blob: 1d2cd4c4b160e77858abe2e71edd5a0261c6bb00 [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,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200105 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200106 ALC268_ACER,
Kailang Yanga361d842007-06-05 12:30:55 +0200107 ALC268_AUTO,
108 ALC268_MODEL_LAST /* last tag */
109};
110
Kailang Yangdf694da2005-12-05 19:42:22 +0100111/* ALC861 models */
112enum {
113 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200114 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100115 ALC861_3ST_DIG,
116 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200117 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200118 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200119 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100120 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100121 ALC861_AUTO,
122 ALC861_MODEL_LAST,
123};
124
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100125/* ALC861-VD models */
126enum {
127 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200128 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100129 ALC861VD_3ST,
130 ALC861VD_3ST_DIG,
131 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200132 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200133 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200134 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100135 ALC861VD_AUTO,
136 ALC861VD_MODEL_LAST,
137};
138
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200139/* ALC662 models */
140enum {
141 ALC662_3ST_2ch_DIG,
142 ALC662_3ST_6ch_DIG,
143 ALC662_3ST_6ch,
144 ALC662_5ST_DIG,
145 ALC662_LENOVO_101E,
146 ALC662_AUTO,
147 ALC662_MODEL_LAST,
148};
149
Kailang Yangdf694da2005-12-05 19:42:22 +0100150/* ALC882 models */
151enum {
152 ALC882_3ST_DIG,
153 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200154 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200155 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_TARGA,
157 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200158 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100159 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200160 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200161 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200162 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100163 ALC882_MODEL_LAST,
164};
165
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200166/* ALC883 models */
167enum {
168 ALC883_3ST_2ch_DIG,
169 ALC883_3ST_6ch_DIG,
170 ALC883_3ST_6ch,
171 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200172 ALC883_TARGA_DIG,
173 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200174 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200175 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200176 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200177 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100178 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200179 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200180 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200181 ALC888_LENOVO_MS7195_DIG,
182 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200183 ALC888_6ST_HP,
184 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200185 ALC883_AUTO,
186 ALC883_MODEL_LAST,
187};
188
Kailang Yangdf694da2005-12-05 19:42:22 +0100189/* for GPIO Poll */
190#define GPIO_MASK 0x03
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192struct alc_spec {
193 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100194 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 unsigned int num_mixers;
196
Kailang Yangdf694da2005-12-05 19:42:22 +0100197 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200198 * don't forget NULL
199 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200200 */
201 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Takashi Iwai16ded522005-06-10 19:58:24 +0200203 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 struct hda_pcm_stream *stream_analog_playback;
205 struct hda_pcm_stream *stream_analog_capture;
206
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200207 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 struct hda_pcm_stream *stream_digital_playback;
209 struct hda_pcm_stream *stream_digital_capture;
210
211 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200212 struct hda_multi_out multiout; /* playback set-up
213 * max_channels, dacs must be set
214 * dig_out_nid and hp_nid are optional
215 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217 /* capture */
218 unsigned int num_adc_nids;
219 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200220 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200223 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 const struct hda_input_mux *input_mux;
225 unsigned int cur_mux[3];
226
227 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100228 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200230 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100233 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200234
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200235 /* dynamic controls, init_verbs and input_mux */
236 struct auto_pin_cfg autocfg;
237 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100238 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200239 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100240 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100241
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100242 /* hooks */
243 void (*init_hook)(struct hda_codec *codec);
244 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
245
Takashi Iwai834be882006-03-01 14:16:17 +0100246 /* for pin sensing */
247 unsigned int sense_updated: 1;
248 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200249
250#ifdef CONFIG_SND_HDA_POWER_SAVE
251 struct hda_loopback_check loopback;
252#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100253};
254
255/*
256 * configuration template - to be copied to the spec instance
257 */
258struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200259 struct snd_kcontrol_new *mixers[5]; /* should be identical size
260 * with spec
261 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100262 const struct hda_verb *init_verbs[5];
263 unsigned int num_dacs;
264 hda_nid_t *dac_nids;
265 hda_nid_t dig_out_nid; /* optional */
266 hda_nid_t hp_nid; /* optional */
267 unsigned int num_adc_nids;
268 hda_nid_t *adc_nids;
269 hda_nid_t dig_in_nid;
270 unsigned int num_channel_mode;
271 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200272 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200273 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100274 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100275 void (*unsol_event)(struct hda_codec *, unsigned int);
276 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200277#ifdef CONFIG_SND_HDA_POWER_SAVE
278 struct hda_amp_list *loopbacks;
279#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280};
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
283/*
284 * input MUX handling
285 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200286static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
289 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
290 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200291 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
292 if (mux_idx >= spec->num_mux_defs)
293 mux_idx = 0;
294 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295}
296
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200297static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
298 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299{
300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
301 struct alc_spec *spec = codec->spec;
302 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
303
304 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
305 return 0;
306}
307
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200308static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
309 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310{
311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 struct alc_spec *spec = codec->spec;
313 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200314 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
315 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200316 spec->adc_nids[adc_idx],
317 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318}
319
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200320
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321/*
322 * channel mode setting
323 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200324static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
328 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100329 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
330 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331}
332
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200333static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
337 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100338 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200339 spec->num_channel_mode,
340 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341}
342
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200343static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200348 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
349 spec->num_channel_mode,
350 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200351 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200352 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
353 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354}
355
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100357 * Control the mode of pin widget settings via the mixer. "pc" is used
358 * instead of "%" to avoid consequences of accidently treating the % as
359 * being part of a format specifier. Maximum allowed length of a value is
360 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100361 *
362 * Note: some retasking pin complexes seem to ignore requests for input
363 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
364 * are requested. Therefore order this list so that this behaviour will not
365 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200366 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
367 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200368 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100369static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100370 "Mic 50pc bias", "Mic 80pc bias",
371 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372};
373static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100374 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100375};
376/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200377 * in the pin being assumed to be exclusively an input or an output pin. In
378 * addition, "input" pins may or may not process the mic bias option
379 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
380 * accept requests for bias as of chip versions up to March 2006) and/or
381 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100382 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200383#define ALC_PIN_DIR_IN 0x00
384#define ALC_PIN_DIR_OUT 0x01
385#define ALC_PIN_DIR_INOUT 0x02
386#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
387#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100388
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100390 * For each direction the minimum and maximum values are given.
391 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200392static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100393 { 0, 2 }, /* ALC_PIN_DIR_IN */
394 { 3, 4 }, /* ALC_PIN_DIR_OUT */
395 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200396 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
397 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100398};
399#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
400#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
401#define alc_pin_mode_n_items(_dir) \
402 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
403
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200404static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200406{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 unsigned int item_num = uinfo->value.enumerated.item;
408 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
409
410 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200411 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100412 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
413
414 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
415 item_num = alc_pin_mode_min(dir);
416 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200417 return 0;
418}
419
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200420static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200422{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
425 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100426 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200427 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200428 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
429 AC_VERB_GET_PIN_WIDGET_CONTROL,
430 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200431
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100432 /* Find enumerated value for current pinctl setting */
433 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200434 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100435 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200436 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100437 return 0;
438}
439
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100442{
443 signed int change;
444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
445 hda_nid_t nid = kcontrol->private_value & 0xffff;
446 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
447 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
449 AC_VERB_GET_PIN_WIDGET_CONTROL,
450 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100451
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200452 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100453 val = alc_pin_mode_min(dir);
454
455 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100456 if (change) {
457 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200458 snd_hda_codec_write_cache(codec, nid, 0,
459 AC_VERB_SET_PIN_WIDGET_CONTROL,
460 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100461
462 /* Also enable the retasking pin's input/output as required
463 * for the requested pin mode. Enum values of 2 or less are
464 * input modes.
465 *
466 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200467 * reduces noise slightly (particularly on input) so we'll
468 * do it. However, having both input and output buffers
469 * enabled simultaneously doesn't seem to be problematic if
470 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100471 */
472 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200473 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
474 HDA_AMP_MUTE, HDA_AMP_MUTE);
475 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
476 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100477 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200478 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
479 HDA_AMP_MUTE, HDA_AMP_MUTE);
480 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
481 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100482 }
483 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200484 return change;
485}
486
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200488 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 .info = alc_pin_mode_info, \
490 .get = alc_pin_mode_get, \
491 .put = alc_pin_mode_put, \
492 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100493
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100494/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
495 * together using a mask with more than one bit set. This control is
496 * currently used only by the ALC260 test model. At this stage they are not
497 * needed for any "production" models.
498 */
499#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200500#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200501
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200502static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100504{
505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
506 hda_nid_t nid = kcontrol->private_value & 0xffff;
507 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
508 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200509 unsigned int val = snd_hda_codec_read(codec, nid, 0,
510 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100511
512 *valp = (val & mask) != 0;
513 return 0;
514}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100517{
518 signed int change;
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 hda_nid_t nid = kcontrol->private_value & 0xffff;
521 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
522 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
524 AC_VERB_GET_GPIO_DATA,
525 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100526
527 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200528 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
529 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100530 gpio_data &= ~mask;
531 else
532 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200533 snd_hda_codec_write_cache(codec, nid, 0,
534 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100535
536 return change;
537}
538#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
539 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
540 .info = alc_gpio_data_info, \
541 .get = alc_gpio_data_get, \
542 .put = alc_gpio_data_put, \
543 .private_value = nid | (mask<<16) }
544#endif /* CONFIG_SND_DEBUG */
545
Jonathan Woithe92621f12006-02-28 11:47:47 +0100546/* A switch control to allow the enabling of the digital IO pins on the
547 * ALC260. This is incredibly simplistic; the intention of this control is
548 * to provide something in the test model allowing digital outputs to be
549 * identified if present. If models are found which can utilise these
550 * outputs a more complete mixer control can be devised for those models if
551 * necessary.
552 */
553#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200554#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200555
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
561 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
562 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563 unsigned int val = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100565
566 *valp = (val & mask) != 0;
567 return 0;
568}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
570 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100571{
572 signed int change;
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 hda_nid_t nid = kcontrol->private_value & 0xffff;
575 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
576 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
578 AC_VERB_GET_DIGI_CONVERT,
579 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100580
581 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200582 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100583 if (val==0)
584 ctrl_data &= ~mask;
585 else
586 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200587 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
588 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100589
590 return change;
591}
592#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
594 .info = alc_spdif_ctrl_info, \
595 .get = alc_spdif_ctrl_get, \
596 .put = alc_spdif_ctrl_put, \
597 .private_value = nid | (mask<<16) }
598#endif /* CONFIG_SND_DEBUG */
599
Kailang Yangdf694da2005-12-05 19:42:22 +0100600/*
601 * set up from the preset table
602 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603static void setup_preset(struct alc_spec *spec,
604 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100605{
606 int i;
607
608 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
609 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200610 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
611 i++)
612 spec->init_verbs[spec->num_init_verbs++] =
613 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100614
615 spec->channel_mode = preset->channel_mode;
616 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200617 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100618
619 spec->multiout.max_channels = spec->channel_mode[0].channels;
620
621 spec->multiout.num_dacs = preset->num_dacs;
622 spec->multiout.dac_nids = preset->dac_nids;
623 spec->multiout.dig_out_nid = preset->dig_out_nid;
624 spec->multiout.hp_nid = preset->hp_nid;
625
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200626 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200627 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200628 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100629 spec->input_mux = preset->input_mux;
630
631 spec->num_adc_nids = preset->num_adc_nids;
632 spec->adc_nids = preset->adc_nids;
633 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100634
635 spec->unsol_event = preset->unsol_event;
636 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200637#ifdef CONFIG_SND_HDA_POWER_SAVE
638 spec->loopback.amplist = preset->loopbacks;
639#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100640}
641
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200642/* Enable GPIO mask and set output */
643static struct hda_verb alc_gpio1_init_verbs[] = {
644 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
647 { }
648};
649
650static struct hda_verb alc_gpio2_init_verbs[] = {
651 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
654 { }
655};
656
Kailang Yangbdd148a2007-05-08 15:19:08 +0200657static struct hda_verb alc_gpio3_init_verbs[] = {
658 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
661 { }
662};
663
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200664/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
665 * 31 ~ 16 : Manufacture ID
666 * 15 ~ 8 : SKU ID
667 * 7 ~ 0 : Assembly ID
668 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
669 */
670static void alc_subsystem_id(struct hda_codec *codec,
671 unsigned int porta, unsigned int porte,
672 unsigned int portd)
673{
674 unsigned int ass, tmp;
675
676 ass = codec->subsystem_id;
677 if (!(ass & 1))
678 return;
679
680 /* Override */
681 tmp = (ass & 0x38) >> 3; /* external Amp control */
682 switch (tmp) {
683 case 1:
684 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
685 break;
686 case 3:
687 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
688 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200689 case 7:
690 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
691 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200692 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200693 switch (codec->vendor_id) {
694 case 0x10ec0862:
695 case 0x10ec0660:
696 case 0x10ec0662:
697 case 0x10ec0267:
698 case 0x10ec0268:
699 snd_hda_codec_write(codec, 0x14, 0,
700 AC_VERB_SET_EAPD_BTLENABLE, 2);
701 snd_hda_codec_write(codec, 0x15, 0,
702 AC_VERB_SET_EAPD_BTLENABLE, 2);
703 return;
704 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200705 case 6:
706 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
707 hda_nid_t port = 0;
708 tmp = (ass & 0x1800) >> 11;
709 switch (tmp) {
710 case 0: port = porta; break;
711 case 1: port = porte; break;
712 case 2: port = portd; break;
713 }
714 if (port)
715 snd_hda_codec_write(codec, port, 0,
716 AC_VERB_SET_EAPD_BTLENABLE,
717 2);
718 }
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
721 (tmp == 5 ? 0x3040 : 0x3050));
722 break;
723 }
724}
725
Takashi Iwai41e41f12005-06-08 14:48:49 +0200726/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200727 * Fix-up pin default configurations
728 */
729
730struct alc_pincfg {
731 hda_nid_t nid;
732 u32 val;
733};
734
735static void alc_fix_pincfg(struct hda_codec *codec,
736 const struct snd_pci_quirk *quirk,
737 const struct alc_pincfg **pinfix)
738{
739 const struct alc_pincfg *cfg;
740
741 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
742 if (!quirk)
743 return;
744
745 cfg = pinfix[quirk->value];
746 for (; cfg->nid; cfg++) {
747 int i;
748 u32 val = cfg->val;
749 for (i = 0; i < 4; i++) {
750 snd_hda_codec_write(codec, cfg->nid, 0,
751 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
752 val & 0xff);
753 val >>= 8;
754 }
755 }
756}
757
758/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200759 * ALC880 3-stack model
760 *
761 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200762 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
763 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 */
765
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200766static hda_nid_t alc880_dac_nids[4] = {
767 /* front, rear, clfe, rear_surr */
768 0x02, 0x05, 0x04, 0x03
769};
770
771static hda_nid_t alc880_adc_nids[3] = {
772 /* ADC0-2 */
773 0x07, 0x08, 0x09,
774};
775
776/* The datasheet says the node 0x07 is connected from inputs,
777 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100778 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200780static hda_nid_t alc880_adc_nids_alt[2] = {
781 /* ADC1-2 */
782 0x08, 0x09,
783};
784
785#define ALC880_DIGOUT_NID 0x06
786#define ALC880_DIGIN_NID 0x0a
787
788static struct hda_input_mux alc880_capture_source = {
789 .num_items = 4,
790 .items = {
791 { "Mic", 0x0 },
792 { "Front Mic", 0x3 },
793 { "Line", 0x2 },
794 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200796};
797
798/* channel source setting (2/6 channel selection for 3-stack) */
799/* 2ch mode */
800static struct hda_verb alc880_threestack_ch2_init[] = {
801 /* set line-in to input, mute it */
802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
804 /* set mic-in to input vref 80%, mute it */
805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 { } /* end */
808};
809
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200810/* 6ch mode */
811static struct hda_verb alc880_threestack_ch6_init[] = {
812 /* set line-in to output, unmute it */
813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
815 /* set mic-in to output, unmute it */
816 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
817 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
818 { } /* end */
819};
820
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100821static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200822 { 2, alc880_threestack_ch2_init },
823 { 6, alc880_threestack_ch6_init },
824};
825
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100826static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100830 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100833 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
834 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
843 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
844 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200846 {
847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
848 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100849 .info = alc_ch_mode_info,
850 .get = alc_ch_mode_get,
851 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200852 },
853 { } /* end */
854};
855
856/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100857static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200858 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
859 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
860 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
861 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
862 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
863 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
864 {
865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
866 /* The multiple "Capture Source" controls confuse alsamixer
867 * So call somewhat different..
868 * FIXME: the controls appear in the "playback" view!
869 */
870 /* .name = "Capture Source", */
871 .name = "Input Source",
872 .count = 3,
873 .info = alc_mux_enum_info,
874 .get = alc_mux_enum_get,
875 .put = alc_mux_enum_put,
876 },
877 { } /* end */
878};
879
880/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100881static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200882 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
883 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 {
887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
888 /* The multiple "Capture Source" controls confuse alsamixer
889 * So call somewhat different..
890 * FIXME: the controls appear in the "playback" view!
891 */
892 /* .name = "Capture Source", */
893 .name = "Input Source",
894 .count = 2,
895 .info = alc_mux_enum_info,
896 .get = alc_mux_enum_get,
897 .put = alc_mux_enum_put,
898 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 { } /* end */
900};
901
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200902
903
904/*
905 * ALC880 5-stack model
906 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200907 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
908 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200909 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
910 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
911 */
912
913/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100914static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200915 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100916 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 { } /* end */
918};
919
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200920/* channel source setting (6/8 channel selection for 5-stack) */
921/* 6ch mode */
922static struct hda_verb alc880_fivestack_ch6_init[] = {
923 /* set line-in to input, mute it */
924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200926 { } /* end */
927};
928
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200929/* 8ch mode */
930static struct hda_verb alc880_fivestack_ch8_init[] = {
931 /* set line-in to output, unmute it */
932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
934 { } /* end */
935};
936
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100937static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200938 { 6, alc880_fivestack_ch6_init },
939 { 8, alc880_fivestack_ch8_init },
940};
941
942
943/*
944 * ALC880 6-stack model
945 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200946 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
947 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200948 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
949 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
950 */
951
952static hda_nid_t alc880_6st_dac_nids[4] = {
953 /* front, rear, clfe, rear_surr */
954 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200955};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200956
957static struct hda_input_mux alc880_6stack_capture_source = {
958 .num_items = 4,
959 .items = {
960 { "Mic", 0x0 },
961 { "Front Mic", 0x1 },
962 { "Line", 0x2 },
963 { "CD", 0x4 },
964 },
965};
966
967/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100968static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200969 { 8, NULL },
970};
971
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100972static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100976 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200981 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100982 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
991 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
992 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200993 {
994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
995 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100996 .info = alc_ch_mode_info,
997 .get = alc_ch_mode_get,
998 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200999 },
1000 { } /* end */
1001};
1002
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001003
1004/*
1005 * ALC880 W810 model
1006 *
1007 * W810 has rear IO for:
1008 * Front (DAC 02)
1009 * Surround (DAC 03)
1010 * Center/LFE (DAC 04)
1011 * Digital out (06)
1012 *
1013 * The system also has a pair of internal speakers, and a headphone jack.
1014 * These are both connected to Line2 on the codec, hence to DAC 02.
1015 *
1016 * There is a variable resistor to control the speaker or headphone
1017 * volume. This is a hardware-only device without a software API.
1018 *
1019 * Plugging headphones in will disable the internal speakers. This is
1020 * implemented in hardware, not via the driver using jack sense. In
1021 * a similar fashion, plugging into the rear socket marked "front" will
1022 * disable both the speakers and headphones.
1023 *
1024 * For input, there's a microphone jack, and an "audio in" jack.
1025 * These may not do anything useful with this driver yet, because I
1026 * haven't setup any initialization verbs for these yet...
1027 */
1028
1029static hda_nid_t alc880_w810_dac_nids[3] = {
1030 /* front, rear/surround, clfe */
1031 0x02, 0x03, 0x04
1032};
1033
1034/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001035static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001036 { 6, NULL }
1037};
1038
1039/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001040static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1050 { } /* end */
1051};
1052
1053
1054/*
1055 * Z710V model
1056 *
1057 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001058 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1059 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001060 */
1061
1062static hda_nid_t alc880_z71v_dac_nids[1] = {
1063 0x02
1064};
1065#define ALC880_Z71V_HP_DAC 0x03
1066
1067/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001068static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001069 { 2, NULL }
1070};
1071
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001072static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1081 { } /* end */
1082};
1083
1084
1085/* FIXME! */
1086/*
1087 * ALC880 F1734 model
1088 *
1089 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1090 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1091 */
1092
1093static hda_nid_t alc880_f1734_dac_nids[1] = {
1094 0x03
1095};
1096#define ALC880_F1734_HP_DAC 0x02
1097
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001098static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001100 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001101 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001102 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001107 { } /* end */
1108};
1109
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001110
1111/* FIXME! */
1112/*
1113 * ALC880 ASUS model
1114 *
1115 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1116 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1117 * Mic = 0x18, Line = 0x1a
1118 */
1119
1120#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1121#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1122
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001123static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001127 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001128 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001138 {
1139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1140 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001141 .info = alc_ch_mode_info,
1142 .get = alc_ch_mode_get,
1143 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001144 },
1145 { } /* end */
1146};
1147
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148/* FIXME! */
1149/*
1150 * ALC880 ASUS W1V model
1151 *
1152 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1153 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1154 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1155 */
1156
1157/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001158static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001159 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1160 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001161 { } /* end */
1162};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001163
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001164/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001165static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1168 { } /* end */
1169};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170
Kailang Yangdf694da2005-12-05 19:42:22 +01001171/* TCL S700 */
1172static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1177 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1180 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1182 {
1183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1184 /* The multiple "Capture Source" controls confuse alsamixer
1185 * So call somewhat different..
1186 * FIXME: the controls appear in the "playback" view!
1187 */
1188 /* .name = "Capture Source", */
1189 .name = "Input Source",
1190 .count = 1,
1191 .info = alc_mux_enum_info,
1192 .get = alc_mux_enum_get,
1193 .put = alc_mux_enum_put,
1194 },
1195 { } /* end */
1196};
1197
Kailang Yangccc656c2006-10-17 12:32:26 +02001198/* Uniwill */
1199static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1200 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1201 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1202 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1210 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1211 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1216 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1217 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1218 {
1219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1220 .name = "Channel Mode",
1221 .info = alc_ch_mode_info,
1222 .get = alc_ch_mode_get,
1223 .put = alc_ch_mode_put,
1224 },
1225 { } /* end */
1226};
1227
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001228static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1229 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1230 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1232 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1235 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1238 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1239 { } /* end */
1240};
1241
Kailang Yangccc656c2006-10-17 12:32:26 +02001242static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1243 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1244 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1245 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1246 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1249 { } /* end */
1250};
1251
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 */
1255static int alc_build_controls(struct hda_codec *codec)
1256{
1257 struct alc_spec *spec = codec->spec;
1258 int err;
1259 int i;
1260
1261 for (i = 0; i < spec->num_mixers; i++) {
1262 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1263 if (err < 0)
1264 return err;
1265 }
1266
1267 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001268 err = snd_hda_create_spdif_out_ctls(codec,
1269 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 if (err < 0)
1271 return err;
1272 }
1273 if (spec->dig_in_nid) {
1274 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1275 if (err < 0)
1276 return err;
1277 }
1278 return 0;
1279}
1280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001281
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282/*
1283 * initialize the codec volumes, etc
1284 */
1285
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001286/*
1287 * generic initialization of ADC, input mixers and output mixers
1288 */
1289static struct hda_verb alc880_volume_init_verbs[] = {
1290 /*
1291 * Unmute ADC0-2 and set the default input to mic-in
1292 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001293 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001295 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001297 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001300 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1301 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001302 * Note: PASD motherboards uses the Line In 2 as the input for front
1303 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001305 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001314 /*
1315 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001317 /* set vol=0 to output mixers */
1318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1322 /* set up input amps for analog loopback */
1323 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332
1333 { }
1334};
1335
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001336/*
1337 * 3-stack pin configuration:
1338 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1339 */
1340static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1341 /*
1342 * preset connection lists of input pins
1343 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1344 */
1345 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1346 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1347 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1348
1349 /*
1350 * Set pin mode and muting
1351 */
1352 /* set front pin widgets 0x14 for output */
1353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1358 /* Mic2 (as headphone out) for HP output */
1359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 /* Line In pin widget for input */
1362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1363 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* Line2 (as front mic) pin widget for input and vref at 80% */
1365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1366 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1367 /* CD pin widget for input */
1368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1369
1370 { }
1371};
1372
1373/*
1374 * 5-stack pin configuration:
1375 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1376 * line-in/side = 0x1a, f-mic = 0x1b
1377 */
1378static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1379 /*
1380 * preset connection lists of input pins
1381 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1382 */
1383 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1384 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1385
1386 /*
1387 * Set pin mode and muting
1388 */
1389 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001394 /* unmute pins for output (no gain on this amp) */
1395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1399
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 /* Mic2 (as headphone out) for HP output */
1404 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001406 /* Line In pin widget for input */
1407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1409 /* Line2 (as front mic) pin widget for input and vref at 80% */
1410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1411 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1412 /* CD pin widget for input */
1413 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414
1415 { }
1416};
1417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418/*
1419 * W810 pin configuration:
1420 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1421 */
1422static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 /* hphone/speaker input selector: front DAC */
1424 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1425
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1431 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1432
1433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 { }
1437};
1438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439/*
1440 * Z71V pin configuration:
1441 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1442 */
1443static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001448
Takashi Iwai16ded522005-06-10 19:58:24 +02001449 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001452 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001453
1454 { }
1455};
1456
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001457/*
1458 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001459 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1460 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001461 */
1462static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1464
Takashi Iwai16ded522005-06-10 19:58:24 +02001465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473
Takashi Iwai16ded522005-06-10 19:58:24 +02001474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001481 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001484 { }
1485};
Takashi Iwai16ded522005-06-10 19:58:24 +02001486
Kailang Yangccc656c2006-10-17 12:32:26 +02001487/*
1488 * Uniwill pin configuration:
1489 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1490 * line = 0x1a
1491 */
1492static struct hda_verb alc880_uniwill_init_verbs[] = {
1493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1494
1495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1509
1510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1516 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1517 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1519
1520 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1521 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1522
1523 { }
1524};
1525
1526/*
1527* Uniwill P53
1528* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1529 */
1530static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1531 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1532
1533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1545
1546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1548 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1550 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1551 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1552
1553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1554 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1555
1556 { }
1557};
1558
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001559static struct hda_verb alc880_beep_init_verbs[] = {
1560 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1561 { }
1562};
1563
Kailang Yangccc656c2006-10-17 12:32:26 +02001564/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001565static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001566{
1567 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001568 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001569
1570 present = snd_hda_codec_read(codec, 0x14, 0,
1571 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001572 bits = present ? HDA_AMP_MUTE : 0;
1573 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1574 HDA_AMP_MUTE, bits);
1575 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1576 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001577}
1578
1579/* auto-toggle front mic */
1580static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1581{
1582 unsigned int present;
1583 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001584
1585 present = snd_hda_codec_read(codec, 0x18, 0,
1586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001587 bits = present ? HDA_AMP_MUTE : 0;
1588 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001589}
1590
1591static void alc880_uniwill_automute(struct hda_codec *codec)
1592{
1593 alc880_uniwill_hp_automute(codec);
1594 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001595}
1596
1597static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1598 unsigned int res)
1599{
1600 /* Looks like the unsol event is incompatible with the standard
1601 * definition. 4bit tag is placed at 28 bit!
1602 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001603 switch (res >> 28) {
1604 case ALC880_HP_EVENT:
1605 alc880_uniwill_hp_automute(codec);
1606 break;
1607 case ALC880_MIC_EVENT:
1608 alc880_uniwill_mic_automute(codec);
1609 break;
1610 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001611}
1612
1613static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1614{
1615 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001616 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001617
1618 present = snd_hda_codec_read(codec, 0x14, 0,
1619 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001620 bits = present ? HDA_AMP_MUTE : 0;
1621 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001622}
1623
1624static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1625{
1626 unsigned int present;
1627
1628 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001629 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1630 present &= HDA_AMP_VOLMASK;
1631 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1632 HDA_AMP_VOLMASK, present);
1633 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1634 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001635}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001636
Kailang Yangccc656c2006-10-17 12:32:26 +02001637static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1638 unsigned int res)
1639{
1640 /* Looks like the unsol event is incompatible with the standard
1641 * definition. 4bit tag is placed at 28 bit!
1642 */
1643 if ((res >> 28) == ALC880_HP_EVENT)
1644 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001645 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001646 alc880_uniwill_p53_dcvol_automute(codec);
1647}
1648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001649/* FIXME! */
1650/*
1651 * F1734 pin configuration:
1652 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1653 */
1654static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1655 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1656 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1657 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1659
1660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664
1665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001674
1675 { }
1676};
1677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678/* FIXME! */
1679/*
1680 * ASUS pin configuration:
1681 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1682 */
1683static struct hda_verb alc880_pin_asus_init_verbs[] = {
1684 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1685 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1686 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1687 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1688
1689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697
1698 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1700 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1702 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1707
1708 { }
1709};
1710
1711/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001712#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1713#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001714
Kailang Yangdf694da2005-12-05 19:42:22 +01001715/* Clevo m520g init */
1716static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1717 /* headphone output */
1718 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1719 /* line-out */
1720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 /* Line-in */
1723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 /* CD */
1726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1728 /* Mic1 (rear panel) */
1729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 /* Mic2 (front panel) */
1732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 /* headphone */
1735 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737 /* change to EAPD mode */
1738 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1739 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1740
1741 { }
1742};
1743
1744static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001745 /* change to EAPD mode */
1746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1747 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1748
Kailang Yangdf694da2005-12-05 19:42:22 +01001749 /* Headphone output */
1750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1751 /* Front output*/
1752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1753 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1754
1755 /* Line In pin widget for input */
1756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1757 /* CD pin widget for input */
1758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1759 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1761
1762 /* change to EAPD mode */
1763 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1764 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1765
1766 { }
1767};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001768
1769/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001770 * LG m1 express dual
1771 *
1772 * Pin assignment:
1773 * Rear Line-In/Out (blue): 0x14
1774 * Build-in Mic-In: 0x15
1775 * Speaker-out: 0x17
1776 * HP-Out (green): 0x1b
1777 * Mic-In/Out (red): 0x19
1778 * SPDIF-Out: 0x1e
1779 */
1780
1781/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1782static hda_nid_t alc880_lg_dac_nids[3] = {
1783 0x05, 0x02, 0x03
1784};
1785
1786/* seems analog CD is not working */
1787static struct hda_input_mux alc880_lg_capture_source = {
1788 .num_items = 3,
1789 .items = {
1790 { "Mic", 0x1 },
1791 { "Line", 0x5 },
1792 { "Internal Mic", 0x6 },
1793 },
1794};
1795
1796/* 2,4,6 channel modes */
1797static struct hda_verb alc880_lg_ch2_init[] = {
1798 /* set line-in and mic-in to input */
1799 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1800 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1801 { }
1802};
1803
1804static struct hda_verb alc880_lg_ch4_init[] = {
1805 /* set line-in to out and mic-in to input */
1806 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1807 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1808 { }
1809};
1810
1811static struct hda_verb alc880_lg_ch6_init[] = {
1812 /* set line-in and mic-in to output */
1813 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1814 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1815 { }
1816};
1817
1818static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1819 { 2, alc880_lg_ch2_init },
1820 { 4, alc880_lg_ch4_init },
1821 { 6, alc880_lg_ch6_init },
1822};
1823
1824static struct snd_kcontrol_new alc880_lg_mixer[] = {
1825 /* FIXME: it's not really "master" but front channels */
1826 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1827 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1828 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1830 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1838 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1839 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1840 {
1841 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1842 .name = "Channel Mode",
1843 .info = alc_ch_mode_info,
1844 .get = alc_ch_mode_get,
1845 .put = alc_ch_mode_put,
1846 },
1847 { } /* end */
1848};
1849
1850static struct hda_verb alc880_lg_init_verbs[] = {
1851 /* set capture source to mic-in */
1852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1855 /* mute all amp mixer inputs */
1856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001859 /* line-in to input */
1860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 /* built-in mic */
1863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 /* speaker-out */
1866 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1867 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1868 /* mic-in to input */
1869 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1872 /* HP-out */
1873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1876 /* jack sense */
1877 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1878 { }
1879};
1880
1881/* toggle speaker-output according to the hp-jack state */
1882static void alc880_lg_automute(struct hda_codec *codec)
1883{
1884 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001885 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001886
1887 present = snd_hda_codec_read(codec, 0x1b, 0,
1888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001889 bits = present ? HDA_AMP_MUTE : 0;
1890 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1891 HDA_AMP_MUTE, 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)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01001961 /* 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 Iwai47fd8302007-08-10 17:11:07 +02001986 bits = present ? HDA_AMP_MUTE : 0;
1987 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1988 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001989}
1990
1991static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1992{
1993 /* Looks like the unsol event is incompatible with the standard
1994 * definition. 4bit tag is placed at 28 bit!
1995 */
1996 if ((res >> 28) == 0x01)
1997 alc880_lg_lw_automute(codec);
1998}
1999
Takashi Iwaicb53c622007-08-10 17:21:45 +02002000#ifdef CONFIG_SND_HDA_POWER_SAVE
2001static struct hda_amp_list alc880_loopbacks[] = {
2002 { 0x0b, HDA_INPUT, 0 },
2003 { 0x0b, HDA_INPUT, 1 },
2004 { 0x0b, HDA_INPUT, 2 },
2005 { 0x0b, HDA_INPUT, 3 },
2006 { 0x0b, HDA_INPUT, 4 },
2007 { } /* end */
2008};
2009
2010static struct hda_amp_list alc880_lg_loopbacks[] = {
2011 { 0x0b, HDA_INPUT, 1 },
2012 { 0x0b, HDA_INPUT, 6 },
2013 { 0x0b, HDA_INPUT, 7 },
2014 { } /* end */
2015};
2016#endif
2017
Takashi Iwaid6815182006-03-23 16:06:23 +01002018/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002019 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002021
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022static int alc_init(struct hda_codec *codec)
2023{
2024 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025 unsigned int i;
2026
2027 for (i = 0; i < spec->num_init_verbs; i++)
2028 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002029
2030 if (spec->init_hook)
2031 spec->init_hook(codec);
2032
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 return 0;
2034}
2035
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002036static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2037{
2038 struct alc_spec *spec = codec->spec;
2039
2040 if (spec->unsol_event)
2041 spec->unsol_event(codec, res);
2042}
2043
Takashi Iwaicb53c622007-08-10 17:21:45 +02002044#ifdef CONFIG_SND_HDA_POWER_SAVE
2045static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2046{
2047 struct alc_spec *spec = codec->spec;
2048 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2049}
2050#endif
2051
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052/*
2053 * Analog playback callbacks
2054 */
2055static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2056 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002057 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058{
2059 struct alc_spec *spec = codec->spec;
2060 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2061}
2062
2063static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2064 struct hda_codec *codec,
2065 unsigned int stream_tag,
2066 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002067 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002068{
2069 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002070 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2071 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002072}
2073
2074static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2075 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002076 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077{
2078 struct alc_spec *spec = codec->spec;
2079 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2080}
2081
2082/*
2083 * Digital out
2084 */
2085static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2086 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002087 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088{
2089 struct alc_spec *spec = codec->spec;
2090 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2091}
2092
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002093static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2094 struct hda_codec *codec,
2095 unsigned int stream_tag,
2096 unsigned int format,
2097 struct snd_pcm_substream *substream)
2098{
2099 struct alc_spec *spec = codec->spec;
2100 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2101 stream_tag, format, substream);
2102}
2103
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2105 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002106 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107{
2108 struct alc_spec *spec = codec->spec;
2109 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2110}
2111
2112/*
2113 * Analog capture
2114 */
2115static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2116 struct hda_codec *codec,
2117 unsigned int stream_tag,
2118 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002119 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120{
2121 struct alc_spec *spec = codec->spec;
2122
2123 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2124 stream_tag, 0, format);
2125 return 0;
2126}
2127
2128static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2129 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002130 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131{
2132 struct alc_spec *spec = codec->spec;
2133
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002134 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2135 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 return 0;
2137}
2138
2139
2140/*
2141 */
2142static struct hda_pcm_stream alc880_pcm_analog_playback = {
2143 .substreams = 1,
2144 .channels_min = 2,
2145 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002146 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147 .ops = {
2148 .open = alc880_playback_pcm_open,
2149 .prepare = alc880_playback_pcm_prepare,
2150 .cleanup = alc880_playback_pcm_cleanup
2151 },
2152};
2153
2154static struct hda_pcm_stream alc880_pcm_analog_capture = {
2155 .substreams = 2,
2156 .channels_min = 2,
2157 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 .ops = {
2160 .prepare = alc880_capture_pcm_prepare,
2161 .cleanup = alc880_capture_pcm_cleanup
2162 },
2163};
2164
2165static struct hda_pcm_stream alc880_pcm_digital_playback = {
2166 .substreams = 1,
2167 .channels_min = 2,
2168 .channels_max = 2,
2169 /* NID is set in alc_build_pcms */
2170 .ops = {
2171 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002172 .close = alc880_dig_playback_pcm_close,
2173 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 },
2175};
2176
2177static struct hda_pcm_stream alc880_pcm_digital_capture = {
2178 .substreams = 1,
2179 .channels_min = 2,
2180 .channels_max = 2,
2181 /* NID is set in alc_build_pcms */
2182};
2183
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002184/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2185static struct hda_pcm_stream alc_pcm_null_playback = {
2186 .substreams = 0,
2187 .channels_min = 0,
2188 .channels_max = 0,
2189};
2190
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191static int alc_build_pcms(struct hda_codec *codec)
2192{
2193 struct alc_spec *spec = codec->spec;
2194 struct hda_pcm *info = spec->pcm_rec;
2195 int i;
2196
2197 codec->num_pcms = 1;
2198 codec->pcm_info = info;
2199
2200 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002201 if (spec->stream_analog_playback) {
2202 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2203 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2205 }
2206 if (spec->stream_analog_capture) {
2207 snd_assert(spec->adc_nids, return -EINVAL);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2209 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2210 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211
Takashi Iwai4a471b72005-12-07 13:56:29 +01002212 if (spec->channel_mode) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2214 for (i = 0; i < spec->num_channel_mode; i++) {
2215 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2216 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2217 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 }
2219 }
2220
Takashi Iwaie08a0072006-09-07 17:52:14 +02002221 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002223 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002224 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002226 if (spec->multiout.dig_out_nid &&
2227 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2229 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2230 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002231 if (spec->dig_in_nid &&
2232 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2234 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2235 }
2236 }
2237
Takashi Iwaie08a0072006-09-07 17:52:14 +02002238 /* If the use of more than one ADC is requested for the current
2239 * model, configure a second analog capture-only PCM.
2240 */
2241 /* Additional Analaog capture for index #2 */
2242 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2243 spec->adc_nids) {
2244 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002245 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002246 info->name = spec->stream_name_analog;
2247 /* No playback stream for second PCM */
2248 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2249 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2250 if (spec->stream_analog_capture) {
2251 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2252 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2253 }
2254 }
2255
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 return 0;
2257}
2258
2259static void alc_free(struct hda_codec *codec)
2260{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002261 struct alc_spec *spec = codec->spec;
2262 unsigned int i;
2263
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002264 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265 return;
2266
2267 if (spec->kctl_alloc) {
2268 for (i = 0; i < spec->num_kctl_used; i++)
2269 kfree(spec->kctl_alloc[i].name);
2270 kfree(spec->kctl_alloc);
2271 }
2272 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273}
2274
2275/*
2276 */
2277static struct hda_codec_ops alc_patch_ops = {
2278 .build_controls = alc_build_controls,
2279 .build_pcms = alc_build_pcms,
2280 .init = alc_init,
2281 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002282 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002283#ifdef CONFIG_SND_HDA_POWER_SAVE
2284 .check_power_status = alc_check_power_status,
2285#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286};
2287
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002288
2289/*
2290 * Test configuration for debugging
2291 *
2292 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2293 * enum controls.
2294 */
2295#ifdef CONFIG_SND_DEBUG
2296static hda_nid_t alc880_test_dac_nids[4] = {
2297 0x02, 0x03, 0x04, 0x05
2298};
2299
2300static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002301 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002302 .items = {
2303 { "In-1", 0x0 },
2304 { "In-2", 0x1 },
2305 { "In-3", 0x2 },
2306 { "In-4", 0x3 },
2307 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002308 { "Front", 0x5 },
2309 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002310 },
2311};
2312
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002313static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002314 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002315 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002316 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002317 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002318};
2319
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002320static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2321 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002322{
2323 static char *texts[] = {
2324 "N/A", "Line Out", "HP Out",
2325 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2326 };
2327 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2328 uinfo->count = 1;
2329 uinfo->value.enumerated.items = 8;
2330 if (uinfo->value.enumerated.item >= 8)
2331 uinfo->value.enumerated.item = 7;
2332 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2333 return 0;
2334}
2335
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002336static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2337 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002338{
2339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2340 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2341 unsigned int pin_ctl, item = 0;
2342
2343 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2344 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2345 if (pin_ctl & AC_PINCTL_OUT_EN) {
2346 if (pin_ctl & AC_PINCTL_HP_EN)
2347 item = 2;
2348 else
2349 item = 1;
2350 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2351 switch (pin_ctl & AC_PINCTL_VREFEN) {
2352 case AC_PINCTL_VREF_HIZ: item = 3; break;
2353 case AC_PINCTL_VREF_50: item = 4; break;
2354 case AC_PINCTL_VREF_GRD: item = 5; break;
2355 case AC_PINCTL_VREF_80: item = 6; break;
2356 case AC_PINCTL_VREF_100: item = 7; break;
2357 }
2358 }
2359 ucontrol->value.enumerated.item[0] = item;
2360 return 0;
2361}
2362
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002363static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002365{
2366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2367 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2368 static unsigned int ctls[] = {
2369 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2372 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2374 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2375 };
2376 unsigned int old_ctl, new_ctl;
2377
2378 old_ctl = snd_hda_codec_read(codec, nid, 0,
2379 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2380 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2381 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002382 int val;
2383 snd_hda_codec_write_cache(codec, nid, 0,
2384 AC_VERB_SET_PIN_WIDGET_CONTROL,
2385 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002386 val = ucontrol->value.enumerated.item[0] >= 3 ?
2387 HDA_AMP_MUTE : 0;
2388 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2389 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002390 return 1;
2391 }
2392 return 0;
2393}
2394
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002395static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2396 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002397{
2398 static char *texts[] = {
2399 "Front", "Surround", "CLFE", "Side"
2400 };
2401 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2402 uinfo->count = 1;
2403 uinfo->value.enumerated.items = 4;
2404 if (uinfo->value.enumerated.item >= 4)
2405 uinfo->value.enumerated.item = 3;
2406 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2407 return 0;
2408}
2409
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002410static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2411 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002412{
2413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2414 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2415 unsigned int sel;
2416
2417 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2418 ucontrol->value.enumerated.item[0] = sel & 3;
2419 return 0;
2420}
2421
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002422static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2423 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002424{
2425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2426 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2427 unsigned int sel;
2428
2429 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2430 if (ucontrol->value.enumerated.item[0] != sel) {
2431 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002432 snd_hda_codec_write_cache(codec, nid, 0,
2433 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002434 return 1;
2435 }
2436 return 0;
2437}
2438
2439#define PIN_CTL_TEST(xname,nid) { \
2440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2441 .name = xname, \
2442 .info = alc_test_pin_ctl_info, \
2443 .get = alc_test_pin_ctl_get, \
2444 .put = alc_test_pin_ctl_put, \
2445 .private_value = nid \
2446 }
2447
2448#define PIN_SRC_TEST(xname,nid) { \
2449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2450 .name = xname, \
2451 .info = alc_test_pin_src_info, \
2452 .get = alc_test_pin_src_get, \
2453 .put = alc_test_pin_src_put, \
2454 .private_value = nid \
2455 }
2456
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002457static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002458 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2459 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2460 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2461 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002462 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2463 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2464 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2465 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002466 PIN_CTL_TEST("Front Pin Mode", 0x14),
2467 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2468 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2469 PIN_CTL_TEST("Side Pin Mode", 0x17),
2470 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2471 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2472 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2473 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2474 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2475 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2476 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2477 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2478 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2479 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2480 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2481 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2482 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2483 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2484 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2485 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002488 {
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2490 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002491 .info = alc_ch_mode_info,
2492 .get = alc_ch_mode_get,
2493 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002494 },
2495 { } /* end */
2496};
2497
2498static struct hda_verb alc880_test_init_verbs[] = {
2499 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002508 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002513 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2516 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002518 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002523 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002524 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2528 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002529 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2533 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002534 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002536 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002540 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002541 /* Analog input/passthru */
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002547 { }
2548};
2549#endif
2550
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551/*
2552 */
2553
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002554static const char *alc880_models[ALC880_MODEL_LAST] = {
2555 [ALC880_3ST] = "3stack",
2556 [ALC880_TCL_S700] = "tcl",
2557 [ALC880_3ST_DIG] = "3stack-digout",
2558 [ALC880_CLEVO] = "clevo",
2559 [ALC880_5ST] = "5stack",
2560 [ALC880_5ST_DIG] = "5stack-digout",
2561 [ALC880_W810] = "w810",
2562 [ALC880_Z71V] = "z71v",
2563 [ALC880_6ST] = "6stack",
2564 [ALC880_6ST_DIG] = "6stack-digout",
2565 [ALC880_ASUS] = "asus",
2566 [ALC880_ASUS_W1V] = "asus-w1v",
2567 [ALC880_ASUS_DIG] = "asus-dig",
2568 [ALC880_ASUS_DIG2] = "asus-dig2",
2569 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002570 [ALC880_UNIWILL_P53] = "uniwill-p53",
2571 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002572 [ALC880_F1734] = "F1734",
2573 [ALC880_LG] = "lg",
2574 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002575#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002576 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002577#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002578 [ALC880_AUTO] = "auto",
2579};
2580
2581static struct snd_pci_quirk alc880_cfg_tbl[] = {
2582 /* Broken BIOS configuration */
2583 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2584 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2585
2586 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2587 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002588 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002589 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2592 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2593 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2594 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2595
2596 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2597 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2598
2599 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2600 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2603 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2604 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2606 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2607 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002609 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002610 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2611 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2612 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2613 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2614
2615 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2616 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2617 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2618 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2619 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2620 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2621 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2622 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2623 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2624 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2625 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2626 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2627 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2630 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2631 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2632 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2633
2634 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2635 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2636 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2637 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2638
2639 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2640 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2641 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002642 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002643
2644 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2645 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2646 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2647 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2648
2649 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2657 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2658 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2659 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002660
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 {}
2662};
2663
Takashi Iwai16ded522005-06-10 19:58:24 +02002664/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002665 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002667static struct alc_config_preset alc880_presets[] = {
2668 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002670 .init_verbs = { alc880_volume_init_verbs,
2671 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2675 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002676 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 .input_mux = &alc880_capture_source,
2678 },
2679 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002681 .init_verbs = { alc880_volume_init_verbs,
2682 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 .dac_nids = alc880_dac_nids,
2685 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2687 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002688 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002689 .input_mux = &alc880_capture_source,
2690 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002691 [ALC880_TCL_S700] = {
2692 .mixers = { alc880_tcl_s700_mixer },
2693 .init_verbs = { alc880_volume_init_verbs,
2694 alc880_pin_tcl_S700_init_verbs,
2695 alc880_gpio2_init_verbs },
2696 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2697 .dac_nids = alc880_dac_nids,
2698 .hp_nid = 0x03,
2699 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2700 .channel_mode = alc880_2_jack_modes,
2701 .input_mux = &alc880_capture_source,
2702 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002703 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002704 .mixers = { alc880_three_stack_mixer,
2705 alc880_five_stack_mixer},
2706 .init_verbs = { alc880_volume_init_verbs,
2707 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002708 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2709 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002710 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2711 .channel_mode = alc880_fivestack_modes,
2712 .input_mux = &alc880_capture_source,
2713 },
2714 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002715 .mixers = { alc880_three_stack_mixer,
2716 alc880_five_stack_mixer },
2717 .init_verbs = { alc880_volume_init_verbs,
2718 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002719 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2720 .dac_nids = alc880_dac_nids,
2721 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002722 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2723 .channel_mode = alc880_fivestack_modes,
2724 .input_mux = &alc880_capture_source,
2725 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002726 [ALC880_6ST] = {
2727 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002728 .init_verbs = { alc880_volume_init_verbs,
2729 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002730 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2731 .dac_nids = alc880_6st_dac_nids,
2732 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2733 .channel_mode = alc880_sixstack_modes,
2734 .input_mux = &alc880_6stack_capture_source,
2735 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002736 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002737 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002738 .init_verbs = { alc880_volume_init_verbs,
2739 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002740 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2741 .dac_nids = alc880_6st_dac_nids,
2742 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002743 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2744 .channel_mode = alc880_sixstack_modes,
2745 .input_mux = &alc880_6stack_capture_source,
2746 },
2747 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002748 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002749 .init_verbs = { alc880_volume_init_verbs,
2750 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002751 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002752 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2753 .dac_nids = alc880_w810_dac_nids,
2754 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002755 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2756 .channel_mode = alc880_w810_modes,
2757 .input_mux = &alc880_capture_source,
2758 },
2759 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002760 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002761 .init_verbs = { alc880_volume_init_verbs,
2762 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002763 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2764 .dac_nids = alc880_z71v_dac_nids,
2765 .dig_out_nid = ALC880_DIGOUT_NID,
2766 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2768 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002769 .input_mux = &alc880_capture_source,
2770 },
2771 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002773 .init_verbs = { alc880_volume_init_verbs,
2774 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2776 .dac_nids = alc880_f1734_dac_nids,
2777 .hp_nid = 0x02,
2778 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2779 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002780 .input_mux = &alc880_capture_source,
2781 },
2782 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002784 .init_verbs = { alc880_volume_init_verbs,
2785 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 alc880_gpio1_init_verbs },
2787 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2788 .dac_nids = alc880_asus_dac_nids,
2789 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2790 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002791 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 .input_mux = &alc880_capture_source,
2793 },
2794 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002796 .init_verbs = { alc880_volume_init_verbs,
2797 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002798 alc880_gpio1_init_verbs },
2799 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2800 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2803 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002804 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 .input_mux = &alc880_capture_source,
2806 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002807 [ALC880_ASUS_DIG2] = {
2808 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002809 .init_verbs = { alc880_volume_init_verbs,
2810 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002811 alc880_gpio2_init_verbs }, /* use GPIO2 */
2812 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2813 .dac_nids = alc880_asus_dac_nids,
2814 .dig_out_nid = ALC880_DIGOUT_NID,
2815 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2816 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002817 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002818 .input_mux = &alc880_capture_source,
2819 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002820 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002821 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002822 .init_verbs = { alc880_volume_init_verbs,
2823 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824 alc880_gpio1_init_verbs },
2825 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2826 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002827 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2829 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002830 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002831 .input_mux = &alc880_capture_source,
2832 },
2833 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002834 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002835 .init_verbs = { alc880_volume_init_verbs,
2836 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2838 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002839 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002840 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2841 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002842 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002843 .input_mux = &alc880_capture_source,
2844 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002845 [ALC880_UNIWILL] = {
2846 .mixers = { alc880_uniwill_mixer },
2847 .init_verbs = { alc880_volume_init_verbs,
2848 alc880_uniwill_init_verbs },
2849 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2850 .dac_nids = alc880_asus_dac_nids,
2851 .dig_out_nid = ALC880_DIGOUT_NID,
2852 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2853 .channel_mode = alc880_threestack_modes,
2854 .need_dac_fix = 1,
2855 .input_mux = &alc880_capture_source,
2856 .unsol_event = alc880_uniwill_unsol_event,
2857 .init_hook = alc880_uniwill_automute,
2858 },
2859 [ALC880_UNIWILL_P53] = {
2860 .mixers = { alc880_uniwill_p53_mixer },
2861 .init_verbs = { alc880_volume_init_verbs,
2862 alc880_uniwill_p53_init_verbs },
2863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2864 .dac_nids = alc880_asus_dac_nids,
2865 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002866 .channel_mode = alc880_threestack_modes,
2867 .input_mux = &alc880_capture_source,
2868 .unsol_event = alc880_uniwill_p53_unsol_event,
2869 .init_hook = alc880_uniwill_p53_hp_automute,
2870 },
2871 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002872 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002873 alc880_pcbeep_mixer, },
2874 .init_verbs = { alc880_volume_init_verbs,
2875 alc880_uniwill_p53_init_verbs,
2876 alc880_beep_init_verbs },
2877 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2878 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02002879 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002880 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2881 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002882 .input_mux = &alc880_capture_source,
2883 .unsol_event = alc880_uniwill_p53_unsol_event,
2884 .init_hook = alc880_uniwill_p53_hp_automute,
2885 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002886 [ALC880_CLEVO] = {
2887 .mixers = { alc880_three_stack_mixer },
2888 .init_verbs = { alc880_volume_init_verbs,
2889 alc880_pin_clevo_init_verbs },
2890 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2891 .dac_nids = alc880_dac_nids,
2892 .hp_nid = 0x03,
2893 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2894 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002895 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002896 .input_mux = &alc880_capture_source,
2897 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002898 [ALC880_LG] = {
2899 .mixers = { alc880_lg_mixer },
2900 .init_verbs = { alc880_volume_init_verbs,
2901 alc880_lg_init_verbs },
2902 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2903 .dac_nids = alc880_lg_dac_nids,
2904 .dig_out_nid = ALC880_DIGOUT_NID,
2905 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2906 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002907 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002908 .input_mux = &alc880_lg_capture_source,
2909 .unsol_event = alc880_lg_unsol_event,
2910 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002911#ifdef CONFIG_SND_HDA_POWER_SAVE
2912 .loopbacks = alc880_lg_loopbacks,
2913#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002914 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002915 [ALC880_LG_LW] = {
2916 .mixers = { alc880_lg_lw_mixer },
2917 .init_verbs = { alc880_volume_init_verbs,
2918 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002920 .dac_nids = alc880_dac_nids,
2921 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002922 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2923 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002924 .input_mux = &alc880_lg_lw_capture_source,
2925 .unsol_event = alc880_lg_lw_unsol_event,
2926 .init_hook = alc880_lg_lw_automute,
2927 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002928#ifdef CONFIG_SND_DEBUG
2929 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930 .mixers = { alc880_test_mixer },
2931 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002932 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2933 .dac_nids = alc880_test_dac_nids,
2934 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002935 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2936 .channel_mode = alc880_test_modes,
2937 .input_mux = &alc880_test_capture_source,
2938 },
2939#endif
2940};
2941
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002942/*
2943 * Automatic parse of I/O pins from the BIOS configuration
2944 */
2945
2946#define NUM_CONTROL_ALLOC 32
2947#define NUM_VERB_ALLOC 32
2948
2949enum {
2950 ALC_CTL_WIDGET_VOL,
2951 ALC_CTL_WIDGET_MUTE,
2952 ALC_CTL_BIND_MUTE,
2953};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002954static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2956 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002957 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958};
2959
2960/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961static int add_control(struct alc_spec *spec, int type, const char *name,
2962 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002964 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002965
2966 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2967 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2968
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002969 /* array + terminator */
2970 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2971 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 return -ENOMEM;
2973 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002974 memcpy(knew, spec->kctl_alloc,
2975 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002976 kfree(spec->kctl_alloc);
2977 }
2978 spec->kctl_alloc = knew;
2979 spec->num_kctl_alloc = num;
2980 }
2981
2982 knew = &spec->kctl_alloc[spec->num_kctl_used];
2983 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002984 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002985 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002986 return -ENOMEM;
2987 knew->private_value = val;
2988 spec->num_kctl_used++;
2989 return 0;
2990}
2991
2992#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2993#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2994#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2995#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2996#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2997#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2998#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2999#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3000#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3001#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3002#define ALC880_PIN_CD_NID 0x1c
3003
3004/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003005static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3006 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007{
3008 hda_nid_t nid;
3009 int assigned[4];
3010 int i, j;
3011
3012 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003013 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003014
3015 /* check the pins hardwired to audio widget */
3016 for (i = 0; i < cfg->line_outs; i++) {
3017 nid = cfg->line_out_pins[i];
3018 if (alc880_is_fixed_pin(nid)) {
3019 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003020 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003021 assigned[idx] = 1;
3022 }
3023 }
3024 /* left pins can be connect to any audio widget */
3025 for (i = 0; i < cfg->line_outs; i++) {
3026 nid = cfg->line_out_pins[i];
3027 if (alc880_is_fixed_pin(nid))
3028 continue;
3029 /* search for an empty channel */
3030 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003031 if (!assigned[j]) {
3032 spec->multiout.dac_nids[i] =
3033 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034 assigned[j] = 1;
3035 break;
3036 }
3037 }
3038 }
3039 spec->multiout.num_dacs = cfg->line_outs;
3040 return 0;
3041}
3042
3043/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003044static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3045 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003046{
3047 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003048 static const char *chname[4] = {
3049 "Front", "Surround", NULL /*CLFE*/, "Side"
3050 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003051 hda_nid_t nid;
3052 int i, err;
3053
3054 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003055 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003056 continue;
3057 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3058 if (i == 2) {
3059 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003060 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3061 "Center Playback Volume",
3062 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3063 HDA_OUTPUT));
3064 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003065 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003066 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3067 "LFE Playback Volume",
3068 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3069 HDA_OUTPUT));
3070 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003071 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003072 err = add_control(spec, ALC_CTL_BIND_MUTE,
3073 "Center Playback Switch",
3074 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3075 HDA_INPUT));
3076 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003078 err = add_control(spec, ALC_CTL_BIND_MUTE,
3079 "LFE Playback Switch",
3080 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3081 HDA_INPUT));
3082 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003083 return err;
3084 } else {
3085 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003086 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3087 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3088 HDA_OUTPUT));
3089 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 return err;
3091 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003092 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3093 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3094 HDA_INPUT));
3095 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 return err;
3097 }
3098 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003099 return 0;
3100}
3101
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003102/* add playback controls for speaker and HP outputs */
3103static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3104 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105{
3106 hda_nid_t nid;
3107 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003108 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003110 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111 return 0;
3112
3113 if (alc880_is_fixed_pin(pin)) {
3114 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003115 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003116 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003118 else
3119 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003120 /* control HP volume/switch on the output mixer amp */
3121 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003122 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003123 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3124 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3125 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003127 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003128 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3129 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3130 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003131 return err;
3132 } else if (alc880_is_multi_pin(pin)) {
3133 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003134 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003135 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003136 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3137 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3138 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 return err;
3140 }
3141 return 0;
3142}
3143
3144/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003145static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3146 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003147 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003148{
3149 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003150 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003151
3152 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003153 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3154 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3155 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003156 return err;
3157 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003158 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3160 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161 return err;
3162 return 0;
3163}
3164
3165/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003166static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3167 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003168{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003169 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003170 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171
3172 for (i = 0; i < AUTO_PIN_LAST; i++) {
3173 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003174 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003175 err = new_analog_input(spec, cfg->input_pins[i],
3176 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003177 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003178 if (err < 0)
3179 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003180 imux->items[imux->num_items].label =
3181 auto_pin_cfg_labels[i];
3182 imux->items[imux->num_items].index =
3183 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003184 imux->num_items++;
3185 }
3186 }
3187 return 0;
3188}
3189
Kailang Yangdf694da2005-12-05 19:42:22 +01003190static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3191 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192 int dac_idx)
3193{
3194 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003195 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3196 pin_type);
3197 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3198 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199 /* need the manual connection? */
3200 if (alc880_is_multi_pin(nid)) {
3201 struct alc_spec *spec = codec->spec;
3202 int idx = alc880_multi_pin_idx(nid);
3203 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3204 AC_VERB_SET_CONNECT_SEL,
3205 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3206 }
3207}
3208
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003209static int get_pin_type(int line_out_type)
3210{
3211 if (line_out_type == AUTO_PIN_HP_OUT)
3212 return PIN_HP;
3213 else
3214 return PIN_OUT;
3215}
3216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217static void alc880_auto_init_multi_out(struct hda_codec *codec)
3218{
3219 struct alc_spec *spec = codec->spec;
3220 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003221
3222 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003223 for (i = 0; i < spec->autocfg.line_outs; i++) {
3224 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003225 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3226 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003227 }
3228}
3229
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003230static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003231{
3232 struct alc_spec *spec = codec->spec;
3233 hda_nid_t pin;
3234
Takashi Iwai82bc9552006-03-21 11:24:42 +01003235 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003236 if (pin) /* connect to front */
3237 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003238 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239 if (pin) /* connect to front */
3240 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3241}
3242
3243static void alc880_auto_init_analog_input(struct hda_codec *codec)
3244{
3245 struct alc_spec *spec = codec->spec;
3246 int i;
3247
3248 for (i = 0; i < AUTO_PIN_LAST; i++) {
3249 hda_nid_t nid = spec->autocfg.input_pins[i];
3250 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003251 snd_hda_codec_write(codec, nid, 0,
3252 AC_VERB_SET_PIN_WIDGET_CONTROL,
3253 i <= AUTO_PIN_FRONT_MIC ?
3254 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003255 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003256 snd_hda_codec_write(codec, nid, 0,
3257 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 AMP_OUT_MUTE);
3259 }
3260 }
3261}
3262
3263/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003264/* return 1 if successful, 0 if the proper config is not found,
3265 * or a negative error code
3266 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267static int alc880_parse_auto_config(struct hda_codec *codec)
3268{
3269 struct alc_spec *spec = codec->spec;
3270 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003271 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003273 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3274 alc880_ignore);
3275 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003277 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003279
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003280 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3281 if (err < 0)
3282 return err;
3283 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3284 if (err < 0)
3285 return err;
3286 err = alc880_auto_create_extra_out(spec,
3287 spec->autocfg.speaker_pins[0],
3288 "Speaker");
3289 if (err < 0)
3290 return err;
3291 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3292 "Headphone");
3293 if (err < 0)
3294 return err;
3295 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3296 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297 return err;
3298
3299 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3300
3301 if (spec->autocfg.dig_out_pin)
3302 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3303 if (spec->autocfg.dig_in_pin)
3304 spec->dig_in_nid = ALC880_DIGIN_NID;
3305
3306 if (spec->kctl_alloc)
3307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3308
3309 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3310
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003311 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003312 spec->input_mux = &spec->private_imux;
3313
3314 return 1;
3315}
3316
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003317/* additional initialization for auto-configuration model */
3318static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003319{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003321 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003322 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003323}
3324
3325/*
3326 * OK, here we have finally the patch for ALC880
3327 */
3328
Linus Torvalds1da177e2005-04-16 15:20:36 -07003329static int patch_alc880(struct hda_codec *codec)
3330{
3331 struct alc_spec *spec;
3332 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003333 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003335 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003336 if (spec == NULL)
3337 return -ENOMEM;
3338
3339 codec->spec = spec;
3340
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003341 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3342 alc880_models,
3343 alc880_cfg_tbl);
3344 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003345 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3346 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003347 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348 }
3349
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003350 if (board_config == ALC880_AUTO) {
3351 /* automatic parse from the BIOS config */
3352 err = alc880_parse_auto_config(codec);
3353 if (err < 0) {
3354 alc_free(codec);
3355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003356 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003357 printk(KERN_INFO
3358 "hda_codec: Cannot set up configuration "
3359 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003360 board_config = ALC880_3ST;
3361 }
3362 }
3363
Kailang Yangdf694da2005-12-05 19:42:22 +01003364 if (board_config != ALC880_AUTO)
3365 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003366
3367 spec->stream_name_analog = "ALC880 Analog";
3368 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3369 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3370
3371 spec->stream_name_digital = "ALC880 Digital";
3372 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3373 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3374
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003375 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003376 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003377 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003378 /* get type */
3379 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003380 if (wcap != AC_WID_AUD_IN) {
3381 spec->adc_nids = alc880_adc_nids_alt;
3382 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003383 spec->mixers[spec->num_mixers] =
3384 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 spec->num_mixers++;
3386 } else {
3387 spec->adc_nids = alc880_adc_nids;
3388 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3389 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3390 spec->num_mixers++;
3391 }
3392 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393
3394 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003396 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003397#ifdef CONFIG_SND_HDA_POWER_SAVE
3398 if (!spec->loopback.amplist)
3399 spec->loopback.amplist = alc880_loopbacks;
3400#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401
3402 return 0;
3403}
3404
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003405
Linus Torvalds1da177e2005-04-16 15:20:36 -07003406/*
3407 * ALC260 support
3408 */
3409
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003410static hda_nid_t alc260_dac_nids[1] = {
3411 /* front */
3412 0x02,
3413};
3414
3415static hda_nid_t alc260_adc_nids[1] = {
3416 /* ADC0 */
3417 0x04,
3418};
3419
Kailang Yangdf694da2005-12-05 19:42:22 +01003420static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003421 /* ADC1 */
3422 0x05,
3423};
3424
Kailang Yangdf694da2005-12-05 19:42:22 +01003425static hda_nid_t alc260_hp_adc_nids[2] = {
3426 /* ADC1, 0 */
3427 0x05, 0x04
3428};
3429
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003430/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3431 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3432 */
3433static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003434 /* ADC0, ADC1 */
3435 0x04, 0x05
3436};
3437
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003438#define ALC260_DIGOUT_NID 0x03
3439#define ALC260_DIGIN_NID 0x06
3440
3441static struct hda_input_mux alc260_capture_source = {
3442 .num_items = 4,
3443 .items = {
3444 { "Mic", 0x0 },
3445 { "Front Mic", 0x1 },
3446 { "Line", 0x2 },
3447 { "CD", 0x4 },
3448 },
3449};
3450
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003451/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003452 * headphone jack and the internal CD lines since these are the only pins at
3453 * which audio can appear. For flexibility, also allow the option of
3454 * recording the mixer output on the second ADC (ADC0 doesn't have a
3455 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003456 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003457static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3458 {
3459 .num_items = 3,
3460 .items = {
3461 { "Mic/Line", 0x0 },
3462 { "CD", 0x4 },
3463 { "Headphone", 0x2 },
3464 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003465 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003466 {
3467 .num_items = 4,
3468 .items = {
3469 { "Mic/Line", 0x0 },
3470 { "CD", 0x4 },
3471 { "Headphone", 0x2 },
3472 { "Mixer", 0x5 },
3473 },
3474 },
3475
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003476};
3477
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003478/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3479 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003480 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003481static struct hda_input_mux alc260_acer_capture_sources[2] = {
3482 {
3483 .num_items = 4,
3484 .items = {
3485 { "Mic", 0x0 },
3486 { "Line", 0x2 },
3487 { "CD", 0x4 },
3488 { "Headphone", 0x5 },
3489 },
3490 },
3491 {
3492 .num_items = 5,
3493 .items = {
3494 { "Mic", 0x0 },
3495 { "Line", 0x2 },
3496 { "CD", 0x4 },
3497 { "Headphone", 0x6 },
3498 { "Mixer", 0x5 },
3499 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003500 },
3501};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003502/*
3503 * This is just place-holder, so there's something for alc_build_pcms to look
3504 * at when it calculates the maximum number of channels. ALC260 has no mixer
3505 * element which allows changing the channel mode, so the verb list is
3506 * never used.
3507 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003508static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003509 { 2, NULL },
3510};
3511
Kailang Yangdf694da2005-12-05 19:42:22 +01003512
3513/* Mixer combinations
3514 *
3515 * basic: base_output + input + pc_beep + capture
3516 * HP: base_output + input + capture_alt
3517 * HP_3013: hp_3013 + input + capture
3518 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003519 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003520 */
3521
3522static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003523 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003524 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003525 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3526 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3527 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3528 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3529 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003530};
Kailang Yangdf694da2005-12-05 19:42:22 +01003531
3532static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003533 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3536 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3539 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3540 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003541 { } /* end */
3542};
3543
Kailang Yangdf694da2005-12-05 19:42:22 +01003544static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3545 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3546 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3547 { } /* end */
3548};
3549
3550static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3551 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3558 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003559 { } /* end */
3560};
3561
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003562/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3563 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3564 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003565static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003567 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003568 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003569 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3570 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3571 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3572 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003573 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003574 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3575 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3576 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003577 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003578 { } /* end */
3579};
3580
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003581/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3582 * versions of the ALC260 don't act on requests to enable mic bias from NID
3583 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3584 * datasheet doesn't mention this restriction. At this stage it's not clear
3585 * whether this behaviour is intentional or is a hardware bug in chip
3586 * revisions available in early 2006. Therefore for now allow the
3587 * "Headphone Jack Mode" control to span all choices, but if it turns out
3588 * that the lack of mic bias for this NID is intentional we could change the
3589 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3590 *
3591 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3592 * don't appear to make the mic bias available from the "line" jack, even
3593 * though the NID used for this jack (0x14) can supply it. The theory is
3594 * that perhaps Acer have included blocking capacitors between the ALC260
3595 * and the output jack. If this turns out to be the case for all such
3596 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3597 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003598 *
3599 * The C20x Tablet series have a mono internal speaker which is controlled
3600 * via the chip's Mono sum widget and pin complex, so include the necessary
3601 * controls for such models. On models without a "mono speaker" the control
3602 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003603 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003604static struct snd_kcontrol_new alc260_acer_mixer[] = {
3605 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3606 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003607 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003608 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3609 HDA_OUTPUT),
3610 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3611 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003612 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3613 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3615 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3616 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3617 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3618 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3619 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3620 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3621 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3622 { } /* end */
3623};
3624
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003625/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3626 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3627 */
3628static struct snd_kcontrol_new alc260_will_mixer[] = {
3629 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3630 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3632 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3633 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3634 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3635 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3636 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3637 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3638 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3640 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3641 { } /* end */
3642};
3643
3644/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3645 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3646 */
3647static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3648 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3649 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3651 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3652 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3653 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3654 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3656 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3657 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3658 { } /* end */
3659};
3660
Kailang Yangdf694da2005-12-05 19:42:22 +01003661/* capture mixer elements */
3662static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003663 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3664 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003665 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3666 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003667 {
3668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003669 /* The multiple "Capture Source" controls confuse alsamixer
3670 * So call somewhat different..
3671 * FIXME: the controls appear in the "playback" view!
3672 */
3673 /* .name = "Capture Source", */
3674 .name = "Input Source",
3675 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003676 .info = alc_mux_enum_info,
3677 .get = alc_mux_enum_get,
3678 .put = alc_mux_enum_put,
3679 },
3680 { } /* end */
3681};
3682
Kailang Yangdf694da2005-12-05 19:42:22 +01003683static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3684 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3685 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3686 {
3687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3688 /* The multiple "Capture Source" controls confuse alsamixer
3689 * So call somewhat different..
3690 * FIXME: the controls appear in the "playback" view!
3691 */
3692 /* .name = "Capture Source", */
3693 .name = "Input Source",
3694 .count = 1,
3695 .info = alc_mux_enum_info,
3696 .get = alc_mux_enum_get,
3697 .put = alc_mux_enum_put,
3698 },
3699 { } /* end */
3700};
3701
3702/*
3703 * initialization verbs
3704 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705static struct hda_verb alc260_init_verbs[] = {
3706 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003713 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003717 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003720 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003721 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003722 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003723 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3724 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003725 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003726 /* set connection select to line in (default select for this ADC) */
3727 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 /* mute capture amp left and right */
3729 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3730 /* set connection select to line in (default select for this ADC) */
3731 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003732 /* set vol=0 Line-Out mixer amp left and right */
3733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3734 /* unmute pin widget amp left and right (no gain on this amp) */
3735 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* set vol=0 HP mixer amp left and right */
3737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3738 /* unmute pin widget amp left and right (no gain on this amp) */
3739 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* set vol=0 Mono mixer amp left and right */
3741 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3742 /* unmute pin widget amp left and right (no gain on this amp) */
3743 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3744 /* unmute LINE-2 out pin */
3745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003746 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3747 * Line In 2 = 0x03
3748 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003749 /* mute analog inputs */
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003755 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003756 /* mute Front out path */
3757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3759 /* mute Headphone out path */
3760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3762 /* mute Mono out path */
3763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003765 { }
3766};
3767
Takashi Iwai474167d2006-05-17 17:17:43 +02003768#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003769static struct hda_verb alc260_hp_init_verbs[] = {
3770 /* Headphone and output */
3771 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3772 /* mono output */
3773 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3774 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3775 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3776 /* Mic2 (front panel) pin widget for input and vref at 80% */
3777 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3778 /* Line In pin widget for input */
3779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3780 /* Line-2 pin widget for output */
3781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3782 /* CD pin widget for input */
3783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3784 /* unmute amp left and right */
3785 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3786 /* set connection select to line in (default select for this ADC) */
3787 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3788 /* unmute Line-Out mixer amp left and right (volume = 0) */
3789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3790 /* mute pin widget amp left and right (no gain on this amp) */
3791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3792 /* unmute HP mixer amp left and right (volume = 0) */
3793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3794 /* mute pin widget amp left and right (no gain on this amp) */
3795 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003796 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3797 * Line In 2 = 0x03
3798 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003799 /* mute analog inputs */
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3804 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003805 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3806 /* Unmute Front out path */
3807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3809 /* Unmute Headphone out path */
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3812 /* Unmute Mono out path */
3813 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3815 { }
3816};
Takashi Iwai474167d2006-05-17 17:17:43 +02003817#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003818
3819static struct hda_verb alc260_hp_3013_init_verbs[] = {
3820 /* Line out and output */
3821 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3822 /* mono output */
3823 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3825 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3826 /* Mic2 (front panel) pin widget for input and vref at 80% */
3827 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3828 /* Line In pin widget for input */
3829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3830 /* Headphone pin widget for output */
3831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3832 /* CD pin widget for input */
3833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3834 /* unmute amp left and right */
3835 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3836 /* set connection select to line in (default select for this ADC) */
3837 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3838 /* unmute Line-Out mixer amp left and right (volume = 0) */
3839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3840 /* mute pin widget amp left and right (no gain on this amp) */
3841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3842 /* unmute HP mixer amp left and right (volume = 0) */
3843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3844 /* mute pin widget amp left and right (no gain on this amp) */
3845 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003846 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3847 * Line In 2 = 0x03
3848 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003849 /* mute analog inputs */
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003855 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3856 /* Unmute Front out path */
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3859 /* Unmute Headphone out path */
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3862 /* Unmute Mono out path */
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3865 { }
3866};
3867
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003868/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003869 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3870 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003871 */
3872static struct hda_verb alc260_fujitsu_init_verbs[] = {
3873 /* Disable all GPIOs */
3874 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3875 /* Internal speaker is connected to headphone pin */
3876 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3877 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003879 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3881 /* Ensure all other unused pins are disabled and muted. */
3882 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003884 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003885 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003886 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003887 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003890
Jonathan Woithef7ace402006-02-28 11:46:14 +01003891 /* Disable digital (SPDIF) pins */
3892 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3893 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003894
Jonathan Woithef7ace402006-02-28 11:46:14 +01003895 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3896 * when acting as an output.
3897 */
3898 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3899
3900 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003910
Jonathan Woithef7ace402006-02-28 11:46:14 +01003911 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3912 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3913 /* Unmute Line1 pin widget output buffer since it starts as an output.
3914 * If the pin mode is changed by the user the pin mode control will
3915 * take care of enabling the pin's input/output buffers as needed.
3916 * Therefore there's no need to enable the input buffer at this
3917 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003918 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003920 /* Unmute input buffer of pin widget used for Line-in (no equiv
3921 * mixer ctrl)
3922 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003923 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003924
Jonathan Woithef7ace402006-02-28 11:46:14 +01003925 /* Mute capture amp left and right */
3926 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3927 /* Set ADC connection select to match default mixer setting - line
3928 * in (on mic1 pin)
3929 */
3930 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003931
Jonathan Woithef7ace402006-02-28 11:46:14 +01003932 /* Do the same for the second ADC: mute capture input amp and
3933 * set ADC connection to line in (on mic1 pin)
3934 */
3935 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3936 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003937
Jonathan Woithef7ace402006-02-28 11:46:14 +01003938 /* Mute all inputs to mixer widget (even unconnected ones) */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003947
3948 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003949};
3950
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003951/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3952 * similar laptops (adapted from Fujitsu init verbs).
3953 */
3954static struct hda_verb alc260_acer_init_verbs[] = {
3955 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3956 * the headphone jack. Turn this on and rely on the standard mute
3957 * methods whenever the user wants to turn these outputs off.
3958 */
3959 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3960 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3961 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3962 /* Internal speaker/Headphone jack is connected to Line-out pin */
3963 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3964 /* Internal microphone/Mic jack is connected to Mic1 pin */
3965 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3966 /* Line In jack is connected to Line1 pin */
3967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003968 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3969 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003970 /* Ensure all other unused pins are disabled and muted. */
3971 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003973 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3974 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3977 /* Disable digital (SPDIF) pins */
3978 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3979 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3980
3981 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3982 * bus when acting as outputs.
3983 */
3984 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3985 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3986
3987 /* Start with output sum widgets muted and their output gains at min */
3988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3994 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3997
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998 /* Unmute Line-out pin widget amp left and right
3999 * (no equiv mixer ctrl)
4000 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004001 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004002 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4003 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004004 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4005 * inputs. If the pin mode is changed by the user the pin mode control
4006 * will take care of enabling the pin's input/output buffers as needed.
4007 * Therefore there's no need to enable the input buffer at this
4008 * stage.
4009 */
4010 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012
4013 /* Mute capture amp left and right */
4014 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4015 /* Set ADC connection select to match default mixer setting - mic
4016 * (on mic1 pin)
4017 */
4018 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4019
4020 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004021 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004022 */
4023 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004024 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004025
4026 /* Mute all inputs to mixer widget (even unconnected ones) */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4035
4036 { }
4037};
4038
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004039static struct hda_verb alc260_will_verbs[] = {
4040 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4041 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4042 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4044 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4045 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4046 {}
4047};
4048
4049static struct hda_verb alc260_replacer_672v_verbs[] = {
4050 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4051 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4052 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4053
4054 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4055 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4057
4058 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4059 {}
4060};
4061
4062/* toggle speaker-output according to the hp-jack state */
4063static void alc260_replacer_672v_automute(struct hda_codec *codec)
4064{
4065 unsigned int present;
4066
4067 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4068 present = snd_hda_codec_read(codec, 0x0f, 0,
4069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4070 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004071 snd_hda_codec_write_cache(codec, 0x01, 0,
4072 AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write_cache(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL,
4075 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004076 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004077 snd_hda_codec_write_cache(codec, 0x01, 0,
4078 AC_VERB_SET_GPIO_DATA, 0);
4079 snd_hda_codec_write_cache(codec, 0x0f, 0,
4080 AC_VERB_SET_PIN_WIDGET_CONTROL,
4081 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004082 }
4083}
4084
4085static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4086 unsigned int res)
4087{
4088 if ((res >> 26) == ALC880_HP_EVENT)
4089 alc260_replacer_672v_automute(codec);
4090}
4091
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004092/* Test configuration for debugging, modelled after the ALC880 test
4093 * configuration.
4094 */
4095#ifdef CONFIG_SND_DEBUG
4096static hda_nid_t alc260_test_dac_nids[1] = {
4097 0x02,
4098};
4099static hda_nid_t alc260_test_adc_nids[2] = {
4100 0x04, 0x05,
4101};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004102/* For testing the ALC260, each input MUX needs its own definition since
4103 * the signal assignments are different. This assumes that the first ADC
4104 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004105 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004106static struct hda_input_mux alc260_test_capture_sources[2] = {
4107 {
4108 .num_items = 7,
4109 .items = {
4110 { "MIC1 pin", 0x0 },
4111 { "MIC2 pin", 0x1 },
4112 { "LINE1 pin", 0x2 },
4113 { "LINE2 pin", 0x3 },
4114 { "CD pin", 0x4 },
4115 { "LINE-OUT pin", 0x5 },
4116 { "HP-OUT pin", 0x6 },
4117 },
4118 },
4119 {
4120 .num_items = 8,
4121 .items = {
4122 { "MIC1 pin", 0x0 },
4123 { "MIC2 pin", 0x1 },
4124 { "LINE1 pin", 0x2 },
4125 { "LINE2 pin", 0x3 },
4126 { "CD pin", 0x4 },
4127 { "Mixer", 0x5 },
4128 { "LINE-OUT pin", 0x6 },
4129 { "HP-OUT pin", 0x7 },
4130 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004131 },
4132};
4133static struct snd_kcontrol_new alc260_test_mixer[] = {
4134 /* Output driver widgets */
4135 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4137 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4138 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4139 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4140 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4141
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004142 /* Modes for retasking pin widgets
4143 * Note: the ALC260 doesn't seem to act on requests to enable mic
4144 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4145 * mention this restriction. At this stage it's not clear whether
4146 * this behaviour is intentional or is a hardware bug in chip
4147 * revisions available at least up until early 2006. Therefore for
4148 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4149 * choices, but if it turns out that the lack of mic bias for these
4150 * NIDs is intentional we could change their modes from
4151 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4152 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004153 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4156 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4157 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4158 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4159
4160 /* Loopback mixer controls */
4161 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4162 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4163 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4164 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4165 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4166 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4167 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4168 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4169 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4170 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4171 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4172 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4173 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4174 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4175 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4176 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004177
4178 /* Controls for GPIO pins, assuming they are configured as outputs */
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4180 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4181 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4182 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4183
Jonathan Woithe92621f12006-02-28 11:47:47 +01004184 /* Switches to allow the digital IO pins to be enabled. The datasheet
4185 * is ambigious as to which NID is which; testing on laptops which
4186 * make this output available should provide clarification.
4187 */
4188 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4189 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4190
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004191 { } /* end */
4192};
4193static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004194 /* Enable all GPIOs as outputs with an initial value of 0 */
4195 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4196 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4197 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4198
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004199 /* Enable retasking pins as output, initially without power amp */
4200 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4205 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4206
Jonathan Woithe92621f12006-02-28 11:47:47 +01004207 /* Disable digital (SPDIF) pins initially, but users can enable
4208 * them via a mixer switch. In the case of SPDIF-out, this initverb
4209 * payload also sets the generation to 0, output to be in "consumer"
4210 * PCM format, copyright asserted, no pre-emphasis and no validity
4211 * control.
4212 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004213 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4214 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4215
Jonathan Woithef7ace402006-02-28 11:46:14 +01004216 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004217 * OUT1 sum bus when acting as an output.
4218 */
4219 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4220 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4221 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4222 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4223
4224 /* Start with output sum widgets muted and their output gains at min */
4225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4230 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4232 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4233 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4234
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004235 /* Unmute retasking pin widget output buffers since the default
4236 * state appears to be output. As the pin mode is changed by the
4237 * user the pin mode control will take care of enabling the pin's
4238 * input/output buffers as needed.
4239 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004240 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 /* Also unmute the mono-out pin widget */
4247 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4248
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004249 /* Mute capture amp left and right */
4250 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004251 /* Set ADC connection select to match default mixer setting (mic1
4252 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004253 */
4254 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4255
4256 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004257 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004258 */
4259 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4260 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4261
4262 /* Mute all inputs to mixer widget (even unconnected ones) */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4271
4272 { }
4273};
4274#endif
4275
Linus Torvalds1da177e2005-04-16 15:20:36 -07004276static struct hda_pcm_stream alc260_pcm_analog_playback = {
4277 .substreams = 1,
4278 .channels_min = 2,
4279 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280};
4281
4282static struct hda_pcm_stream alc260_pcm_analog_capture = {
4283 .substreams = 1,
4284 .channels_min = 2,
4285 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004286};
4287
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004288#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4289#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4290
Kailang Yangdf694da2005-12-05 19:42:22 +01004291/*
4292 * for BIOS auto-configuration
4293 */
4294
4295static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4296 const char *pfx)
4297{
4298 hda_nid_t nid_vol;
4299 unsigned long vol_val, sw_val;
4300 char name[32];
4301 int err;
4302
4303 if (nid >= 0x0f && nid < 0x11) {
4304 nid_vol = nid - 0x7;
4305 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4306 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4307 } else if (nid == 0x11) {
4308 nid_vol = nid - 0x7;
4309 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4310 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4311 } else if (nid >= 0x12 && nid <= 0x15) {
4312 nid_vol = 0x08;
4313 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4314 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4315 } else
4316 return 0; /* N/A */
4317
4318 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004319 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4320 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004321 return err;
4322 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4324 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004325 return err;
4326 return 1;
4327}
4328
4329/* add playback controls from the parsed DAC table */
4330static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4331 const struct auto_pin_cfg *cfg)
4332{
4333 hda_nid_t nid;
4334 int err;
4335
4336 spec->multiout.num_dacs = 1;
4337 spec->multiout.dac_nids = spec->private_dac_nids;
4338 spec->multiout.dac_nids[0] = 0x02;
4339
4340 nid = cfg->line_out_pins[0];
4341 if (nid) {
4342 err = alc260_add_playback_controls(spec, nid, "Front");
4343 if (err < 0)
4344 return err;
4345 }
4346
Takashi Iwai82bc9552006-03-21 11:24:42 +01004347 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 if (nid) {
4349 err = alc260_add_playback_controls(spec, nid, "Speaker");
4350 if (err < 0)
4351 return err;
4352 }
4353
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004354 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004355 if (nid) {
4356 err = alc260_add_playback_controls(spec, nid, "Headphone");
4357 if (err < 0)
4358 return err;
4359 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004360 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004361}
4362
4363/* create playback/capture controls for input pins */
4364static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4365 const struct auto_pin_cfg *cfg)
4366{
Kailang Yangdf694da2005-12-05 19:42:22 +01004367 struct hda_input_mux *imux = &spec->private_imux;
4368 int i, err, idx;
4369
4370 for (i = 0; i < AUTO_PIN_LAST; i++) {
4371 if (cfg->input_pins[i] >= 0x12) {
4372 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004373 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004374 auto_pin_cfg_labels[i], idx,
4375 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004376 if (err < 0)
4377 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 imux->items[imux->num_items].label =
4379 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004380 imux->items[imux->num_items].index = idx;
4381 imux->num_items++;
4382 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004384 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004385 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 auto_pin_cfg_labels[i], idx,
4387 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004388 if (err < 0)
4389 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 imux->items[imux->num_items].label =
4391 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004392 imux->items[imux->num_items].index = idx;
4393 imux->num_items++;
4394 }
4395 }
4396 return 0;
4397}
4398
4399static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4400 hda_nid_t nid, int pin_type,
4401 int sel_idx)
4402{
4403 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004404 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4405 pin_type);
4406 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4407 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004408 /* need the manual connection? */
4409 if (nid >= 0x12) {
4410 int idx = nid - 0x12;
4411 snd_hda_codec_write(codec, idx + 0x0b, 0,
4412 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004413 }
4414}
4415
4416static void alc260_auto_init_multi_out(struct hda_codec *codec)
4417{
4418 struct alc_spec *spec = codec->spec;
4419 hda_nid_t nid;
4420
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004421 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004422 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004423 if (nid) {
4424 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4425 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4426 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004427
Takashi Iwai82bc9552006-03-21 11:24:42 +01004428 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004429 if (nid)
4430 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4431
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004432 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004433 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004434 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004435}
Kailang Yangdf694da2005-12-05 19:42:22 +01004436
4437#define ALC260_PIN_CD_NID 0x16
4438static void alc260_auto_init_analog_input(struct hda_codec *codec)
4439{
4440 struct alc_spec *spec = codec->spec;
4441 int i;
4442
4443 for (i = 0; i < AUTO_PIN_LAST; i++) {
4444 hda_nid_t nid = spec->autocfg.input_pins[i];
4445 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004446 snd_hda_codec_write(codec, nid, 0,
4447 AC_VERB_SET_PIN_WIDGET_CONTROL,
4448 i <= AUTO_PIN_FRONT_MIC ?
4449 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004450 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 snd_hda_codec_write(codec, nid, 0,
4452 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004453 AMP_OUT_MUTE);
4454 }
4455 }
4456}
4457
4458/*
4459 * generic initialization of ADC, input mixers and output mixers
4460 */
4461static struct hda_verb alc260_volume_init_verbs[] = {
4462 /*
4463 * Unmute ADC0-1 and set the default input to mic-in
4464 */
4465 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4466 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4468 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4469
4470 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4471 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 * Note: PASD motherboards uses the Line In 2 as the input for
4473 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004474 */
4475 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004476 /* mute analog inputs */
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004482
4483 /*
4484 * Set up output mixers (0x08 - 0x0a)
4485 */
4486 /* set vol=0 to output mixers */
4487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4490 /* set up input amps for analog loopback */
4491 /* Amp Indices: DAC = 0, mixer = 1 */
4492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4496 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4497 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4498
4499 { }
4500};
4501
4502static int alc260_parse_auto_config(struct hda_codec *codec)
4503{
4504 struct alc_spec *spec = codec->spec;
4505 unsigned int wcap;
4506 int err;
4507 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4508
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004509 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4510 alc260_ignore);
4511 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004512 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004513 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4514 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004515 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004516 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004517 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004518 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4519 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004520 return err;
4521
4522 spec->multiout.max_channels = 2;
4523
4524 if (spec->autocfg.dig_out_pin)
4525 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4526 if (spec->kctl_alloc)
4527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4528
4529 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4530
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004531 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 spec->input_mux = &spec->private_imux;
4533
4534 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004535 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004536 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4537 if (wcap != AC_WID_AUD_IN) {
4538 spec->adc_nids = alc260_adc_nids_alt;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4540 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004541 } else {
4542 spec->adc_nids = alc260_adc_nids;
4543 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4544 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004545 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004546 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004547
4548 return 1;
4549}
4550
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004551/* additional initialization for auto-configuration model */
4552static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004553{
Kailang Yangdf694da2005-12-05 19:42:22 +01004554 alc260_auto_init_multi_out(codec);
4555 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004556}
4557
Takashi Iwaicb53c622007-08-10 17:21:45 +02004558#ifdef CONFIG_SND_HDA_POWER_SAVE
4559static struct hda_amp_list alc260_loopbacks[] = {
4560 { 0x07, HDA_INPUT, 0 },
4561 { 0x07, HDA_INPUT, 1 },
4562 { 0x07, HDA_INPUT, 2 },
4563 { 0x07, HDA_INPUT, 3 },
4564 { 0x07, HDA_INPUT, 4 },
4565 { } /* end */
4566};
4567#endif
4568
Kailang Yangdf694da2005-12-05 19:42:22 +01004569/*
4570 * ALC260 configurations
4571 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004572static const char *alc260_models[ALC260_MODEL_LAST] = {
4573 [ALC260_BASIC] = "basic",
4574 [ALC260_HP] = "hp",
4575 [ALC260_HP_3013] = "hp-3013",
4576 [ALC260_FUJITSU_S702X] = "fujitsu",
4577 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004578 [ALC260_WILL] = "will",
4579 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004580#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004581 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004582#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 [ALC260_AUTO] = "auto",
4584};
4585
4586static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004587 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004588 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004589 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004590 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004591 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4592 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4593 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4594 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4595 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4596 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4597 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4598 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4600 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4601 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4602 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004603 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4604 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004605 {}
4606};
4607
Kailang Yangdf694da2005-12-05 19:42:22 +01004608static struct alc_config_preset alc260_presets[] = {
4609 [ALC260_BASIC] = {
4610 .mixers = { alc260_base_output_mixer,
4611 alc260_input_mixer,
4612 alc260_pc_beep_mixer,
4613 alc260_capture_mixer },
4614 .init_verbs = { alc260_init_verbs },
4615 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4616 .dac_nids = alc260_dac_nids,
4617 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4618 .adc_nids = alc260_adc_nids,
4619 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4620 .channel_mode = alc260_modes,
4621 .input_mux = &alc260_capture_source,
4622 },
4623 [ALC260_HP] = {
4624 .mixers = { alc260_base_output_mixer,
4625 alc260_input_mixer,
4626 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004627 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004628 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4629 .dac_nids = alc260_dac_nids,
4630 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4631 .adc_nids = alc260_hp_adc_nids,
4632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4633 .channel_mode = alc260_modes,
4634 .input_mux = &alc260_capture_source,
4635 },
4636 [ALC260_HP_3013] = {
4637 .mixers = { alc260_hp_3013_mixer,
4638 alc260_input_mixer,
4639 alc260_capture_alt_mixer },
4640 .init_verbs = { alc260_hp_3013_init_verbs },
4641 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4642 .dac_nids = alc260_dac_nids,
4643 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4644 .adc_nids = alc260_hp_adc_nids,
4645 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4646 .channel_mode = alc260_modes,
4647 .input_mux = &alc260_capture_source,
4648 },
4649 [ALC260_FUJITSU_S702X] = {
4650 .mixers = { alc260_fujitsu_mixer,
4651 alc260_capture_mixer },
4652 .init_verbs = { alc260_fujitsu_init_verbs },
4653 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4654 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004655 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4656 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4658 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004659 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4660 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004661 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004662 [ALC260_ACER] = {
4663 .mixers = { alc260_acer_mixer,
4664 alc260_capture_mixer },
4665 .init_verbs = { alc260_acer_init_verbs },
4666 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4667 .dac_nids = alc260_dac_nids,
4668 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4669 .adc_nids = alc260_dual_adc_nids,
4670 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4671 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004672 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4673 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004674 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004675 [ALC260_WILL] = {
4676 .mixers = { alc260_will_mixer,
4677 alc260_capture_mixer },
4678 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4679 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4680 .dac_nids = alc260_dac_nids,
4681 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4682 .adc_nids = alc260_adc_nids,
4683 .dig_out_nid = ALC260_DIGOUT_NID,
4684 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4685 .channel_mode = alc260_modes,
4686 .input_mux = &alc260_capture_source,
4687 },
4688 [ALC260_REPLACER_672V] = {
4689 .mixers = { alc260_replacer_672v_mixer,
4690 alc260_capture_mixer },
4691 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4692 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4693 .dac_nids = alc260_dac_nids,
4694 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4695 .adc_nids = alc260_adc_nids,
4696 .dig_out_nid = ALC260_DIGOUT_NID,
4697 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4698 .channel_mode = alc260_modes,
4699 .input_mux = &alc260_capture_source,
4700 .unsol_event = alc260_replacer_672v_unsol_event,
4701 .init_hook = alc260_replacer_672v_automute,
4702 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004703#ifdef CONFIG_SND_DEBUG
4704 [ALC260_TEST] = {
4705 .mixers = { alc260_test_mixer,
4706 alc260_capture_mixer },
4707 .init_verbs = { alc260_test_init_verbs },
4708 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4709 .dac_nids = alc260_test_dac_nids,
4710 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4711 .adc_nids = alc260_test_adc_nids,
4712 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4713 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004714 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4715 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004716 },
4717#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004718};
4719
Linus Torvalds1da177e2005-04-16 15:20:36 -07004720static int patch_alc260(struct hda_codec *codec)
4721{
4722 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004723 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004724
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004725 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004726 if (spec == NULL)
4727 return -ENOMEM;
4728
4729 codec->spec = spec;
4730
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004731 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4732 alc260_models,
4733 alc260_cfg_tbl);
4734 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004735 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4736 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004737 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004738 }
4739
Kailang Yangdf694da2005-12-05 19:42:22 +01004740 if (board_config == ALC260_AUTO) {
4741 /* automatic parse from the BIOS config */
4742 err = alc260_parse_auto_config(codec);
4743 if (err < 0) {
4744 alc_free(codec);
4745 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004747 printk(KERN_INFO
4748 "hda_codec: Cannot set up configuration "
4749 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004750 board_config = ALC260_BASIC;
4751 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004752 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004753
Kailang Yangdf694da2005-12-05 19:42:22 +01004754 if (board_config != ALC260_AUTO)
4755 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004756
4757 spec->stream_name_analog = "ALC260 Analog";
4758 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4759 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4760
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004761 spec->stream_name_digital = "ALC260 Digital";
4762 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4763 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4764
Linus Torvalds1da177e2005-04-16 15:20:36 -07004765 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004766 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004767 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004768#ifdef CONFIG_SND_HDA_POWER_SAVE
4769 if (!spec->loopback.amplist)
4770 spec->loopback.amplist = alc260_loopbacks;
4771#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004772
4773 return 0;
4774}
4775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004776
Linus Torvalds1da177e2005-04-16 15:20:36 -07004777/*
4778 * ALC882 support
4779 *
4780 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4781 * configuration. Each pin widget can choose any input DACs and a mixer.
4782 * Each ADC is connected from a mixer of all inputs. This makes possible
4783 * 6-channel independent captures.
4784 *
4785 * In addition, an independent DAC for the multi-playback (not used in this
4786 * driver yet).
4787 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004788#define ALC882_DIGOUT_NID 0x06
4789#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004790
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004791static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004792 { 8, NULL }
4793};
4794
4795static hda_nid_t alc882_dac_nids[4] = {
4796 /* front, rear, clfe, rear_surr */
4797 0x02, 0x03, 0x04, 0x05
4798};
4799
Kailang Yangdf694da2005-12-05 19:42:22 +01004800/* identical with ALC880 */
4801#define alc882_adc_nids alc880_adc_nids
4802#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004803
4804/* input MUX */
4805/* FIXME: should be a matrix-type input source selection */
4806
4807static struct hda_input_mux alc882_capture_source = {
4808 .num_items = 4,
4809 .items = {
4810 { "Mic", 0x0 },
4811 { "Front Mic", 0x1 },
4812 { "Line", 0x2 },
4813 { "CD", 0x4 },
4814 },
4815};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004816#define alc882_mux_enum_info alc_mux_enum_info
4817#define alc882_mux_enum_get alc_mux_enum_get
4818
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004819static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4820 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004821{
4822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4823 struct alc_spec *spec = codec->spec;
4824 const struct hda_input_mux *imux = spec->input_mux;
4825 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4826 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4827 hda_nid_t nid = capture_mixers[adc_idx];
4828 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4829 unsigned int i, idx;
4830
4831 idx = ucontrol->value.enumerated.item[0];
4832 if (idx >= imux->num_items)
4833 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004834 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004835 return 0;
4836 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02004837 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4838 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004839 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02004840 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841 }
4842 *cur_val = idx;
4843 return 1;
4844}
4845
Kailang Yangdf694da2005-12-05 19:42:22 +01004846/*
Kailang Yang272a5272007-05-14 11:00:38 +02004847 * 2ch mode
4848 */
4849static struct hda_verb alc882_3ST_ch2_init[] = {
4850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4854 { } /* end */
4855};
4856
4857/*
4858 * 6ch mode
4859 */
4860static struct hda_verb alc882_3ST_ch6_init[] = {
4861 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4862 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4863 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4866 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4867 { } /* end */
4868};
4869
4870static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4871 { 2, alc882_3ST_ch2_init },
4872 { 6, alc882_3ST_ch6_init },
4873};
4874
4875/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004876 * 6ch mode
4877 */
4878static struct hda_verb alc882_sixstack_ch6_init[] = {
4879 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4880 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4881 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4883 { } /* end */
4884};
4885
4886/*
4887 * 8ch mode
4888 */
4889static struct hda_verb alc882_sixstack_ch8_init[] = {
4890 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4891 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4892 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4893 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4894 { } /* end */
4895};
4896
4897static struct hda_channel_mode alc882_sixstack_modes[2] = {
4898 { 6, alc882_sixstack_ch6_init },
4899 { 8, alc882_sixstack_ch8_init },
4900};
4901
Takashi Iwai87350ad2007-08-16 18:19:38 +02004902/*
4903 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
4904 */
4905
4906/*
4907 * 2ch mode
4908 */
4909static struct hda_verb alc885_mbp_ch2_init[] = {
4910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4911 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4912 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4913 { } /* end */
4914};
4915
4916/*
4917 * 6ch mode
4918 */
4919static struct hda_verb alc885_mbp_ch6_init[] = {
4920 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4921 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4923 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4924 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4925 { } /* end */
4926};
4927
4928static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
4929 { 2, alc885_mbp_ch2_init },
4930 { 6, alc885_mbp_ch6_init },
4931};
4932
4933
Linus Torvalds1da177e2005-04-16 15:20:36 -07004934/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4935 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4936 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004937static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004946 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004947 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4950 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004957 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4959 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4960 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004961 { } /* end */
4962};
4963
Takashi Iwai87350ad2007-08-16 18:19:38 +02004964static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
4965 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
4966 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
4967 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
4968 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
4969 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
4971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
4972 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
4973 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
4974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
4975 { } /* end */
4976};
Kailang Yangbdd148a2007-05-08 15:19:08 +02004977static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4978 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4979 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4987 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4988 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4989 { } /* end */
4990};
4991
Kailang Yang272a5272007-05-14 11:00:38 +02004992static struct snd_kcontrol_new alc882_targa_mixer[] = {
4993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4994 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005003 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5004 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005005 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005006 { } /* end */
5007};
5008
5009/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5010 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5011 */
5012static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5014 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5016 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5017 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5018 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5021 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5022 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005025 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005026 { } /* end */
5027};
5028
Takashi Iwai914759b2007-09-06 14:52:04 +02005029static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5033 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5034 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5035 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5036 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5040 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5041 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5042 { } /* end */
5043};
5044
Kailang Yangdf694da2005-12-05 19:42:22 +01005045static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5046 {
5047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5048 .name = "Channel Mode",
5049 .info = alc_ch_mode_info,
5050 .get = alc_ch_mode_get,
5051 .put = alc_ch_mode_put,
5052 },
5053 { } /* end */
5054};
5055
Linus Torvalds1da177e2005-04-16 15:20:36 -07005056static struct hda_verb alc882_init_verbs[] = {
5057 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005061 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005065 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5067 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5068 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005069 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5071 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5072 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005075 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005076 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005077 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005078 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005085 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005086 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005089 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005090 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5093 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5096 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5099 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005103 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005105
5106 /* FIXME: use matrix-type input source selection */
5107 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5108 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5110 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005113 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005118 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5123 /* ADC1: mute amp left and right */
5124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005125 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005126 /* ADC2: mute amp left and right */
5127 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005128 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005129 /* ADC3: mute amp left and right */
5130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005131 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005132
5133 { }
5134};
5135
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005136static struct hda_verb alc882_eapd_verbs[] = {
5137 /* change to EAPD mode */
5138 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005139 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005140 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005141};
5142
Tobin Davis9102cd12006-12-15 10:02:12 +01005143/* Mac Pro test */
5144static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5150 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5151 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5152 { } /* end */
5153};
5154
5155static struct hda_verb alc882_macpro_init_verbs[] = {
5156 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5160 /* Front Pin: output 0 (0x0c) */
5161 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5163 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5164 /* Front Mic pin: input vref at 80% */
5165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5167 /* Speaker: output */
5168 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5169 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5170 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5171 /* Headphone output (output 0 - 0x0c) */
5172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5174 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5175
5176 /* FIXME: use matrix-type input source selection */
5177 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5178 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5183 /* Input mixer2 */
5184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5188 /* Input mixer3 */
5189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5193 /* ADC1: mute amp left and right */
5194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5196 /* ADC2: mute amp left and right */
5197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5199 /* ADC3: mute amp left and right */
5200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5202
5203 { }
5204};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005205
Takashi Iwai87350ad2007-08-16 18:19:38 +02005206/* Macbook Pro rev3 */
5207static struct hda_verb alc885_mbp3_init_verbs[] = {
5208 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5212 /* Rear mixer */
5213 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5216 /* Front Pin: output 0 (0x0c) */
5217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5219 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5220 /* HP Pin: output 0 (0x0d) */
5221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5223 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5224 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5225 /* Mic (rear) pin: input vref at 80% */
5226 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5228 /* Front Mic pin: input vref at 80% */
5229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5231 /* Line In pin: use output 1 when in LineOut mode */
5232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5234 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5235
5236 /* FIXME: use matrix-type input source selection */
5237 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5238 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5243 /* Input mixer2 */
5244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5248 /* Input mixer3 */
5249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5253 /* ADC1: mute amp left and right */
5254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5255 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5256 /* ADC2: mute amp left and right */
5257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5258 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5259 /* ADC3: mute amp left and right */
5260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5261 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5262
5263 { }
5264};
5265
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005266/* iMac 24 mixer. */
5267static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5268 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5269 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5270 { } /* end */
5271};
5272
5273/* iMac 24 init verbs. */
5274static struct hda_verb alc885_imac24_init_verbs[] = {
5275 /* Internal speakers: output 0 (0x0c) */
5276 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5277 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5278 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5279 /* Internal speakers: output 0 (0x0c) */
5280 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5281 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5282 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5283 /* Headphone: output 0 (0x0c) */
5284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5285 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5286 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5287 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5288 /* Front Mic: input vref at 80% */
5289 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5291 { }
5292};
5293
5294/* Toggle speaker-output according to the hp-jack state */
5295static void alc885_imac24_automute(struct hda_codec *codec)
5296{
5297 unsigned int present;
5298
5299 present = snd_hda_codec_read(codec, 0x14, 0,
5300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005301 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5302 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5303 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5304 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005305}
5306
5307/* Processes unsolicited events. */
5308static void alc885_imac24_unsol_event(struct hda_codec *codec,
5309 unsigned int res)
5310{
5311 /* Headphone insertion or removal. */
5312 if ((res >> 26) == ALC880_HP_EVENT)
5313 alc885_imac24_automute(codec);
5314}
5315
Takashi Iwai87350ad2007-08-16 18:19:38 +02005316static void alc885_mbp3_automute(struct hda_codec *codec)
5317{
5318 unsigned int present;
5319
5320 present = snd_hda_codec_read(codec, 0x15, 0,
5321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5322 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5323 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5324 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5325 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5326
5327}
5328static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5329 unsigned int res)
5330{
5331 /* Headphone insertion or removal. */
5332 if ((res >> 26) == ALC880_HP_EVENT)
5333 alc885_mbp3_automute(codec);
5334}
5335
5336
Kailang Yang272a5272007-05-14 11:00:38 +02005337static struct hda_verb alc882_targa_verbs[] = {
5338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5340
5341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5343
5344 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5347
5348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5349 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5350 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5351 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5352 { } /* end */
5353};
5354
5355/* toggle speaker-output according to the hp-jack state */
5356static void alc882_targa_automute(struct hda_codec *codec)
5357{
5358 unsigned int present;
5359
5360 present = snd_hda_codec_read(codec, 0x14, 0,
5361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005362 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5363 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005364 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5365 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005366}
5367
5368static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5369{
5370 /* Looks like the unsol event is incompatible with the standard
5371 * definition. 4bit tag is placed at 26 bit!
5372 */
5373 if (((res >> 26) == ALC880_HP_EVENT)) {
5374 alc882_targa_automute(codec);
5375 }
5376}
5377
5378static struct hda_verb alc882_asus_a7j_verbs[] = {
5379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5381
5382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5383 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5384 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5385
5386 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5388 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5389
5390 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5391 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5392 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5393 { } /* end */
5394};
5395
Takashi Iwai914759b2007-09-06 14:52:04 +02005396static struct hda_verb alc882_asus_a7m_verbs[] = {
5397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5399
5400 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5402 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5403
5404 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5406 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5407
5408 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5409 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5410 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5411 { } /* end */
5412};
5413
Tobin Davis9102cd12006-12-15 10:02:12 +01005414static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5415{
5416 unsigned int gpiostate, gpiomask, gpiodir;
5417
5418 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5419 AC_VERB_GET_GPIO_DATA, 0);
5420
5421 if (!muted)
5422 gpiostate |= (1 << pin);
5423 else
5424 gpiostate &= ~(1 << pin);
5425
5426 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5427 AC_VERB_GET_GPIO_MASK, 0);
5428 gpiomask |= (1 << pin);
5429
5430 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5431 AC_VERB_GET_GPIO_DIRECTION, 0);
5432 gpiodir |= (1 << pin);
5433
5434
5435 snd_hda_codec_write(codec, codec->afg, 0,
5436 AC_VERB_SET_GPIO_MASK, gpiomask);
5437 snd_hda_codec_write(codec, codec->afg, 0,
5438 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5439
5440 msleep(1);
5441
5442 snd_hda_codec_write(codec, codec->afg, 0,
5443 AC_VERB_SET_GPIO_DATA, gpiostate);
5444}
5445
Takashi Iwai7debbe52007-08-16 15:01:03 +02005446/* set up GPIO at initialization */
5447static void alc885_macpro_init_hook(struct hda_codec *codec)
5448{
5449 alc882_gpio_mute(codec, 0, 0);
5450 alc882_gpio_mute(codec, 1, 0);
5451}
5452
5453/* set up GPIO and update auto-muting at initialization */
5454static void alc885_imac24_init_hook(struct hda_codec *codec)
5455{
5456 alc885_macpro_init_hook(codec);
5457 alc885_imac24_automute(codec);
5458}
5459
Kailang Yangdf694da2005-12-05 19:42:22 +01005460/*
5461 * generic initialization of ADC, input mixers and output mixers
5462 */
5463static struct hda_verb alc882_auto_init_verbs[] = {
5464 /*
5465 * Unmute ADC0-2 and set the default input to mic-in
5466 */
5467 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5469 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5471 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5473
Takashi Iwaicb53c622007-08-10 17:21:45 +02005474 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005475 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005476 * Note: PASD motherboards uses the Line In 2 as the input for
5477 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005478 */
5479 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005485
5486 /*
5487 * Set up output mixers (0x0c - 0x0f)
5488 */
5489 /* set vol=0 to output mixers */
5490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 /* set up input amps for analog loopback */
5495 /* Amp Indices: DAC = 0, mixer = 1 */
5496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5504 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5505 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5506
5507 /* FIXME: use matrix-type input source selection */
5508 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5509 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5511 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5514 /* Input mixer2 */
5515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5519 /* Input mixer3 */
5520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5524
5525 { }
5526};
5527
5528/* capture mixer elements */
5529static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5530 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5531 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5532 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5533 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5534 {
5535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5536 /* The multiple "Capture Source" controls confuse alsamixer
5537 * So call somewhat different..
5538 * FIXME: the controls appear in the "playback" view!
5539 */
5540 /* .name = "Capture Source", */
5541 .name = "Input Source",
5542 .count = 2,
5543 .info = alc882_mux_enum_info,
5544 .get = alc882_mux_enum_get,
5545 .put = alc882_mux_enum_put,
5546 },
5547 { } /* end */
5548};
5549
5550static struct snd_kcontrol_new alc882_capture_mixer[] = {
5551 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5552 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5553 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5554 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5555 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5556 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5557 {
5558 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5559 /* The multiple "Capture Source" controls confuse alsamixer
5560 * So call somewhat different..
5561 * FIXME: the controls appear in the "playback" view!
5562 */
5563 /* .name = "Capture Source", */
5564 .name = "Input Source",
5565 .count = 3,
5566 .info = alc882_mux_enum_info,
5567 .get = alc882_mux_enum_get,
5568 .put = alc882_mux_enum_put,
5569 },
5570 { } /* end */
5571};
5572
Takashi Iwaicb53c622007-08-10 17:21:45 +02005573#ifdef CONFIG_SND_HDA_POWER_SAVE
5574#define alc882_loopbacks alc880_loopbacks
5575#endif
5576
Kailang Yangdf694da2005-12-05 19:42:22 +01005577/* pcm configuration: identiacal with ALC880 */
5578#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5579#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5580#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5581#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5582
5583/*
5584 * configuration and preset
5585 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005586static const char *alc882_models[ALC882_MODEL_LAST] = {
5587 [ALC882_3ST_DIG] = "3stack-dig",
5588 [ALC882_6ST_DIG] = "6stack-dig",
5589 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005590 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02005591 [ALC882_TARGA] = "targa",
5592 [ALC882_ASUS_A7J] = "asus-a7j",
5593 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01005594 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005595 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005596 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005597 [ALC882_AUTO] = "auto",
5598};
5599
5600static struct snd_pci_quirk alc882_cfg_tbl[] = {
5601 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5602 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5603 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005604 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005605 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005606 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02005607 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02005608 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005609 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005610 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005611 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005612 {}
5613};
5614
5615static struct alc_config_preset alc882_presets[] = {
5616 [ALC882_3ST_DIG] = {
5617 .mixers = { alc882_base_mixer },
5618 .init_verbs = { alc882_init_verbs },
5619 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5620 .dac_nids = alc882_dac_nids,
5621 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005622 .dig_in_nid = ALC882_DIGIN_NID,
5623 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5624 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005625 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005626 .input_mux = &alc882_capture_source,
5627 },
5628 [ALC882_6ST_DIG] = {
5629 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5630 .init_verbs = { alc882_init_verbs },
5631 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5632 .dac_nids = alc882_dac_nids,
5633 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005634 .dig_in_nid = ALC882_DIGIN_NID,
5635 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5636 .channel_mode = alc882_sixstack_modes,
5637 .input_mux = &alc882_capture_source,
5638 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005639 [ALC882_ARIMA] = {
5640 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5641 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5642 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5643 .dac_nids = alc882_dac_nids,
5644 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5645 .channel_mode = alc882_sixstack_modes,
5646 .input_mux = &alc882_capture_source,
5647 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005648 [ALC882_W2JC] = {
5649 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5650 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5651 alc880_gpio1_init_verbs },
5652 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5653 .dac_nids = alc882_dac_nids,
5654 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5655 .channel_mode = alc880_threestack_modes,
5656 .need_dac_fix = 1,
5657 .input_mux = &alc882_capture_source,
5658 .dig_out_nid = ALC882_DIGOUT_NID,
5659 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005660 [ALC885_MBP3] = {
5661 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5662 .init_verbs = { alc885_mbp3_init_verbs,
5663 alc880_gpio1_init_verbs },
5664 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5665 .dac_nids = alc882_dac_nids,
5666 .channel_mode = alc885_mbp_6ch_modes,
5667 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5668 .input_mux = &alc882_capture_source,
5669 .dig_out_nid = ALC882_DIGOUT_NID,
5670 .dig_in_nid = ALC882_DIGIN_NID,
5671 .unsol_event = alc885_mbp3_unsol_event,
5672 .init_hook = alc885_mbp3_automute,
5673 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005674 [ALC885_MACPRO] = {
5675 .mixers = { alc882_macpro_mixer },
5676 .init_verbs = { alc882_macpro_init_verbs },
5677 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5678 .dac_nids = alc882_dac_nids,
5679 .dig_out_nid = ALC882_DIGOUT_NID,
5680 .dig_in_nid = ALC882_DIGIN_NID,
5681 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5682 .channel_mode = alc882_ch_modes,
5683 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005684 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005685 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005686 [ALC885_IMAC24] = {
5687 .mixers = { alc885_imac24_mixer },
5688 .init_verbs = { alc885_imac24_init_verbs },
5689 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5690 .dac_nids = alc882_dac_nids,
5691 .dig_out_nid = ALC882_DIGOUT_NID,
5692 .dig_in_nid = ALC882_DIGIN_NID,
5693 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5694 .channel_mode = alc882_ch_modes,
5695 .input_mux = &alc882_capture_source,
5696 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005697 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005698 },
Kailang Yang272a5272007-05-14 11:00:38 +02005699 [ALC882_TARGA] = {
5700 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5701 alc882_capture_mixer },
5702 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5703 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5704 .dac_nids = alc882_dac_nids,
5705 .dig_out_nid = ALC882_DIGOUT_NID,
5706 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5707 .adc_nids = alc882_adc_nids,
5708 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5709 .channel_mode = alc882_3ST_6ch_modes,
5710 .need_dac_fix = 1,
5711 .input_mux = &alc882_capture_source,
5712 .unsol_event = alc882_targa_unsol_event,
5713 .init_hook = alc882_targa_automute,
5714 },
5715 [ALC882_ASUS_A7J] = {
5716 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5717 alc882_capture_mixer },
5718 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5719 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5720 .dac_nids = alc882_dac_nids,
5721 .dig_out_nid = ALC882_DIGOUT_NID,
5722 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5723 .adc_nids = alc882_adc_nids,
5724 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5725 .channel_mode = alc882_3ST_6ch_modes,
5726 .need_dac_fix = 1,
5727 .input_mux = &alc882_capture_source,
5728 },
Takashi Iwai914759b2007-09-06 14:52:04 +02005729 [ALC882_ASUS_A7M] = {
5730 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5731 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5732 alc880_gpio1_init_verbs,
5733 alc882_asus_a7m_verbs },
5734 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5735 .dac_nids = alc882_dac_nids,
5736 .dig_out_nid = ALC882_DIGOUT_NID,
5737 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5738 .channel_mode = alc880_threestack_modes,
5739 .need_dac_fix = 1,
5740 .input_mux = &alc882_capture_source,
5741 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005742};
5743
5744
5745/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005746 * Pin config fixes
5747 */
5748enum {
5749 PINFIX_ABIT_AW9D_MAX
5750};
5751
5752static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5753 { 0x15, 0x01080104 }, /* side */
5754 { 0x16, 0x01011012 }, /* rear */
5755 { 0x17, 0x01016011 }, /* clfe */
5756 { }
5757};
5758
5759static const struct alc_pincfg *alc882_pin_fixes[] = {
5760 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5761};
5762
5763static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5764 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5765 {}
5766};
5767
5768/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005769 * BIOS auto configuration
5770 */
5771static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5772 hda_nid_t nid, int pin_type,
5773 int dac_idx)
5774{
5775 /* set as output */
5776 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005777 int idx;
5778
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5780 idx = 4;
5781 else
5782 idx = spec->multiout.dac_nids[dac_idx] - 2;
5783
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5785 pin_type);
5786 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5787 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005788 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5789
5790}
5791
5792static void alc882_auto_init_multi_out(struct hda_codec *codec)
5793{
5794 struct alc_spec *spec = codec->spec;
5795 int i;
5796
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005797 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005798 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005799 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005800 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005801 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005802 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005803 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 }
5805}
5806
5807static void alc882_auto_init_hp_out(struct hda_codec *codec)
5808{
5809 struct alc_spec *spec = codec->spec;
5810 hda_nid_t pin;
5811
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005812 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005813 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005814 /* use dac 0 */
5815 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005816}
5817
5818#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5819#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5820
5821static void alc882_auto_init_analog_input(struct hda_codec *codec)
5822{
5823 struct alc_spec *spec = codec->spec;
5824 int i;
5825
5826 for (i = 0; i < AUTO_PIN_LAST; i++) {
5827 hda_nid_t nid = spec->autocfg.input_pins[i];
5828 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005829 snd_hda_codec_write(codec, nid, 0,
5830 AC_VERB_SET_PIN_WIDGET_CONTROL,
5831 i <= AUTO_PIN_FRONT_MIC ?
5832 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005833 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005834 snd_hda_codec_write(codec, nid, 0,
5835 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005836 AMP_OUT_MUTE);
5837 }
5838 }
5839}
5840
Takashi Iwai776e1842007-08-29 15:07:11 +02005841/* add mic boosts if needed */
5842static int alc_auto_add_mic_boost(struct hda_codec *codec)
5843{
5844 struct alc_spec *spec = codec->spec;
5845 int err;
5846 hda_nid_t nid;
5847
5848 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
5849 if (nid) {
5850 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5851 "Mic Boost",
5852 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
5853 if (err < 0)
5854 return err;
5855 }
5856 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
5857 if (nid) {
5858 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5859 "Front Mic Boost",
5860 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
5861 if (err < 0)
5862 return err;
5863 }
5864 return 0;
5865}
5866
Kailang Yangdf694da2005-12-05 19:42:22 +01005867/* almost identical with ALC880 parser... */
5868static int alc882_parse_auto_config(struct hda_codec *codec)
5869{
5870 struct alc_spec *spec = codec->spec;
5871 int err = alc880_parse_auto_config(codec);
5872
5873 if (err < 0)
5874 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02005875 else if (!err)
5876 return 0; /* no config found */
5877
5878 err = alc_auto_add_mic_boost(codec);
5879 if (err < 0)
5880 return err;
5881
5882 /* hack - override the init verbs */
5883 spec->init_verbs[0] = alc882_auto_init_verbs;
5884
5885 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01005886}
5887
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005888/* additional initialization for auto-configuration model */
5889static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005890{
Kailang Yangdf694da2005-12-05 19:42:22 +01005891 alc882_auto_init_multi_out(codec);
5892 alc882_auto_init_hp_out(codec);
5893 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005894}
5895
Linus Torvalds1da177e2005-04-16 15:20:36 -07005896static int patch_alc882(struct hda_codec *codec)
5897{
5898 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005899 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005900
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005901 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005902 if (spec == NULL)
5903 return -ENOMEM;
5904
Linus Torvalds1da177e2005-04-16 15:20:36 -07005905 codec->spec = spec;
5906
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005907 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5908 alc882_models,
5909 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005910
Kailang Yangdf694da2005-12-05 19:42:22 +01005911 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005912 /* Pick up systems that don't supply PCI SSID */
5913 switch (codec->subsystem_id) {
5914 case 0x106b0c00: /* Mac Pro */
5915 board_config = ALC885_MACPRO;
5916 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005917 case 0x106b1000: /* iMac 24 */
5918 board_config = ALC885_IMAC24;
5919 break;
Takashi Iwai87350ad2007-08-16 18:19:38 +02005920 case 0x106b2c00: /* Macbook Pro rev3 */
5921 board_config = ALC885_MBP3;
5922 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005923 default:
5924 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5925 "trying auto-probe from BIOS...\n");
5926 board_config = ALC882_AUTO;
5927 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005928 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005929
Takashi Iwaif95474e2007-07-10 00:47:43 +02005930 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5931
Kailang Yangdf694da2005-12-05 19:42:22 +01005932 if (board_config == ALC882_AUTO) {
5933 /* automatic parse from the BIOS config */
5934 err = alc882_parse_auto_config(codec);
5935 if (err < 0) {
5936 alc_free(codec);
5937 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005938 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005939 printk(KERN_INFO
5940 "hda_codec: Cannot set up configuration "
5941 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005942 board_config = ALC882_3ST_DIG;
5943 }
5944 }
5945
5946 if (board_config != ALC882_AUTO)
5947 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005948
5949 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005950 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5951 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005952
5953 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5955 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005956
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005957 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005958 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005959 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005960 /* get type */
5961 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005962 if (wcap != AC_WID_AUD_IN) {
5963 spec->adc_nids = alc882_adc_nids_alt;
5964 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005965 spec->mixers[spec->num_mixers] =
5966 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005967 spec->num_mixers++;
5968 } else {
5969 spec->adc_nids = alc882_adc_nids;
5970 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5971 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5972 spec->num_mixers++;
5973 }
5974 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005975
5976 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005977 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005978 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005979#ifdef CONFIG_SND_HDA_POWER_SAVE
5980 if (!spec->loopback.amplist)
5981 spec->loopback.amplist = alc882_loopbacks;
5982#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005983
5984 return 0;
5985}
5986
5987/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005988 * ALC883 support
5989 *
5990 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5991 * configuration. Each pin widget can choose any input DACs and a mixer.
5992 * Each ADC is connected from a mixer of all inputs. This makes possible
5993 * 6-channel independent captures.
5994 *
5995 * In addition, an independent DAC for the multi-playback (not used in this
5996 * driver yet).
5997 */
5998#define ALC883_DIGOUT_NID 0x06
5999#define ALC883_DIGIN_NID 0x0a
6000
6001static hda_nid_t alc883_dac_nids[4] = {
6002 /* front, rear, clfe, rear_surr */
6003 0x02, 0x04, 0x03, 0x05
6004};
6005
6006static hda_nid_t alc883_adc_nids[2] = {
6007 /* ADC1-2 */
6008 0x08, 0x09,
6009};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006010
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006011/* input MUX */
6012/* FIXME: should be a matrix-type input source selection */
6013
6014static struct hda_input_mux alc883_capture_source = {
6015 .num_items = 4,
6016 .items = {
6017 { "Mic", 0x0 },
6018 { "Front Mic", 0x1 },
6019 { "Line", 0x2 },
6020 { "CD", 0x4 },
6021 },
6022};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006023
6024static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6025 .num_items = 2,
6026 .items = {
6027 { "Mic", 0x1 },
6028 { "Line", 0x2 },
6029 },
6030};
6031
Kailang Yang272a5272007-05-14 11:00:38 +02006032static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6033 .num_items = 4,
6034 .items = {
6035 { "Mic", 0x0 },
6036 { "iMic", 0x1 },
6037 { "Line", 0x2 },
6038 { "CD", 0x4 },
6039 },
6040};
6041
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006042#define alc883_mux_enum_info alc_mux_enum_info
6043#define alc883_mux_enum_get alc_mux_enum_get
6044
6045static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6046 struct snd_ctl_elem_value *ucontrol)
6047{
6048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6049 struct alc_spec *spec = codec->spec;
6050 const struct hda_input_mux *imux = spec->input_mux;
6051 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6052 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6053 hda_nid_t nid = capture_mixers[adc_idx];
6054 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6055 unsigned int i, idx;
6056
6057 idx = ucontrol->value.enumerated.item[0];
6058 if (idx >= imux->num_items)
6059 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006060 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006061 return 0;
6062 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02006063 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6064 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006065 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02006066 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006067 }
6068 *cur_val = idx;
6069 return 1;
6070}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006071
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006072/*
6073 * 2ch mode
6074 */
6075static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6076 { 2, NULL }
6077};
6078
6079/*
6080 * 2ch mode
6081 */
6082static struct hda_verb alc883_3ST_ch2_init[] = {
6083 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6084 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6085 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6086 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6087 { } /* end */
6088};
6089
6090/*
Tobin Davisb2011312007-09-17 12:45:11 +02006091 * 4ch mode
6092 */
6093static struct hda_verb alc883_3ST_ch4_init[] = {
6094 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6095 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6096 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6097 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6098 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6099 { } /* end */
6100};
6101
6102/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006103 * 6ch mode
6104 */
6105static struct hda_verb alc883_3ST_ch6_init[] = {
6106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6108 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6109 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6110 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6111 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6112 { } /* end */
6113};
6114
Tobin Davisb2011312007-09-17 12:45:11 +02006115static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006116 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006117 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006118 { 6, alc883_3ST_ch6_init },
6119};
6120
6121/*
6122 * 6ch mode
6123 */
6124static struct hda_verb alc883_sixstack_ch6_init[] = {
6125 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6126 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6127 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6128 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6129 { } /* end */
6130};
6131
6132/*
6133 * 8ch mode
6134 */
6135static struct hda_verb alc883_sixstack_ch8_init[] = {
6136 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6137 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6138 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6139 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6140 { } /* end */
6141};
6142
6143static struct hda_channel_mode alc883_sixstack_modes[2] = {
6144 { 6, alc883_sixstack_ch6_init },
6145 { 8, alc883_sixstack_ch8_init },
6146};
6147
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006148static struct hda_verb alc883_medion_eapd_verbs[] = {
6149 /* eanable EAPD on medion laptop */
6150 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6151 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6152 { }
6153};
6154
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006155/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6156 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6157 */
6158
6159static struct snd_kcontrol_new alc883_base_mixer[] = {
6160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6163 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6164 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6165 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6168 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6169 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6171 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6172 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6178 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006179 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6181 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6182 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6183 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6184 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6185 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6186 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6187 {
6188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6189 /* .name = "Capture Source", */
6190 .name = "Input Source",
6191 .count = 2,
6192 .info = alc883_mux_enum_info,
6193 .get = alc883_mux_enum_get,
6194 .put = alc883_mux_enum_put,
6195 },
6196 { } /* end */
6197};
6198
6199static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6203 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6204 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006208 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6210 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006211 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6213 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6214 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6218 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6219 {
6220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6221 /* .name = "Capture Source", */
6222 .name = "Input Source",
6223 .count = 2,
6224 .info = alc883_mux_enum_info,
6225 .get = alc883_mux_enum_get,
6226 .put = alc883_mux_enum_put,
6227 },
6228 { } /* end */
6229};
6230
6231static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6234 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6235 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6236 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6237 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6238 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6239 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006246 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6248 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006249 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006250 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6251 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6252 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6253 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6254 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6255 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6256 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6257 {
6258 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6259 /* .name = "Capture Source", */
6260 .name = "Input Source",
6261 .count = 2,
6262 .info = alc883_mux_enum_info,
6263 .get = alc883_mux_enum_get,
6264 .put = alc883_mux_enum_put,
6265 },
6266 { } /* end */
6267};
6268
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006269static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6271 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6273 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6276 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6277 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6279 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6280 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6281 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6282 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6286 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006287 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006288 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6289 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6290 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6291 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6292 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6293
6294 {
6295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6296 /* .name = "Capture Source", */
6297 .name = "Input Source",
6298 .count = 1,
6299 .info = alc883_mux_enum_info,
6300 .get = alc883_mux_enum_get,
6301 .put = alc883_mux_enum_put,
6302 },
6303 { } /* end */
6304};
6305
Kailang Yangccc656c2006-10-17 12:32:26 +02006306static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6307 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6309 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6310 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6311 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6312 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6313 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6314 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6315 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6316 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6317 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006321 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6323 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6324 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6325 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6326 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6327 {
6328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6329 /* .name = "Capture Source", */
6330 .name = "Input Source",
6331 .count = 2,
6332 .info = alc883_mux_enum_info,
6333 .get = alc883_mux_enum_get,
6334 .put = alc883_mux_enum_put,
6335 },
6336 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006337};
Kailang Yangccc656c2006-10-17 12:32:26 +02006338
6339static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6342 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6348 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6349 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6350 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6351 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6352 {
6353 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6354 /* .name = "Capture Source", */
6355 .name = "Input Source",
6356 .count = 2,
6357 .info = alc883_mux_enum_info,
6358 .get = alc883_mux_enum_get,
6359 .put = alc883_mux_enum_put,
6360 },
6361 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006362};
Kailang Yangccc656c2006-10-17 12:32:26 +02006363
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6366 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6367 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6368 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6371 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6373 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6374 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6375 {
6376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6377 /* .name = "Capture Source", */
6378 .name = "Input Source",
6379 .count = 1,
6380 .info = alc883_mux_enum_info,
6381 .get = alc883_mux_enum_get,
6382 .put = alc883_mux_enum_put,
6383 },
6384 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006385};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006386
Kailang Yang272a5272007-05-14 11:00:38 +02006387static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6388 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6389 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6395 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6396 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6397 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6398 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6399 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6400 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6401 {
6402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6403 /* .name = "Capture Source", */
6404 .name = "Input Source",
6405 .count = 2,
6406 .info = alc883_mux_enum_info,
6407 .get = alc883_mux_enum_get,
6408 .put = alc883_mux_enum_put,
6409 },
6410 { } /* end */
6411};
6412
6413static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6416 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6423 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6424 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6425 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6426 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6427 {
6428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6429 /* .name = "Capture Source", */
6430 .name = "Input Source",
6431 .count = 2,
6432 .info = alc883_mux_enum_info,
6433 .get = alc883_mux_enum_get,
6434 .put = alc883_mux_enum_put,
6435 },
6436 { } /* end */
6437};
6438
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006439static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006440 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6441 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6443 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6445 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6448 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6449 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6456 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6457 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6458 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6459 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6461 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6462 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6464 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6465 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6466 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6467 {
6468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6469 /* .name = "Capture Source", */
6470 .name = "Input Source",
6471 .count = 2,
6472 .info = alc883_mux_enum_info,
6473 .get = alc883_mux_enum_get,
6474 .put = alc883_mux_enum_put,
6475 },
6476 { } /* end */
6477};
6478
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006479static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006480 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6481 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6482 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6483 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6484 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6485 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6486 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6487 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6491 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6492 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6498 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6499 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6500 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6501 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6502 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6503 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6504 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6505 {
6506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6507 /* .name = "Capture Source", */
6508 .name = "Input Source",
6509 .count = 2,
6510 .info = alc883_mux_enum_info,
6511 .get = alc883_mux_enum_get,
6512 .put = alc883_mux_enum_put,
6513 },
6514 { } /* end */
6515};
6516
Tobin Davis2880a862007-08-07 11:50:26 +02006517static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006518 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6519 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006521 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6522 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6524 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006526 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6527 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6528 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6529 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6530 {
6531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6532 /* .name = "Capture Source", */
6533 .name = "Input Source",
6534 .count = 2,
6535 .info = alc883_mux_enum_info,
6536 .get = alc883_mux_enum_get,
6537 .put = alc883_mux_enum_put,
6538 },
6539 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006540};
Tobin Davis2880a862007-08-07 11:50:26 +02006541
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006542static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6543 {
6544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6545 .name = "Channel Mode",
6546 .info = alc_ch_mode_info,
6547 .get = alc_ch_mode_get,
6548 .put = alc_ch_mode_put,
6549 },
6550 { } /* end */
6551};
6552
6553static struct hda_verb alc883_init_verbs[] = {
6554 /* ADC1: mute amp left and right */
6555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6556 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6557 /* ADC2: mute amp left and right */
6558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6559 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6560 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6564 /* Rear mixer */
6565 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6566 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6567 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6568 /* CLFE mixer */
6569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6572 /* Side mixer */
6573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6574 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6575 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6576
Takashi Iwaicb53c622007-08-10 17:21:45 +02006577 /* mute analog input loopbacks */
6578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006583
6584 /* Front Pin: output 0 (0x0c) */
6585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6587 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6588 /* Rear Pin: output 1 (0x0d) */
6589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6592 /* CLFE Pin: output 2 (0x0e) */
6593 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6596 /* Side Pin: output 3 (0x0f) */
6597 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6598 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6599 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6600 /* Mic (rear) pin: input vref at 80% */
6601 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6602 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6603 /* Front Mic pin: input vref at 80% */
6604 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6605 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6606 /* Line In pin: input */
6607 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6608 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6609 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6611 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6612 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6613 /* CD pin widget for input */
6614 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6615
6616 /* FIXME: use matrix-type input source selection */
6617 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6618 /* Input mixer2 */
6619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6623 /* Input mixer3 */
6624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6628 { }
6629};
6630
Kailang Yangccc656c2006-10-17 12:32:26 +02006631static struct hda_verb alc883_tagra_verbs[] = {
6632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6634
6635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6636 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6637
6638 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6639 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6640 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6641
6642 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006643 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6645 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006646
6647 { } /* end */
6648};
6649
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006650static struct hda_verb alc883_lenovo_101e_verbs[] = {
6651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6652 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6654 { } /* end */
6655};
6656
Kailang Yang272a5272007-05-14 11:00:38 +02006657static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6660 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6662 { } /* end */
6663};
6664
6665static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6669 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6670 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6671 { } /* end */
6672};
6673
Kailang Yang189609a2007-08-20 11:31:23 +02006674static struct hda_verb alc883_haier_w66_verbs[] = {
6675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6677
6678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6679
6680 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6681 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6683 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6684 { } /* end */
6685};
6686
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006687static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006688 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6689 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6690 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6691 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6692 { }
6693};
6694
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006695static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006696 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6697 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6698 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6699 { }
6700};
6701
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006702static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006703 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6704 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6705 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6706 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6707 { }
6708};
6709
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006710static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6713 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6714 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6715 { }
6716};
6717
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006718static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6719 { 2, alc888_3st_hp_2ch_init },
6720 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006721};
6722
Kailang Yang272a5272007-05-14 11:00:38 +02006723/* toggle front-jack and RCA according to the hp-jack state */
6724static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6725{
6726 unsigned int present;
6727
6728 present = snd_hda_codec_read(codec, 0x1b, 0,
6729 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006730 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6731 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6732 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6733 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006734}
6735
6736/* toggle RCA according to the front-jack state */
6737static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6738{
6739 unsigned int present;
6740
6741 present = snd_hda_codec_read(codec, 0x14, 0,
6742 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006743 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6744 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006745}
Takashi Iwai47fd8302007-08-10 17:11:07 +02006746
Kailang Yang272a5272007-05-14 11:00:38 +02006747static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6748 unsigned int res)
6749{
6750 if ((res >> 26) == ALC880_HP_EVENT)
6751 alc888_lenovo_ms7195_front_automute(codec);
6752 if ((res >> 26) == ALC880_FRONT_EVENT)
6753 alc888_lenovo_ms7195_rca_automute(codec);
6754}
6755
6756static struct hda_verb alc883_medion_md2_verbs[] = {
6757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6759
6760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6761
6762 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6763 { } /* end */
6764};
6765
6766/* toggle speaker-output according to the hp-jack state */
6767static void alc883_medion_md2_automute(struct hda_codec *codec)
6768{
6769 unsigned int present;
6770
6771 present = snd_hda_codec_read(codec, 0x14, 0,
6772 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006773 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6774 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006775}
6776
6777static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6778 unsigned int res)
6779{
6780 if ((res >> 26) == ALC880_HP_EVENT)
6781 alc883_medion_md2_automute(codec);
6782}
6783
Kailang Yangccc656c2006-10-17 12:32:26 +02006784/* toggle speaker-output according to the hp-jack state */
6785static void alc883_tagra_automute(struct hda_codec *codec)
6786{
6787 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006788 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006789
6790 present = snd_hda_codec_read(codec, 0x14, 0,
6791 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006792 bits = present ? HDA_AMP_MUTE : 0;
6793 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6794 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006795 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6796 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006797}
6798
6799static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6800{
6801 if ((res >> 26) == ALC880_HP_EVENT)
6802 alc883_tagra_automute(codec);
6803}
6804
Kailang Yang189609a2007-08-20 11:31:23 +02006805static void alc883_haier_w66_automute(struct hda_codec *codec)
6806{
6807 unsigned int present;
6808 unsigned char bits;
6809
6810 present = snd_hda_codec_read(codec, 0x1b, 0,
6811 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6812 bits = present ? 0x80 : 0;
6813 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6814 0x80, bits);
6815}
6816
6817static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
6818 unsigned int res)
6819{
6820 if ((res >> 26) == ALC880_HP_EVENT)
6821 alc883_haier_w66_automute(codec);
6822}
6823
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006824static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6825{
6826 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006827 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006828
6829 present = snd_hda_codec_read(codec, 0x14, 0,
6830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006831 bits = present ? HDA_AMP_MUTE : 0;
6832 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6833 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006834}
6835
6836static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6837{
6838 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006839 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006840
6841 present = snd_hda_codec_read(codec, 0x1b, 0,
6842 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006843 bits = present ? HDA_AMP_MUTE : 0;
6844 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6845 HDA_AMP_MUTE, bits);
6846 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6847 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006848}
6849
6850static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6851 unsigned int res)
6852{
6853 if ((res >> 26) == ALC880_HP_EVENT)
6854 alc883_lenovo_101e_all_automute(codec);
6855 if ((res >> 26) == ALC880_FRONT_EVENT)
6856 alc883_lenovo_101e_ispeaker_automute(codec);
6857}
6858
Takashi Iwai676a9b52007-08-16 15:23:35 +02006859/* toggle speaker-output according to the hp-jack state */
6860static void alc883_acer_aspire_automute(struct hda_codec *codec)
6861{
6862 unsigned int present;
6863
6864 present = snd_hda_codec_read(codec, 0x14, 0,
6865 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6866 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6867 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6868 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
6869 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6870}
6871
6872static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
6873 unsigned int res)
6874{
6875 if ((res >> 26) == ALC880_HP_EVENT)
6876 alc883_acer_aspire_automute(codec);
6877}
6878
Kailang Yangd1a991a2007-08-15 16:21:59 +02006879static struct hda_verb alc883_acer_eapd_verbs[] = {
6880 /* HP Pin: output 0 (0x0c) */
6881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02006885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6886 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006887 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006888 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6889 /* eanable EAPD on medion laptop */
6890 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6891 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02006892 /* enable unsolicited event */
6893 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006894 { }
6895};
6896
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006897/*
6898 * generic initialization of ADC, input mixers and output mixers
6899 */
6900static struct hda_verb alc883_auto_init_verbs[] = {
6901 /*
6902 * Unmute ADC0-2 and set the default input to mic-in
6903 */
6904 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6905 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6906 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6908
Takashi Iwaicb53c622007-08-10 17:21:45 +02006909 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006910 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006911 * Note: PASD motherboards uses the Line In 2 as the input for
6912 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006913 */
6914 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006920
6921 /*
6922 * Set up output mixers (0x0c - 0x0f)
6923 */
6924 /* set vol=0 to output mixers */
6925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6929 /* set up input amps for analog loopback */
6930 /* Amp Indices: DAC = 0, mixer = 1 */
6931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6938 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6939 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6940 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6941
6942 /* FIXME: use matrix-type input source selection */
6943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6944 /* Input mixer1 */
6945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006948 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6950 /* Input mixer2 */
6951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006954 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6956
6957 { }
6958};
6959
6960/* capture mixer elements */
6961static struct snd_kcontrol_new alc883_capture_mixer[] = {
6962 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6963 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6964 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6965 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6966 {
6967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6968 /* The multiple "Capture Source" controls confuse alsamixer
6969 * So call somewhat different..
6970 * FIXME: the controls appear in the "playback" view!
6971 */
6972 /* .name = "Capture Source", */
6973 .name = "Input Source",
6974 .count = 2,
6975 .info = alc882_mux_enum_info,
6976 .get = alc882_mux_enum_get,
6977 .put = alc882_mux_enum_put,
6978 },
6979 { } /* end */
6980};
6981
Takashi Iwaicb53c622007-08-10 17:21:45 +02006982#ifdef CONFIG_SND_HDA_POWER_SAVE
6983#define alc883_loopbacks alc880_loopbacks
6984#endif
6985
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006986/* pcm configuration: identiacal with ALC880 */
6987#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6988#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6989#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6990#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6991
6992/*
6993 * configuration and preset
6994 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006995static const char *alc883_models[ALC883_MODEL_LAST] = {
6996 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6997 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6998 [ALC883_3ST_6ch] = "3stack-6ch",
6999 [ALC883_6ST_DIG] = "6stack-dig",
7000 [ALC883_TARGA_DIG] = "targa-dig",
7001 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007002 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02007003 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007004 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02007005 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007006 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007007 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02007008 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7009 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02007010 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007011 [ALC888_6ST_HP] = "6stack-hp",
7012 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007013 [ALC883_AUTO] = "auto",
7014};
7015
7016static struct snd_pci_quirk alc883_cfg_tbl[] = {
7017 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02007018 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007019 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7020 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7021 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02007022 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007023 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7024 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02007025 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01007026 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02007027 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02007028 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007029 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02007030 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007031 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7032 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7033 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7034 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7035 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
Takashi Iwai64ca1c22007-08-16 17:23:32 +02007036 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007037 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7038 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7039 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7040 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007041 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Tobin Davis2880a862007-08-07 11:50:26 +02007042 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai8da64702007-09-05 19:14:38 +02007043 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007044 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04007045 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007046 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7047 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7048 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02007049 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7050 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7051 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007052 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7053 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7054 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02007055 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02007056 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7057 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Tobin Davis11370ee2007-09-17 12:46:12 +02007058 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7059 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007060 {}
7061};
7062
7063static struct alc_config_preset alc883_presets[] = {
7064 [ALC883_3ST_2ch_DIG] = {
7065 .mixers = { alc883_3ST_2ch_mixer },
7066 .init_verbs = { alc883_init_verbs },
7067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7068 .dac_nids = alc883_dac_nids,
7069 .dig_out_nid = ALC883_DIGOUT_NID,
7070 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7071 .adc_nids = alc883_adc_nids,
7072 .dig_in_nid = ALC883_DIGIN_NID,
7073 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7074 .channel_mode = alc883_3ST_2ch_modes,
7075 .input_mux = &alc883_capture_source,
7076 },
7077 [ALC883_3ST_6ch_DIG] = {
7078 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7079 .init_verbs = { alc883_init_verbs },
7080 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7081 .dac_nids = alc883_dac_nids,
7082 .dig_out_nid = ALC883_DIGOUT_NID,
7083 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7084 .adc_nids = alc883_adc_nids,
7085 .dig_in_nid = ALC883_DIGIN_NID,
7086 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7087 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007088 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007089 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007090 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007091 [ALC883_3ST_6ch] = {
7092 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7093 .init_verbs = { alc883_init_verbs },
7094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7095 .dac_nids = alc883_dac_nids,
7096 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7097 .adc_nids = alc883_adc_nids,
7098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7099 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007100 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007101 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007102 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007103 [ALC883_6ST_DIG] = {
7104 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7105 .init_verbs = { alc883_init_verbs },
7106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7107 .dac_nids = alc883_dac_nids,
7108 .dig_out_nid = ALC883_DIGOUT_NID,
7109 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7110 .adc_nids = alc883_adc_nids,
7111 .dig_in_nid = ALC883_DIGIN_NID,
7112 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7113 .channel_mode = alc883_sixstack_modes,
7114 .input_mux = &alc883_capture_source,
7115 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007116 [ALC883_TARGA_DIG] = {
7117 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7118 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7120 .dac_nids = alc883_dac_nids,
7121 .dig_out_nid = ALC883_DIGOUT_NID,
7122 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7123 .adc_nids = alc883_adc_nids,
7124 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7125 .channel_mode = alc883_3ST_6ch_modes,
7126 .need_dac_fix = 1,
7127 .input_mux = &alc883_capture_source,
7128 .unsol_event = alc883_tagra_unsol_event,
7129 .init_hook = alc883_tagra_automute,
7130 },
7131 [ALC883_TARGA_2ch_DIG] = {
7132 .mixers = { alc883_tagra_2ch_mixer},
7133 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7134 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7135 .dac_nids = alc883_dac_nids,
7136 .dig_out_nid = ALC883_DIGOUT_NID,
7137 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7138 .adc_nids = alc883_adc_nids,
7139 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7140 .channel_mode = alc883_3ST_2ch_modes,
7141 .input_mux = &alc883_capture_source,
7142 .unsol_event = alc883_tagra_unsol_event,
7143 .init_hook = alc883_tagra_automute,
7144 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007145 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007146 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007147 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7148 * and the headphone jack. Turn this on and rely on the
7149 * standard mute methods whenever the user wants to turn
7150 * these outputs off.
7151 */
7152 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7154 .dac_nids = alc883_dac_nids,
7155 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7156 .adc_nids = alc883_adc_nids,
7157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7158 .channel_mode = alc883_3ST_2ch_modes,
7159 .input_mux = &alc883_capture_source,
7160 },
Tobin Davis2880a862007-08-07 11:50:26 +02007161 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007162 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007163 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007164 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7165 .dac_nids = alc883_dac_nids,
7166 .dig_out_nid = ALC883_DIGOUT_NID,
7167 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7168 .adc_nids = alc883_adc_nids,
7169 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7170 .channel_mode = alc883_3ST_2ch_modes,
7171 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007172 .unsol_event = alc883_acer_aspire_unsol_event,
7173 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007174 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007175 [ALC883_MEDION] = {
7176 .mixers = { alc883_fivestack_mixer,
7177 alc883_chmode_mixer },
7178 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007179 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7181 .dac_nids = alc883_dac_nids,
7182 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7183 .adc_nids = alc883_adc_nids,
7184 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7185 .channel_mode = alc883_sixstack_modes,
7186 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007187 },
Kailang Yang272a5272007-05-14 11:00:38 +02007188 [ALC883_MEDION_MD2] = {
7189 .mixers = { alc883_medion_md2_mixer},
7190 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7191 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7192 .dac_nids = alc883_dac_nids,
7193 .dig_out_nid = ALC883_DIGOUT_NID,
7194 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7195 .adc_nids = alc883_adc_nids,
7196 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7197 .channel_mode = alc883_3ST_2ch_modes,
7198 .input_mux = &alc883_capture_source,
7199 .unsol_event = alc883_medion_md2_unsol_event,
7200 .init_hook = alc883_medion_md2_automute,
7201 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007202 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007203 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007204 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7206 .dac_nids = alc883_dac_nids,
7207 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7208 .adc_nids = alc883_adc_nids,
7209 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7210 .channel_mode = alc883_3ST_2ch_modes,
7211 .input_mux = &alc883_capture_source,
7212 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007213 [ALC883_LENOVO_101E_2ch] = {
7214 .mixers = { alc883_lenovo_101e_2ch_mixer},
7215 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7216 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7217 .dac_nids = alc883_dac_nids,
7218 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7219 .adc_nids = alc883_adc_nids,
7220 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7221 .channel_mode = alc883_3ST_2ch_modes,
7222 .input_mux = &alc883_lenovo_101e_capture_source,
7223 .unsol_event = alc883_lenovo_101e_unsol_event,
7224 .init_hook = alc883_lenovo_101e_all_automute,
7225 },
Kailang Yang272a5272007-05-14 11:00:38 +02007226 [ALC883_LENOVO_NB0763] = {
7227 .mixers = { alc883_lenovo_nb0763_mixer },
7228 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7229 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7230 .dac_nids = alc883_dac_nids,
7231 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7232 .adc_nids = alc883_adc_nids,
7233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7234 .channel_mode = alc883_3ST_2ch_modes,
7235 .need_dac_fix = 1,
7236 .input_mux = &alc883_lenovo_nb0763_capture_source,
7237 .unsol_event = alc883_medion_md2_unsol_event,
7238 .init_hook = alc883_medion_md2_automute,
7239 },
7240 [ALC888_LENOVO_MS7195_DIG] = {
7241 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7242 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7243 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7244 .dac_nids = alc883_dac_nids,
7245 .dig_out_nid = ALC883_DIGOUT_NID,
7246 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7247 .adc_nids = alc883_adc_nids,
7248 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7249 .channel_mode = alc883_3ST_6ch_modes,
7250 .need_dac_fix = 1,
7251 .input_mux = &alc883_capture_source,
7252 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7253 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007254 },
7255 [ALC883_HAIER_W66] = {
7256 .mixers = { alc883_tagra_2ch_mixer},
7257 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7258 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7259 .dac_nids = alc883_dac_nids,
7260 .dig_out_nid = ALC883_DIGOUT_NID,
7261 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7262 .adc_nids = alc883_adc_nids,
7263 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7264 .channel_mode = alc883_3ST_2ch_modes,
7265 .input_mux = &alc883_capture_source,
7266 .unsol_event = alc883_haier_w66_unsol_event,
7267 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007268 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007269 [ALC888_6ST_HP] = {
7270 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7271 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007272 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7273 .dac_nids = alc883_dac_nids,
7274 .dig_out_nid = ALC883_DIGOUT_NID,
7275 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7276 .adc_nids = alc883_adc_nids,
7277 .dig_in_nid = ALC883_DIGIN_NID,
7278 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7279 .channel_mode = alc883_sixstack_modes,
7280 .input_mux = &alc883_capture_source,
7281 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007282 [ALC888_3ST_HP] = {
7283 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7284 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007285 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7286 .dac_nids = alc883_dac_nids,
7287 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7288 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007289 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7290 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007291 .need_dac_fix = 1,
7292 .input_mux = &alc883_capture_source,
7293 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007294};
7295
7296
7297/*
7298 * BIOS auto configuration
7299 */
7300static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7301 hda_nid_t nid, int pin_type,
7302 int dac_idx)
7303{
7304 /* set as output */
7305 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007306 int idx;
7307
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007308 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7309 idx = 4;
7310 else
7311 idx = spec->multiout.dac_nids[dac_idx] - 2;
7312
7313 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7314 pin_type);
7315 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7316 AMP_OUT_UNMUTE);
7317 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7318
7319}
7320
7321static void alc883_auto_init_multi_out(struct hda_codec *codec)
7322{
7323 struct alc_spec *spec = codec->spec;
7324 int i;
7325
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007326 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007327 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007328 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007329 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007330 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007331 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007332 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007333 }
7334}
7335
7336static void alc883_auto_init_hp_out(struct hda_codec *codec)
7337{
7338 struct alc_spec *spec = codec->spec;
7339 hda_nid_t pin;
7340
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007341 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007342 if (pin) /* connect to front */
7343 /* use dac 0 */
7344 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7345}
7346
7347#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7348#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7349
7350static void alc883_auto_init_analog_input(struct hda_codec *codec)
7351{
7352 struct alc_spec *spec = codec->spec;
7353 int i;
7354
7355 for (i = 0; i < AUTO_PIN_LAST; i++) {
7356 hda_nid_t nid = spec->autocfg.input_pins[i];
7357 if (alc883_is_input_pin(nid)) {
7358 snd_hda_codec_write(codec, nid, 0,
7359 AC_VERB_SET_PIN_WIDGET_CONTROL,
7360 (i <= AUTO_PIN_FRONT_MIC ?
7361 PIN_VREF80 : PIN_IN));
7362 if (nid != ALC883_PIN_CD_NID)
7363 snd_hda_codec_write(codec, nid, 0,
7364 AC_VERB_SET_AMP_GAIN_MUTE,
7365 AMP_OUT_MUTE);
7366 }
7367 }
7368}
7369
7370/* almost identical with ALC880 parser... */
7371static int alc883_parse_auto_config(struct hda_codec *codec)
7372{
7373 struct alc_spec *spec = codec->spec;
7374 int err = alc880_parse_auto_config(codec);
7375
7376 if (err < 0)
7377 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007378 else if (!err)
7379 return 0; /* no config found */
7380
7381 err = alc_auto_add_mic_boost(codec);
7382 if (err < 0)
7383 return err;
7384
7385 /* hack - override the init verbs */
7386 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007387 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7388 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02007389
7390 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007391}
7392
7393/* additional initialization for auto-configuration model */
7394static void alc883_auto_init(struct hda_codec *codec)
7395{
7396 alc883_auto_init_multi_out(codec);
7397 alc883_auto_init_hp_out(codec);
7398 alc883_auto_init_analog_input(codec);
7399}
7400
7401static int patch_alc883(struct hda_codec *codec)
7402{
7403 struct alc_spec *spec;
7404 int err, board_config;
7405
7406 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7407 if (spec == NULL)
7408 return -ENOMEM;
7409
7410 codec->spec = spec;
7411
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007412 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7413 alc883_models,
7414 alc883_cfg_tbl);
7415 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007416 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7417 "trying auto-probe from BIOS...\n");
7418 board_config = ALC883_AUTO;
7419 }
7420
7421 if (board_config == ALC883_AUTO) {
7422 /* automatic parse from the BIOS config */
7423 err = alc883_parse_auto_config(codec);
7424 if (err < 0) {
7425 alc_free(codec);
7426 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007427 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007428 printk(KERN_INFO
7429 "hda_codec: Cannot set up configuration "
7430 "from BIOS. Using base mode...\n");
7431 board_config = ALC883_3ST_2ch_DIG;
7432 }
7433 }
7434
7435 if (board_config != ALC883_AUTO)
7436 setup_preset(spec, &alc883_presets[board_config]);
7437
7438 spec->stream_name_analog = "ALC883 Analog";
7439 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7440 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7441
7442 spec->stream_name_digital = "ALC883 Digital";
7443 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7444 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007446 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007447 spec->adc_nids = alc883_adc_nids;
7448 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7449 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007450
7451 codec->patch_ops = alc_patch_ops;
7452 if (board_config == ALC883_AUTO)
7453 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007454#ifdef CONFIG_SND_HDA_POWER_SAVE
7455 if (!spec->loopback.amplist)
7456 spec->loopback.amplist = alc883_loopbacks;
7457#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007458
7459 return 0;
7460}
7461
7462/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007463 * ALC262 support
7464 */
7465
7466#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7467#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7468
7469#define alc262_dac_nids alc260_dac_nids
7470#define alc262_adc_nids alc882_adc_nids
7471#define alc262_adc_nids_alt alc882_adc_nids_alt
7472
7473#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007474#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007475
7476static struct snd_kcontrol_new alc262_base_mixer[] = {
7477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7478 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007489 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7490 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7492 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7493 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7494 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007495 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007496};
7497
Kailang Yangccc656c2006-10-17 12:32:26 +02007498static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7499 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7500 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7501 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7502 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7503 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7504 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007508 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007510 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007511 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7512 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7513 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7515 { } /* end */
7516};
7517
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007518static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7520 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7522 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7523 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7524
7525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7526 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007527 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007528 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7529 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007530 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007531 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7532 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7533 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7534 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7535 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7536 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7537 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7538 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7539 { } /* end */
7540};
7541
Kailang Yangcd7509a2007-01-26 18:33:17 +01007542static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7544 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7547 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7548 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7550 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007551 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7556 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7557 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7558 { } /* end */
7559};
7560
7561static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7562 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7563 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007564 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007565 { } /* end */
7566};
7567
Takashi Iwai0724ea22007-08-23 00:31:43 +02007568/* bind hp and internal speaker mute (with plug check) */
7569static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7570 struct snd_ctl_elem_value *ucontrol)
7571{
7572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7573 long *valp = ucontrol->value.integer.value;
7574 int change;
7575
7576 /* change hp mute */
7577 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7578 HDA_AMP_MUTE,
7579 valp[0] ? 0 : HDA_AMP_MUTE);
7580 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7581 HDA_AMP_MUTE,
7582 valp[1] ? 0 : HDA_AMP_MUTE);
7583 if (change) {
7584 /* change speaker according to HP jack state */
7585 struct alc_spec *spec = codec->spec;
7586 unsigned int mute;
7587 if (spec->jack_present)
7588 mute = HDA_AMP_MUTE;
7589 else
7590 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
7591 HDA_OUTPUT, 0);
7592 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7593 HDA_AMP_MUTE, mute);
7594 }
7595 return change;
7596}
Takashi Iwai5b319542007-07-26 11:49:22 +02007597
Kailang Yang272a5272007-05-14 11:00:38 +02007598static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02007599 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7600 {
7601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7602 .name = "Master Playback Switch",
7603 .info = snd_hda_mixer_amp_switch_info,
7604 .get = snd_hda_mixer_amp_switch_get,
7605 .put = alc262_sony_master_sw_put,
7606 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7607 },
Kailang Yang272a5272007-05-14 11:00:38 +02007608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7610 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7611 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7612 { } /* end */
7613};
7614
Kailang Yang83c34212007-07-05 11:43:05 +02007615static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7616 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7617 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7621 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7622 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7623 { } /* end */
7624};
Kailang Yang272a5272007-05-14 11:00:38 +02007625
Kailang Yangdf694da2005-12-05 19:42:22 +01007626#define alc262_capture_mixer alc882_capture_mixer
7627#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7628
7629/*
7630 * generic initialization of ADC, input mixers and output mixers
7631 */
7632static struct hda_verb alc262_init_verbs[] = {
7633 /*
7634 * Unmute ADC0-2 and set the default input to mic-in
7635 */
7636 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7638 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7639 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7640 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7642
Takashi Iwaicb53c622007-08-10 17:21:45 +02007643 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007644 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007645 * Note: PASD motherboards uses the Line In 2 as the input for
7646 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007647 */
7648 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007654
7655 /*
7656 * Set up output mixers (0x0c - 0x0e)
7657 */
7658 /* set vol=0 to output mixers */
7659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7662 /* set up input amps for analog loopback */
7663 /* Amp Indices: DAC = 0, mixer = 1 */
7664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7666 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7667 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7669 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7670
7671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7674 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7675 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7677
7678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7682 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7683
7684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7686
7687 /* FIXME: use matrix-type input source selection */
7688 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7689 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7694 /* Input mixer2 */
7695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7696 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7699 /* Input mixer3 */
7700 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7701 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7702 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007703 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007704
7705 { }
7706};
7707
Kailang Yangccc656c2006-10-17 12:32:26 +02007708static struct hda_verb alc262_hippo_unsol_verbs[] = {
7709 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7711 {}
7712};
7713
7714static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7716 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7718
7719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7721 {}
7722};
7723
Kailang Yang272a5272007-05-14 11:00:38 +02007724static struct hda_verb alc262_sony_unsol_verbs[] = {
7725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7726 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7727 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7728
7729 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7731};
7732
Kailang Yangccc656c2006-10-17 12:32:26 +02007733/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007734static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007735{
7736 struct alc_spec *spec = codec->spec;
7737 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007738 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007739
Takashi Iwai5b319542007-07-26 11:49:22 +02007740 /* need to execute and sync at first */
7741 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7742 present = snd_hda_codec_read(codec, 0x15, 0,
7743 AC_VERB_GET_PIN_SENSE, 0);
7744 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007745 if (spec->jack_present) {
7746 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007747 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7748 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007749 } else {
7750 /* unmute internal speaker if necessary */
7751 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007752 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7753 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007754 }
7755}
7756
7757/* unsolicited event for HP jack sensing */
7758static void alc262_hippo_unsol_event(struct hda_codec *codec,
7759 unsigned int res)
7760{
7761 if ((res >> 26) != ALC880_HP_EVENT)
7762 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007763 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007764}
7765
Takashi Iwai5b319542007-07-26 11:49:22 +02007766static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007767{
Kailang Yangccc656c2006-10-17 12:32:26 +02007768 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007769 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007770
Takashi Iwai5b319542007-07-26 11:49:22 +02007771 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7772 present = snd_hda_codec_read(codec, 0x1b, 0,
7773 AC_VERB_GET_PIN_SENSE, 0);
7774 present = (present & 0x80000000) != 0;
7775 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007776 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007777 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7778 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007779 } else {
7780 /* unmute internal speaker if necessary */
7781 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007782 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7783 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007784 }
7785}
7786
7787/* unsolicited event for HP jack sensing */
7788static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7789 unsigned int res)
7790{
7791 if ((res >> 26) != ALC880_HP_EVENT)
7792 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007793 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007794}
7795
Takashi Iwai834be882006-03-01 14:16:17 +01007796/*
7797 * fujitsu model
7798 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7799 */
7800
7801#define ALC_HP_EVENT 0x37
7802
7803static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7804 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7805 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7806 {}
7807};
7808
7809static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02007810 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01007811 .items = {
7812 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02007813 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01007814 { "CD", 0x4 },
7815 },
7816};
7817
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007818static struct hda_input_mux alc262_HP_capture_source = {
7819 .num_items = 5,
7820 .items = {
7821 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02007822 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007823 { "Line", 0x2 },
7824 { "CD", 0x4 },
7825 { "AUX IN", 0x6 },
7826 },
7827};
7828
zhejiangaccbe492007-08-31 12:36:05 +02007829static struct hda_input_mux alc262_HP_D7000_capture_source = {
7830 .num_items = 4,
7831 .items = {
7832 { "Mic", 0x0 },
7833 { "Front Mic", 0x2 },
7834 { "Line", 0x1 },
7835 { "CD", 0x4 },
7836 },
7837};
7838
Takashi Iwai834be882006-03-01 14:16:17 +01007839/* mute/unmute internal speaker according to the hp jack and mute state */
7840static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7841{
7842 struct alc_spec *spec = codec->spec;
7843 unsigned int mute;
7844
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007845 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007846 unsigned int present;
7847 /* need to execute and sync at first */
7848 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7849 present = snd_hda_codec_read(codec, 0x14, 0,
7850 AC_VERB_GET_PIN_SENSE, 0);
7851 spec->jack_present = (present & 0x80000000) != 0;
7852 spec->sense_updated = 1;
7853 }
7854 if (spec->jack_present) {
7855 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007856 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7857 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007858 } else {
7859 /* unmute internal speaker if necessary */
7860 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007861 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7862 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01007863 }
7864}
7865
7866/* unsolicited event for HP jack sensing */
7867static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7868 unsigned int res)
7869{
7870 if ((res >> 26) != ALC_HP_EVENT)
7871 return;
7872 alc262_fujitsu_automute(codec, 1);
7873}
7874
7875/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02007876static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7877 .ops = &snd_hda_bind_vol,
7878 .values = {
7879 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7880 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7881 0
7882 },
7883};
Takashi Iwai834be882006-03-01 14:16:17 +01007884
7885/* bind hp and internal speaker mute (with plug check) */
7886static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7887 struct snd_ctl_elem_value *ucontrol)
7888{
7889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7890 long *valp = ucontrol->value.integer.value;
7891 int change;
7892
7893 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007894 HDA_AMP_MUTE,
7895 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007896 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007897 HDA_AMP_MUTE,
7898 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007899 if (change)
7900 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01007901 return change;
7902}
7903
7904static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02007905 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01007906 {
7907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7908 .name = "Master Playback Switch",
7909 .info = snd_hda_mixer_amp_switch_info,
7910 .get = snd_hda_mixer_amp_switch_get,
7911 .put = alc262_fujitsu_master_sw_put,
7912 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7913 },
7914 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7915 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02007919 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7920 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7921 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01007922 { } /* end */
7923};
7924
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007925/* additional init verbs for Benq laptops */
7926static struct hda_verb alc262_EAPD_verbs[] = {
7927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7928 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7929 {}
7930};
7931
Kailang Yang83c34212007-07-05 11:43:05 +02007932static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7933 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7935
7936 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7937 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7938 {}
7939};
7940
Kailang Yangdf694da2005-12-05 19:42:22 +01007941/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007942static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7943 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007944{
7945 hda_nid_t nid;
7946 int err;
7947
7948 spec->multiout.num_dacs = 1; /* only use one dac */
7949 spec->multiout.dac_nids = spec->private_dac_nids;
7950 spec->multiout.dac_nids[0] = 2;
7951
7952 nid = cfg->line_out_pins[0];
7953 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007954 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7955 "Front Playback Volume",
7956 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7957 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007958 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007959 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7960 "Front Playback Switch",
7961 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7962 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007963 return err;
7964 }
7965
Takashi Iwai82bc9552006-03-21 11:24:42 +01007966 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007967 if (nid) {
7968 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007969 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7970 "Speaker Playback Volume",
7971 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7972 HDA_OUTPUT));
7973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007974 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007975 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7976 "Speaker Playback Switch",
7977 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7978 HDA_OUTPUT));
7979 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007980 return err;
7981 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007982 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7983 "Speaker Playback Switch",
7984 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7985 HDA_OUTPUT));
7986 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007987 return err;
7988 }
7989 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007990 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007991 if (nid) {
7992 /* spec->multiout.hp_nid = 2; */
7993 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007994 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7995 "Headphone Playback Volume",
7996 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7997 HDA_OUTPUT));
7998 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007999 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008000 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8001 "Headphone Playback Switch",
8002 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8003 HDA_OUTPUT));
8004 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008005 return err;
8006 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008007 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8008 "Headphone Playback Switch",
8009 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8010 HDA_OUTPUT));
8011 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008012 return err;
8013 }
8014 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008015 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01008016}
8017
8018/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008019#define alc262_auto_create_analog_input_ctls \
8020 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01008021
8022/*
8023 * generic initialization of ADC, input mixers and output mixers
8024 */
8025static struct hda_verb alc262_volume_init_verbs[] = {
8026 /*
8027 * Unmute ADC0-2 and set the default input to mic-in
8028 */
8029 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8033 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8034 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8035
Takashi Iwaicb53c622007-08-10 17:21:45 +02008036 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008037 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008038 * Note: PASD motherboards uses the Line In 2 as the input for
8039 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008040 */
8041 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008047
8048 /*
8049 * Set up output mixers (0x0c - 0x0f)
8050 */
8051 /* set vol=0 to output mixers */
8052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8055
8056 /* set up input amps for analog loopback */
8057 /* Amp Indices: DAC = 0, mixer = 1 */
8058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8064
8065 /* FIXME: use matrix-type input source selection */
8066 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8067 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8072 /* Input mixer2 */
8073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8077 /* Input mixer3 */
8078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8082
8083 { }
8084};
8085
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008086static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8087 /*
8088 * Unmute ADC0-2 and set the default input to mic-in
8089 */
8090 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8092 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8093 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8094 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8095 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8096
Takashi Iwaicb53c622007-08-10 17:21:45 +02008097 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008098 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008099 * Note: PASD motherboards uses the Line In 2 as the input for
8100 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008101 */
8102 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008110
8111 /*
8112 * Set up output mixers (0x0c - 0x0e)
8113 */
8114 /* set vol=0 to output mixers */
8115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8118
8119 /* set up input amps for analog loopback */
8120 /* Amp Indices: DAC = 0, mixer = 1 */
8121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8126 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8127
8128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8129 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8130 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8131
8132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8134
8135 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8137
8138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8140 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8143
8144 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8148 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8149 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8150
8151
8152 /* FIXME: use matrix-type input source selection */
8153 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8154 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8159 /* Input mixer2 */
8160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8164 /* Input mixer3 */
8165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8167 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8169
8170 { }
8171};
8172
Kailang Yangcd7509a2007-01-26 18:33:17 +01008173static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8174 /*
8175 * Unmute ADC0-2 and set the default input to mic-in
8176 */
8177 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8178 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8179 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8180 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8181 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8182 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183
Takashi Iwaicb53c622007-08-10 17:21:45 +02008184 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008185 * mixer widget
8186 * Note: PASD motherboards uses the Line In 2 as the input for front
8187 * panel mic (mic 2)
8188 */
8189 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8196 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008198 /*
8199 * Set up output mixers (0x0c - 0x0e)
8200 */
8201 /* set vol=0 to output mixers */
8202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8204 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8205
8206 /* set up input amps for analog loopback */
8207 /* Amp Indices: DAC = 0, mixer = 1 */
8208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8213 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8214
8215
8216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8219 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8220 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8222 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8223
8224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8226
8227 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8229
8230 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8234 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8235 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8236
8237 /* FIXME: use matrix-type input source selection */
8238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8239 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8245 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8247 /* Input mixer2 */
8248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8253 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8254 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8255 /* Input mixer3 */
8256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8261 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8263
8264 { }
8265};
8266
Takashi Iwaicb53c622007-08-10 17:21:45 +02008267#ifdef CONFIG_SND_HDA_POWER_SAVE
8268#define alc262_loopbacks alc880_loopbacks
8269#endif
8270
Kailang Yangdf694da2005-12-05 19:42:22 +01008271/* pcm configuration: identiacal with ALC880 */
8272#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8273#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8274#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8275#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8276
8277/*
8278 * BIOS auto configuration
8279 */
8280static int alc262_parse_auto_config(struct hda_codec *codec)
8281{
8282 struct alc_spec *spec = codec->spec;
8283 int err;
8284 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8285
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008286 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8287 alc262_ignore);
8288 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008289 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008290 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008291 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008292 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8293 if (err < 0)
8294 return err;
8295 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8296 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008297 return err;
8298
8299 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8300
8301 if (spec->autocfg.dig_out_pin)
8302 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8303 if (spec->autocfg.dig_in_pin)
8304 spec->dig_in_nid = ALC262_DIGIN_NID;
8305
8306 if (spec->kctl_alloc)
8307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8308
8309 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008310 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008311 spec->input_mux = &spec->private_imux;
8312
Takashi Iwai776e1842007-08-29 15:07:11 +02008313 err = alc_auto_add_mic_boost(codec);
8314 if (err < 0)
8315 return err;
8316
Kailang Yangdf694da2005-12-05 19:42:22 +01008317 return 1;
8318}
8319
8320#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8321#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8322#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8323
8324
8325/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008326static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008327{
Kailang Yangdf694da2005-12-05 19:42:22 +01008328 alc262_auto_init_multi_out(codec);
8329 alc262_auto_init_hp_out(codec);
8330 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008331}
8332
8333/*
8334 * configuration and preset
8335 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008336static const char *alc262_models[ALC262_MODEL_LAST] = {
8337 [ALC262_BASIC] = "basic",
8338 [ALC262_HIPPO] = "hippo",
8339 [ALC262_HIPPO_1] = "hippo_1",
8340 [ALC262_FUJITSU] = "fujitsu",
8341 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008342 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008343 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008344 [ALC262_BENQ_T31] = "benq-t31",
8345 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008346 [ALC262_AUTO] = "auto",
8347};
8348
8349static struct snd_pci_quirk alc262_cfg_tbl[] = {
8350 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8351 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8352 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008353 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8354 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008355 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008356 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008357 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008358 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008359 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8360 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8361 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8362 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8363 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8364 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8365 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8366 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008367 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8368 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8369 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8370 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02008371 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02008372 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02008373 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8374 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8375 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01008376 {}
8377};
8378
8379static struct alc_config_preset alc262_presets[] = {
8380 [ALC262_BASIC] = {
8381 .mixers = { alc262_base_mixer },
8382 .init_verbs = { alc262_init_verbs },
8383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8384 .dac_nids = alc262_dac_nids,
8385 .hp_nid = 0x03,
8386 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8387 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01008388 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008389 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008390 [ALC262_HIPPO] = {
8391 .mixers = { alc262_base_mixer },
8392 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8393 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8394 .dac_nids = alc262_dac_nids,
8395 .hp_nid = 0x03,
8396 .dig_out_nid = ALC262_DIGOUT_NID,
8397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8398 .channel_mode = alc262_modes,
8399 .input_mux = &alc262_capture_source,
8400 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008401 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008402 },
8403 [ALC262_HIPPO_1] = {
8404 .mixers = { alc262_hippo1_mixer },
8405 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8407 .dac_nids = alc262_dac_nids,
8408 .hp_nid = 0x02,
8409 .dig_out_nid = ALC262_DIGOUT_NID,
8410 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8411 .channel_mode = alc262_modes,
8412 .input_mux = &alc262_capture_source,
8413 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008414 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008415 },
Takashi Iwai834be882006-03-01 14:16:17 +01008416 [ALC262_FUJITSU] = {
8417 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02008418 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
8419 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +01008420 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8421 .dac_nids = alc262_dac_nids,
8422 .hp_nid = 0x03,
8423 .dig_out_nid = ALC262_DIGOUT_NID,
8424 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8425 .channel_mode = alc262_modes,
8426 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008427 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008428 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008429 [ALC262_HP_BPC] = {
8430 .mixers = { alc262_HP_BPC_mixer },
8431 .init_verbs = { alc262_HP_BPC_init_verbs },
8432 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8433 .dac_nids = alc262_dac_nids,
8434 .hp_nid = 0x03,
8435 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8436 .channel_mode = alc262_modes,
8437 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008438 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008439 [ALC262_HP_BPC_D7000_WF] = {
8440 .mixers = { alc262_HP_BPC_WildWest_mixer },
8441 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8442 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8443 .dac_nids = alc262_dac_nids,
8444 .hp_nid = 0x03,
8445 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8446 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008447 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008448 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008449 [ALC262_HP_BPC_D7000_WL] = {
8450 .mixers = { alc262_HP_BPC_WildWest_mixer,
8451 alc262_HP_BPC_WildWest_option_mixer },
8452 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8453 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8454 .dac_nids = alc262_dac_nids,
8455 .hp_nid = 0x03,
8456 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8457 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +02008458 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008459 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008460 [ALC262_BENQ_ED8] = {
8461 .mixers = { alc262_base_mixer },
8462 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8463 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8464 .dac_nids = alc262_dac_nids,
8465 .hp_nid = 0x03,
8466 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8467 .channel_mode = alc262_modes,
8468 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008469 },
Kailang Yang272a5272007-05-14 11:00:38 +02008470 [ALC262_SONY_ASSAMD] = {
8471 .mixers = { alc262_sony_mixer },
8472 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8473 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8474 .dac_nids = alc262_dac_nids,
8475 .hp_nid = 0x02,
8476 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8477 .channel_mode = alc262_modes,
8478 .input_mux = &alc262_capture_source,
8479 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008480 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008481 },
8482 [ALC262_BENQ_T31] = {
8483 .mixers = { alc262_benq_t31_mixer },
8484 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8485 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8486 .dac_nids = alc262_dac_nids,
8487 .hp_nid = 0x03,
8488 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8489 .channel_mode = alc262_modes,
8490 .input_mux = &alc262_capture_source,
8491 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008492 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008493 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008494};
8495
8496static int patch_alc262(struct hda_codec *codec)
8497{
8498 struct alc_spec *spec;
8499 int board_config;
8500 int err;
8501
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008502 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008503 if (spec == NULL)
8504 return -ENOMEM;
8505
8506 codec->spec = spec;
8507#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008508 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8509 * under-run
8510 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008511 {
8512 int tmp;
8513 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8514 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8515 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8516 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8517 }
8518#endif
8519
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008520 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8521 alc262_models,
8522 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008523
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008524 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008525 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8526 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008527 board_config = ALC262_AUTO;
8528 }
8529
8530 if (board_config == ALC262_AUTO) {
8531 /* automatic parse from the BIOS config */
8532 err = alc262_parse_auto_config(codec);
8533 if (err < 0) {
8534 alc_free(codec);
8535 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008536 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008537 printk(KERN_INFO
8538 "hda_codec: Cannot set up configuration "
8539 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008540 board_config = ALC262_BASIC;
8541 }
8542 }
8543
8544 if (board_config != ALC262_AUTO)
8545 setup_preset(spec, &alc262_presets[board_config]);
8546
8547 spec->stream_name_analog = "ALC262 Analog";
8548 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8549 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8550
8551 spec->stream_name_digital = "ALC262 Digital";
8552 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8553 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008555 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008556 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008557 unsigned int wcap = get_wcaps(codec, 0x07);
8558
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008559 /* get type */
8560 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008561 if (wcap != AC_WID_AUD_IN) {
8562 spec->adc_nids = alc262_adc_nids_alt;
8563 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008564 spec->mixers[spec->num_mixers] =
8565 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008566 spec->num_mixers++;
8567 } else {
8568 spec->adc_nids = alc262_adc_nids;
8569 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8570 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8571 spec->num_mixers++;
8572 }
8573 }
8574
8575 codec->patch_ops = alc_patch_ops;
8576 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008577 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008578#ifdef CONFIG_SND_HDA_POWER_SAVE
8579 if (!spec->loopback.amplist)
8580 spec->loopback.amplist = alc262_loopbacks;
8581#endif
Takashi Iwai834be882006-03-01 14:16:17 +01008582
Kailang Yangdf694da2005-12-05 19:42:22 +01008583 return 0;
8584}
8585
Kailang Yangdf694da2005-12-05 19:42:22 +01008586/*
Kailang Yanga361d842007-06-05 12:30:55 +02008587 * ALC268 channel source setting (2 channel)
8588 */
8589#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8590#define alc268_modes alc260_modes
8591
8592static hda_nid_t alc268_dac_nids[2] = {
8593 /* front, hp */
8594 0x02, 0x03
8595};
8596
8597static hda_nid_t alc268_adc_nids[2] = {
8598 /* ADC0-1 */
8599 0x08, 0x07
8600};
8601
8602static hda_nid_t alc268_adc_nids_alt[1] = {
8603 /* ADC0 */
8604 0x08
8605};
8606
8607static struct snd_kcontrol_new alc268_base_mixer[] = {
8608 /* output mixer control */
8609 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8610 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8611 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +02008613 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8614 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8615 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +02008616 { }
8617};
8618
Kailang Yangd1a991a2007-08-15 16:21:59 +02008619static struct hda_verb alc268_eapd_verbs[] = {
8620 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8621 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8622 { }
8623};
8624
Takashi Iwaid2738092007-08-16 14:59:45 +02008625/* Toshiba specific */
8626#define alc268_toshiba_automute alc262_hippo_automute
8627
8628static struct hda_verb alc268_toshiba_verbs[] = {
8629 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8630 { } /* end */
8631};
8632
8633/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +02008634/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +02008635static struct hda_bind_ctls alc268_acer_bind_master_vol = {
8636 .ops = &snd_hda_bind_vol,
8637 .values = {
8638 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
8639 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
8640 0
8641 },
8642};
8643
Takashi Iwai889c4392007-08-23 18:56:52 +02008644/* mute/unmute internal speaker according to the hp jack and mute state */
8645static void alc268_acer_automute(struct hda_codec *codec, int force)
8646{
8647 struct alc_spec *spec = codec->spec;
8648 unsigned int mute;
8649
8650 if (force || !spec->sense_updated) {
8651 unsigned int present;
8652 present = snd_hda_codec_read(codec, 0x14, 0,
8653 AC_VERB_GET_PIN_SENSE, 0);
8654 spec->jack_present = (present & 0x80000000) != 0;
8655 spec->sense_updated = 1;
8656 }
8657 if (spec->jack_present)
8658 mute = HDA_AMP_MUTE; /* mute internal speaker */
8659 else /* unmute internal speaker if necessary */
8660 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8661 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8662 HDA_AMP_MUTE, mute);
8663}
8664
8665
8666/* bind hp and internal speaker mute (with plug check) */
8667static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
8668 struct snd_ctl_elem_value *ucontrol)
8669{
8670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8671 long *valp = ucontrol->value.integer.value;
8672 int change;
8673
8674 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8675 HDA_AMP_MUTE,
8676 valp[0] ? 0 : HDA_AMP_MUTE);
8677 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8678 HDA_AMP_MUTE,
8679 valp[1] ? 0 : HDA_AMP_MUTE);
8680 if (change)
8681 alc268_acer_automute(codec, 0);
8682 return change;
8683}
Takashi Iwaid2738092007-08-16 14:59:45 +02008684
8685static struct snd_kcontrol_new alc268_acer_mixer[] = {
8686 /* output mixer control */
8687 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8688 {
8689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8690 .name = "Master Playback Switch",
8691 .info = snd_hda_mixer_amp_switch_info,
8692 .get = snd_hda_mixer_amp_switch_get,
8693 .put = alc268_acer_master_sw_put,
8694 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8695 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +02008696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
8698 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +02008699 { }
8700};
8701
8702static struct hda_verb alc268_acer_verbs[] = {
8703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8705
8706 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8707 { }
8708};
8709
8710/* unsolicited event for HP jack sensing */
8711static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8712 unsigned int res)
8713{
Takashi Iwai889c4392007-08-23 18:56:52 +02008714 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02008715 return;
8716 alc268_toshiba_automute(codec);
8717}
8718
8719static void alc268_acer_unsol_event(struct hda_codec *codec,
8720 unsigned int res)
8721{
Takashi Iwai889c4392007-08-23 18:56:52 +02008722 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +02008723 return;
8724 alc268_acer_automute(codec, 1);
8725}
8726
Takashi Iwai889c4392007-08-23 18:56:52 +02008727static void alc268_acer_init_hook(struct hda_codec *codec)
8728{
8729 alc268_acer_automute(codec, 1);
8730}
8731
Kailang Yanga361d842007-06-05 12:30:55 +02008732/*
8733 * generic initialization of ADC, input mixers and output mixers
8734 */
8735static struct hda_verb alc268_base_init_verbs[] = {
8736 /* Unmute DAC0-1 and set vol = 0 */
8737 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8738 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8741 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8743
8744 /*
8745 * Set up output mixers (0x0c - 0x0e)
8746 */
8747 /* set vol=0 to output mixers */
8748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8751 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8752
8753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8754 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8755
8756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8762 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8763 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8764
8765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8771 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8772 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8773
8774 /* FIXME: use matrix-type input source selection */
8775 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8776 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8777 /* Input mixer2 */
8778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8782
8783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8787 { }
8788};
8789
8790/*
8791 * generic initialization of ADC, input mixers and output mixers
8792 */
8793static struct hda_verb alc268_volume_init_verbs[] = {
8794 /* set output DAC */
8795 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8796 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8797 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8798 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8799
8800 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8802 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8804 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8805
8806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8809 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8810 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8811
8812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8815 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8816
8817 /* set PCBEEP vol = 0 */
8818 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8819
8820 { }
8821};
8822
8823#define alc268_mux_enum_info alc_mux_enum_info
8824#define alc268_mux_enum_get alc_mux_enum_get
8825
8826static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8827 struct snd_ctl_elem_value *ucontrol)
8828{
8829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8830 struct alc_spec *spec = codec->spec;
8831 const struct hda_input_mux *imux = spec->input_mux;
8832 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8833 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8834 hda_nid_t nid = capture_mixers[adc_idx];
8835 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8836 unsigned int i, idx;
8837
8838 idx = ucontrol->value.enumerated.item[0];
8839 if (idx >= imux->num_items)
8840 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008841 if (*cur_val == idx)
Kailang Yanga361d842007-06-05 12:30:55 +02008842 return 0;
8843 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02008844 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8845 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8846 imux->items[i].index,
8847 HDA_AMP_MUTE, v);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008848 snd_hda_codec_write_cache(codec, nid, 0,
8849 AC_VERB_SET_CONNECT_SEL,
8850 idx );
Kailang Yanga361d842007-06-05 12:30:55 +02008851 }
8852 *cur_val = idx;
8853 return 1;
8854}
8855
8856static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8857 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8858 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8859 {
8860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8861 /* The multiple "Capture Source" controls confuse alsamixer
8862 * So call somewhat different..
8863 * FIXME: the controls appear in the "playback" view!
8864 */
8865 /* .name = "Capture Source", */
8866 .name = "Input Source",
8867 .count = 1,
8868 .info = alc268_mux_enum_info,
8869 .get = alc268_mux_enum_get,
8870 .put = alc268_mux_enum_put,
8871 },
8872 { } /* end */
8873};
8874
8875static struct snd_kcontrol_new alc268_capture_mixer[] = {
8876 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8877 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8878 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8879 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8880 {
8881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8882 /* The multiple "Capture Source" controls confuse alsamixer
8883 * So call somewhat different..
8884 * FIXME: the controls appear in the "playback" view!
8885 */
8886 /* .name = "Capture Source", */
8887 .name = "Input Source",
8888 .count = 2,
8889 .info = alc268_mux_enum_info,
8890 .get = alc268_mux_enum_get,
8891 .put = alc268_mux_enum_put,
8892 },
8893 { } /* end */
8894};
8895
8896static struct hda_input_mux alc268_capture_source = {
8897 .num_items = 4,
8898 .items = {
8899 { "Mic", 0x0 },
8900 { "Front Mic", 0x1 },
8901 { "Line", 0x2 },
8902 { "CD", 0x3 },
8903 },
8904};
8905
8906/* create input playback/capture controls for the given pin */
8907static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8908 const char *ctlname, int idx)
8909{
8910 char name[32];
8911 int err;
8912
8913 sprintf(name, "%s Playback Volume", ctlname);
8914 if (nid == 0x14) {
8915 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8916 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8917 HDA_OUTPUT));
8918 if (err < 0)
8919 return err;
8920 } else if (nid == 0x15) {
8921 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8922 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8923 HDA_OUTPUT));
8924 if (err < 0)
8925 return err;
8926 } else
8927 return -1;
8928 sprintf(name, "%s Playback Switch", ctlname);
8929 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8930 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8931 if (err < 0)
8932 return err;
8933 return 0;
8934}
8935
8936/* add playback controls from the parsed DAC table */
8937static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8938 const struct auto_pin_cfg *cfg)
8939{
8940 hda_nid_t nid;
8941 int err;
8942
8943 spec->multiout.num_dacs = 2; /* only use one dac */
8944 spec->multiout.dac_nids = spec->private_dac_nids;
8945 spec->multiout.dac_nids[0] = 2;
8946 spec->multiout.dac_nids[1] = 3;
8947
8948 nid = cfg->line_out_pins[0];
8949 if (nid)
8950 alc268_new_analog_output(spec, nid, "Front", 0);
8951
8952 nid = cfg->speaker_pins[0];
8953 if (nid == 0x1d) {
8954 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8955 "Speaker Playback Volume",
8956 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8957 if (err < 0)
8958 return err;
8959 }
8960 nid = cfg->hp_pins[0];
8961 if (nid)
8962 alc268_new_analog_output(spec, nid, "Headphone", 0);
8963
8964 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8965 if (nid == 0x16) {
8966 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8967 "Mono Playback Switch",
8968 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8969 if (err < 0)
8970 return err;
8971 }
8972 return 0;
8973}
8974
8975/* create playback/capture controls for input pins */
8976static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8977 const struct auto_pin_cfg *cfg)
8978{
8979 struct hda_input_mux *imux = &spec->private_imux;
8980 int i, idx1;
8981
8982 for (i = 0; i < AUTO_PIN_LAST; i++) {
8983 switch(cfg->input_pins[i]) {
8984 case 0x18:
8985 idx1 = 0; /* Mic 1 */
8986 break;
8987 case 0x19:
8988 idx1 = 1; /* Mic 2 */
8989 break;
8990 case 0x1a:
8991 idx1 = 2; /* Line In */
8992 break;
8993 case 0x1c:
8994 idx1 = 3; /* CD */
8995 break;
8996 default:
8997 continue;
8998 }
8999 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9000 imux->items[imux->num_items].index = idx1;
9001 imux->num_items++;
9002 }
9003 return 0;
9004}
9005
9006static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9007{
9008 struct alc_spec *spec = codec->spec;
9009 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9010 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9011 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9012 unsigned int dac_vol1, dac_vol2;
9013
9014 if (speaker_nid) {
9015 snd_hda_codec_write(codec, speaker_nid, 0,
9016 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9017 snd_hda_codec_write(codec, 0x0f, 0,
9018 AC_VERB_SET_AMP_GAIN_MUTE,
9019 AMP_IN_UNMUTE(1));
9020 snd_hda_codec_write(codec, 0x10, 0,
9021 AC_VERB_SET_AMP_GAIN_MUTE,
9022 AMP_IN_UNMUTE(1));
9023 } else {
9024 snd_hda_codec_write(codec, 0x0f, 0,
9025 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9026 snd_hda_codec_write(codec, 0x10, 0,
9027 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9028 }
9029
9030 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9031 if (line_nid == 0x14)
9032 dac_vol2 = AMP_OUT_ZERO;
9033 else if (line_nid == 0x15)
9034 dac_vol1 = AMP_OUT_ZERO;
9035 if (hp_nid == 0x14)
9036 dac_vol2 = AMP_OUT_ZERO;
9037 else if (hp_nid == 0x15)
9038 dac_vol1 = AMP_OUT_ZERO;
9039 if (line_nid != 0x16 || hp_nid != 0x16 ||
9040 spec->autocfg.line_out_pins[1] != 0x16 ||
9041 spec->autocfg.line_out_pins[2] != 0x16)
9042 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9043
9044 snd_hda_codec_write(codec, 0x02, 0,
9045 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9046 snd_hda_codec_write(codec, 0x03, 0,
9047 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9048}
9049
9050/* pcm configuration: identiacal with ALC880 */
9051#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9052#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9053#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9054
9055/*
9056 * BIOS auto configuration
9057 */
9058static int alc268_parse_auto_config(struct hda_codec *codec)
9059{
9060 struct alc_spec *spec = codec->spec;
9061 int err;
9062 static hda_nid_t alc268_ignore[] = { 0 };
9063
9064 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9065 alc268_ignore);
9066 if (err < 0)
9067 return err;
9068 if (!spec->autocfg.line_outs)
9069 return 0; /* can't find valid BIOS pin config */
9070
9071 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9072 if (err < 0)
9073 return err;
9074 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9075 if (err < 0)
9076 return err;
9077
9078 spec->multiout.max_channels = 2;
9079
9080 /* digital only support output */
9081 if (spec->autocfg.dig_out_pin)
9082 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9083
9084 if (spec->kctl_alloc)
9085 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9086
9087 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9088 spec->num_mux_defs = 1;
9089 spec->input_mux = &spec->private_imux;
9090
Takashi Iwai776e1842007-08-29 15:07:11 +02009091 err = alc_auto_add_mic_boost(codec);
9092 if (err < 0)
9093 return err;
9094
Kailang Yanga361d842007-06-05 12:30:55 +02009095 return 1;
9096}
9097
9098#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9099#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9100#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9101
9102/* init callback for auto-configuration model -- overriding the default init */
9103static void alc268_auto_init(struct hda_codec *codec)
9104{
9105 alc268_auto_init_multi_out(codec);
9106 alc268_auto_init_hp_out(codec);
9107 alc268_auto_init_mono_speaker_out(codec);
9108 alc268_auto_init_analog_input(codec);
9109}
9110
9111/*
9112 * configuration and preset
9113 */
9114static const char *alc268_models[ALC268_MODEL_LAST] = {
9115 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02009116 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02009117 [ALC268_ACER] = "acer",
Kailang Yanga361d842007-06-05 12:30:55 +02009118 [ALC268_AUTO] = "auto",
9119};
9120
9121static struct snd_pci_quirk alc268_cfg_tbl[] = {
9122 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009123 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +02009124 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Takashi Iwaid2738092007-08-16 14:59:45 +02009125 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9126 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Takashi Iwai889c4392007-08-23 18:56:52 +02009127 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Takashi Iwaib875bf32007-09-06 15:00:27 +02009128 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02009129 {}
9130};
9131
9132static struct alc_config_preset alc268_presets[] = {
9133 [ALC268_3ST] = {
9134 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9135 .init_verbs = { alc268_base_init_verbs },
9136 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9137 .dac_nids = alc268_dac_nids,
9138 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9139 .adc_nids = alc268_adc_nids_alt,
9140 .hp_nid = 0x03,
9141 .dig_out_nid = ALC268_DIGOUT_NID,
9142 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9143 .channel_mode = alc268_modes,
9144 .input_mux = &alc268_capture_source,
9145 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009146 [ALC268_TOSHIBA] = {
9147 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02009148 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9149 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009150 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9151 .dac_nids = alc268_dac_nids,
9152 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9153 .adc_nids = alc268_adc_nids_alt,
9154 .hp_nid = 0x03,
9155 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9156 .channel_mode = alc268_modes,
9157 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02009158 .input_mux = &alc268_capture_source,
9159 .unsol_event = alc268_toshiba_unsol_event,
9160 .init_hook = alc268_toshiba_automute,
9161 },
9162 [ALC268_ACER] = {
9163 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9164 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9165 alc268_acer_verbs },
9166 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9167 .dac_nids = alc268_dac_nids,
9168 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9169 .adc_nids = alc268_adc_nids_alt,
9170 .hp_nid = 0x02,
9171 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9172 .channel_mode = alc268_modes,
9173 .input_mux = &alc268_capture_source,
9174 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +02009175 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009176 },
Kailang Yanga361d842007-06-05 12:30:55 +02009177};
9178
9179static int patch_alc268(struct hda_codec *codec)
9180{
9181 struct alc_spec *spec;
9182 int board_config;
9183 int err;
9184
9185 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9186 if (spec == NULL)
9187 return -ENOMEM;
9188
9189 codec->spec = spec;
9190
9191 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9192 alc268_models,
9193 alc268_cfg_tbl);
9194
9195 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9196 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9197 "trying auto-probe from BIOS...\n");
9198 board_config = ALC268_AUTO;
9199 }
9200
9201 if (board_config == ALC268_AUTO) {
9202 /* automatic parse from the BIOS config */
9203 err = alc268_parse_auto_config(codec);
9204 if (err < 0) {
9205 alc_free(codec);
9206 return err;
9207 } else if (!err) {
9208 printk(KERN_INFO
9209 "hda_codec: Cannot set up configuration "
9210 "from BIOS. Using base mode...\n");
9211 board_config = ALC268_3ST;
9212 }
9213 }
9214
9215 if (board_config != ALC268_AUTO)
9216 setup_preset(spec, &alc268_presets[board_config]);
9217
9218 spec->stream_name_analog = "ALC268 Analog";
9219 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9220 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9221
9222 spec->stream_name_digital = "ALC268 Digital";
9223 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9224
9225 if (board_config == ALC268_AUTO) {
9226 if (!spec->adc_nids && spec->input_mux) {
9227 /* check whether NID 0x07 is valid */
9228 unsigned int wcap = get_wcaps(codec, 0x07);
9229
9230 /* get type */
9231 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9232 if (wcap != AC_WID_AUD_IN) {
9233 spec->adc_nids = alc268_adc_nids_alt;
9234 spec->num_adc_nids =
9235 ARRAY_SIZE(alc268_adc_nids_alt);
9236 spec->mixers[spec->num_mixers] =
9237 alc268_capture_alt_mixer;
9238 spec->num_mixers++;
9239 } else {
9240 spec->adc_nids = alc268_adc_nids;
9241 spec->num_adc_nids =
9242 ARRAY_SIZE(alc268_adc_nids);
9243 spec->mixers[spec->num_mixers] =
9244 alc268_capture_mixer;
9245 spec->num_mixers++;
9246 }
9247 }
9248 }
9249 codec->patch_ops = alc_patch_ops;
9250 if (board_config == ALC268_AUTO)
9251 spec->init_hook = alc268_auto_init;
9252
9253 return 0;
9254}
9255
9256/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009257 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9258 */
9259
9260/*
9261 * set the path ways for 2 channel output
9262 * need to set the codec line out and mic 1 pin widgets to inputs
9263 */
9264static struct hda_verb alc861_threestack_ch2_init[] = {
9265 /* set pin widget 1Ah (line in) for input */
9266 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009267 /* set pin widget 18h (mic1/2) for input, for mic also enable
9268 * the vref
9269 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009270 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9271
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009272 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9273#if 0
9274 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9275 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9276#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01009277 { } /* end */
9278};
9279/*
9280 * 6ch mode
9281 * need to set the codec line out and mic 1 pin widgets to outputs
9282 */
9283static struct hda_verb alc861_threestack_ch6_init[] = {
9284 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9285 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9286 /* set pin widget 18h (mic1) for output (CLFE)*/
9287 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9288
9289 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009290 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009291
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009292 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9293#if 0
9294 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9295 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9296#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01009297 { } /* end */
9298};
9299
9300static struct hda_channel_mode alc861_threestack_modes[2] = {
9301 { 2, alc861_threestack_ch2_init },
9302 { 6, alc861_threestack_ch6_init },
9303};
Takashi Iwai22309c32006-08-09 16:57:28 +02009304/* Set mic1 as input and unmute the mixer */
9305static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
9306 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9308 { } /* end */
9309};
9310/* Set mic1 as output and mute mixer */
9311static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
9312 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9313 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9314 { } /* end */
9315};
9316
9317static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
9318 { 2, alc861_uniwill_m31_ch2_init },
9319 { 4, alc861_uniwill_m31_ch4_init },
9320};
Kailang Yangdf694da2005-12-05 19:42:22 +01009321
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009322/* Set mic1 and line-in as input and unmute the mixer */
9323static struct hda_verb alc861_asus_ch2_init[] = {
9324 /* set pin widget 1Ah (line in) for input */
9325 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009326 /* set pin widget 18h (mic1/2) for input, for mic also enable
9327 * the vref
9328 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009329 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9330
9331 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9332#if 0
9333 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9334 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9335#endif
9336 { } /* end */
9337};
9338/* Set mic1 nad line-in as output and mute mixer */
9339static struct hda_verb alc861_asus_ch6_init[] = {
9340 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9342 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9343 /* set pin widget 18h (mic1) for output (CLFE)*/
9344 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9345 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9346 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9347 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9348
9349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9350#if 0
9351 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9352 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9353#endif
9354 { } /* end */
9355};
9356
9357static struct hda_channel_mode alc861_asus_modes[2] = {
9358 { 2, alc861_asus_ch2_init },
9359 { 6, alc861_asus_ch6_init },
9360};
9361
Kailang Yangdf694da2005-12-05 19:42:22 +01009362/* patch-ALC861 */
9363
9364static struct snd_kcontrol_new alc861_base_mixer[] = {
9365 /* output mixer control */
9366 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9367 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9368 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9369 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9370 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9371
9372 /*Input mixer control */
9373 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9374 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9375 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9376 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9377 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9378 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9380 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9381 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009383
Kailang Yangdf694da2005-12-05 19:42:22 +01009384 /* Capture mixer control */
9385 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9386 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9387 {
9388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9389 .name = "Capture Source",
9390 .count = 1,
9391 .info = alc_mux_enum_info,
9392 .get = alc_mux_enum_get,
9393 .put = alc_mux_enum_put,
9394 },
9395 { } /* end */
9396};
9397
9398static struct snd_kcontrol_new alc861_3ST_mixer[] = {
9399 /* output mixer control */
9400 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9401 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9402 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9403 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9404 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9405
9406 /* Input mixer control */
9407 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9408 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9409 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9410 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9411 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9412 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9414 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9416 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009417
Kailang Yangdf694da2005-12-05 19:42:22 +01009418 /* Capture mixer control */
9419 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9420 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9421 {
9422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9423 .name = "Capture Source",
9424 .count = 1,
9425 .info = alc_mux_enum_info,
9426 .get = alc_mux_enum_get,
9427 .put = alc_mux_enum_put,
9428 },
9429 {
9430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9431 .name = "Channel Mode",
9432 .info = alc_ch_mode_info,
9433 .get = alc_ch_mode_get,
9434 .put = alc_ch_mode_put,
9435 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9436 },
9437 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009438};
9439
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009440static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009441 /* output mixer control */
9442 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9444 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9445
9446 /*Capture mixer control */
9447 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9448 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9449 {
9450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9451 .name = "Capture Source",
9452 .count = 1,
9453 .info = alc_mux_enum_info,
9454 .get = alc_mux_enum_get,
9455 .put = alc_mux_enum_put,
9456 },
9457
9458 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009459};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009460
Takashi Iwai22309c32006-08-09 16:57:28 +02009461static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9462 /* output mixer control */
9463 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9464 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9465 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9466 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9467 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9468
9469 /* Input mixer control */
9470 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9471 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9472 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9473 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9474 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9475 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9477 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9478 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009480
Takashi Iwai22309c32006-08-09 16:57:28 +02009481 /* Capture mixer control */
9482 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9483 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9484 {
9485 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9486 .name = "Capture Source",
9487 .count = 1,
9488 .info = alc_mux_enum_info,
9489 .get = alc_mux_enum_get,
9490 .put = alc_mux_enum_put,
9491 },
9492 {
9493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9494 .name = "Channel Mode",
9495 .info = alc_ch_mode_info,
9496 .get = alc_ch_mode_get,
9497 .put = alc_ch_mode_put,
9498 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9499 },
9500 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009501};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009502
9503static struct snd_kcontrol_new alc861_asus_mixer[] = {
9504 /* output mixer control */
9505 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9506 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9507 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9508 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9509 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9510
9511 /* Input mixer control */
9512 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9513 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9514 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9515 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9516 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9517 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9519 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9522
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009523 /* Capture mixer control */
9524 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9525 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9526 {
9527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9528 .name = "Capture Source",
9529 .count = 1,
9530 .info = alc_mux_enum_info,
9531 .get = alc_mux_enum_get,
9532 .put = alc_mux_enum_put,
9533 },
9534 {
9535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9536 .name = "Channel Mode",
9537 .info = alc_ch_mode_info,
9538 .get = alc_ch_mode_get,
9539 .put = alc_ch_mode_put,
9540 .private_value = ARRAY_SIZE(alc861_asus_modes),
9541 },
9542 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009543};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009544
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009545/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009546static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009547 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9548 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9549 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9551 { }
9552};
9553
Kailang Yangdf694da2005-12-05 19:42:22 +01009554/*
9555 * generic initialization of ADC, input mixers and output mixers
9556 */
9557static struct hda_verb alc861_base_init_verbs[] = {
9558 /*
9559 * Unmute ADC0 and set the default input to mic-in
9560 */
9561 /* port-A for surround (rear panel) */
9562 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9563 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9564 /* port-B for mic-in (rear panel) with vref */
9565 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9566 /* port-C for line-in (rear panel) */
9567 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9568 /* port-D for Front */
9569 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9570 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9571 /* port-E for HP out (front panel) */
9572 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9573 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009574 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009575 /* port-F for mic-in (front panel) with vref */
9576 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9577 /* port-G for CLFE (rear panel) */
9578 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9579 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9580 /* port-H for side (rear panel) */
9581 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9582 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9583 /* CD-in */
9584 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9585 /* route front mic to ADC1*/
9586 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9588
9589 /* Unmute DAC0~3 & spdif out*/
9590 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9591 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9592 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9593 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9595
9596 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9597 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9598 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9599 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9600 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9601
9602 /* Unmute Stereo Mixer 15 */
9603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009607
9608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9611 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009616 /* hp used DAC 3 (Front) */
9617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9619
9620 { }
9621};
9622
9623static struct hda_verb alc861_threestack_init_verbs[] = {
9624 /*
9625 * Unmute ADC0 and set the default input to mic-in
9626 */
9627 /* port-A for surround (rear panel) */
9628 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9629 /* port-B for mic-in (rear panel) with vref */
9630 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9631 /* port-C for line-in (rear panel) */
9632 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9633 /* port-D for Front */
9634 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9635 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9636 /* port-E for HP out (front panel) */
9637 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9638 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009639 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009640 /* port-F for mic-in (front panel) with vref */
9641 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9642 /* port-G for CLFE (rear panel) */
9643 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9644 /* port-H for side (rear panel) */
9645 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9646 /* CD-in */
9647 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9648 /* route front mic to ADC1*/
9649 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9651 /* Unmute DAC0~3 & spdif out*/
9652 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9653 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9654 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9655 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9657
9658 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9659 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9660 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9661 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9662 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9663
9664 /* Unmute Stereo Mixer 15 */
9665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009669
9670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9672 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9673 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9674 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009678 /* hp used DAC 3 (Front) */
9679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009680 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9681 { }
9682};
Takashi Iwai22309c32006-08-09 16:57:28 +02009683
9684static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9685 /*
9686 * Unmute ADC0 and set the default input to mic-in
9687 */
9688 /* port-A for surround (rear panel) */
9689 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9690 /* port-B for mic-in (rear panel) with vref */
9691 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9692 /* port-C for line-in (rear panel) */
9693 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9694 /* port-D for Front */
9695 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9696 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9697 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009698 /* this has to be set to VREF80 */
9699 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009700 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009701 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009702 /* port-F for mic-in (front panel) with vref */
9703 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9704 /* port-G for CLFE (rear panel) */
9705 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9706 /* port-H for side (rear panel) */
9707 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9708 /* CD-in */
9709 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9710 /* route front mic to ADC1*/
9711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9713 /* Unmute DAC0~3 & spdif out*/
9714 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9716 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9717 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9719
9720 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9721 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9722 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9723 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9724 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9725
9726 /* Unmute Stereo Mixer 15 */
9727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009731
9732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9734 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9735 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9736 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9738 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009740 /* hp used DAC 3 (Front) */
9741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9743 { }
9744};
9745
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009746static struct hda_verb alc861_asus_init_verbs[] = {
9747 /*
9748 * Unmute ADC0 and set the default input to mic-in
9749 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009750 /* port-A for surround (rear panel)
9751 * according to codec#0 this is the HP jack
9752 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009753 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9754 /* route front PCM to HP */
9755 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9756 /* port-B for mic-in (rear panel) with vref */
9757 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9758 /* port-C for line-in (rear panel) */
9759 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9760 /* port-D for Front */
9761 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9762 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9763 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009764 /* this has to be set to VREF80 */
9765 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009766 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009767 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009768 /* port-F for mic-in (front panel) with vref */
9769 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9770 /* port-G for CLFE (rear panel) */
9771 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9772 /* port-H for side (rear panel) */
9773 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9774 /* CD-in */
9775 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9776 /* route front mic to ADC1*/
9777 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9779 /* Unmute DAC0~3 & spdif out*/
9780 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9782 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9783 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9785 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9786 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9787 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9788 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9789 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9790
9791 /* Unmute Stereo Mixer 15 */
9792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009796
9797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9803 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009805 /* hp used DAC 3 (Front) */
9806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9808 { }
9809};
9810
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009811/* additional init verbs for ASUS laptops */
9812static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9813 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9814 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9815 { }
9816};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009817
Kailang Yangdf694da2005-12-05 19:42:22 +01009818/*
9819 * generic initialization of ADC, input mixers and output mixers
9820 */
9821static struct hda_verb alc861_auto_init_verbs[] = {
9822 /*
9823 * Unmute ADC0 and set the default input to mic-in
9824 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009825 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009826 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9827
9828 /* Unmute DAC0~3 & spdif out*/
9829 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9830 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9831 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9832 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9834
9835 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9836 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9837 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9838 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9839 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9840
9841 /* Unmute Stereo Mixer 15 */
9842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9846
9847 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9849 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9850 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9855
9856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009858 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009860 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009862 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9863 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009864
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009865 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009866
9867 { }
9868};
9869
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009870static struct hda_verb alc861_toshiba_init_verbs[] = {
9871 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009872
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009873 { }
9874};
9875
9876/* toggle speaker-output according to the hp-jack state */
9877static void alc861_toshiba_automute(struct hda_codec *codec)
9878{
9879 unsigned int present;
9880
9881 present = snd_hda_codec_read(codec, 0x0f, 0,
9882 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02009883 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9884 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9885 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9886 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009887}
9888
9889static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9890 unsigned int res)
9891{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009892 if ((res >> 26) == ALC880_HP_EVENT)
9893 alc861_toshiba_automute(codec);
9894}
9895
Kailang Yangdf694da2005-12-05 19:42:22 +01009896/* pcm configuration: identiacal with ALC880 */
9897#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9898#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9899#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9900#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9901
9902
9903#define ALC861_DIGOUT_NID 0x07
9904
9905static struct hda_channel_mode alc861_8ch_modes[1] = {
9906 { 8, NULL }
9907};
9908
9909static hda_nid_t alc861_dac_nids[4] = {
9910 /* front, surround, clfe, side */
9911 0x03, 0x06, 0x05, 0x04
9912};
9913
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009914static hda_nid_t alc660_dac_nids[3] = {
9915 /* front, clfe, surround */
9916 0x03, 0x05, 0x06
9917};
9918
Kailang Yangdf694da2005-12-05 19:42:22 +01009919static hda_nid_t alc861_adc_nids[1] = {
9920 /* ADC0-2 */
9921 0x08,
9922};
9923
9924static struct hda_input_mux alc861_capture_source = {
9925 .num_items = 5,
9926 .items = {
9927 { "Mic", 0x0 },
9928 { "Front Mic", 0x3 },
9929 { "Line", 0x1 },
9930 { "CD", 0x4 },
9931 { "Mixer", 0x5 },
9932 },
9933};
9934
9935/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009936static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9937 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009938{
9939 int i;
9940 hda_nid_t nid;
9941
9942 spec->multiout.dac_nids = spec->private_dac_nids;
9943 for (i = 0; i < cfg->line_outs; i++) {
9944 nid = cfg->line_out_pins[i];
9945 if (nid) {
9946 if (i >= ARRAY_SIZE(alc861_dac_nids))
9947 continue;
9948 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9949 }
9950 }
9951 spec->multiout.num_dacs = cfg->line_outs;
9952 return 0;
9953}
9954
9955/* add playback controls from the parsed DAC table */
9956static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9957 const struct auto_pin_cfg *cfg)
9958{
9959 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009960 static const char *chname[4] = {
9961 "Front", "Surround", NULL /*CLFE*/, "Side"
9962 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009963 hda_nid_t nid;
9964 int i, idx, err;
9965
9966 for (i = 0; i < cfg->line_outs; i++) {
9967 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009968 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009969 continue;
9970 if (nid == 0x05) {
9971 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009972 err = add_control(spec, ALC_CTL_BIND_MUTE,
9973 "Center Playback Switch",
9974 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9975 HDA_OUTPUT));
9976 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009977 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009978 err = add_control(spec, ALC_CTL_BIND_MUTE,
9979 "LFE Playback Switch",
9980 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9981 HDA_OUTPUT));
9982 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009983 return err;
9984 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009985 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9986 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009987 if (nid == alc861_dac_nids[idx])
9988 break;
9989 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009990 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9991 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9992 HDA_OUTPUT));
9993 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009994 return err;
9995 }
9996 }
9997 return 0;
9998}
9999
10000static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
10001{
10002 int err;
10003 hda_nid_t nid;
10004
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010005 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010010006 return 0;
10007
10008 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
10009 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010010 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10011 "Headphone Playback Switch",
10012 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10013 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010014 return err;
10015 spec->multiout.hp_nid = nid;
10016 }
10017 return 0;
10018}
10019
10020/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010021static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
10022 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010023{
Kailang Yangdf694da2005-12-05 19:42:22 +010010024 struct hda_input_mux *imux = &spec->private_imux;
10025 int i, err, idx, idx1;
10026
10027 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010028 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010029 case 0x0c:
10030 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010031 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010032 break;
10033 case 0x0f:
10034 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010035 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010036 break;
10037 case 0x0d:
10038 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010039 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010040 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010041 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010010042 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010043 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010010044 break;
10045 case 0x11:
10046 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010047 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010010048 break;
10049 default:
10050 continue;
10051 }
10052
Takashi Iwai4a471b72005-12-07 13:56:29 +010010053 err = new_analog_input(spec, cfg->input_pins[i],
10054 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010010055 if (err < 0)
10056 return err;
10057
Takashi Iwai4a471b72005-12-07 13:56:29 +010010058 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010010059 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010060 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010010061 }
10062 return 0;
10063}
10064
10065static struct snd_kcontrol_new alc861_capture_mixer[] = {
10066 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10067 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10068
10069 {
10070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10071 /* The multiple "Capture Source" controls confuse alsamixer
10072 * So call somewhat different..
10073 *FIXME: the controls appear in the "playback" view!
10074 */
10075 /* .name = "Capture Source", */
10076 .name = "Input Source",
10077 .count = 1,
10078 .info = alc_mux_enum_info,
10079 .get = alc_mux_enum_get,
10080 .put = alc_mux_enum_put,
10081 },
10082 { } /* end */
10083};
10084
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010085static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
10086 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010010087 int pin_type, int dac_idx)
10088{
10089 /* set as output */
10090
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010091 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10092 pin_type);
10093 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10094 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010010095
10096}
10097
10098static void alc861_auto_init_multi_out(struct hda_codec *codec)
10099{
10100 struct alc_spec *spec = codec->spec;
10101 int i;
10102
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010103 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010010104 for (i = 0; i < spec->autocfg.line_outs; i++) {
10105 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010106 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010010107 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010108 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010109 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010010110 }
10111}
10112
10113static void alc861_auto_init_hp_out(struct hda_codec *codec)
10114{
10115 struct alc_spec *spec = codec->spec;
10116 hda_nid_t pin;
10117
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010118 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010119 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010120 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
10121 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010010122}
10123
10124static void alc861_auto_init_analog_input(struct hda_codec *codec)
10125{
10126 struct alc_spec *spec = codec->spec;
10127 int i;
10128
10129 for (i = 0; i < AUTO_PIN_LAST; i++) {
10130 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010131 if (nid >= 0x0c && nid <= 0x11) {
10132 snd_hda_codec_write(codec, nid, 0,
10133 AC_VERB_SET_PIN_WIDGET_CONTROL,
10134 i <= AUTO_PIN_FRONT_MIC ?
10135 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010010136 }
10137 }
10138}
10139
10140/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010141/* return 1 if successful, 0 if the proper config is not found,
10142 * or a negative error code
10143 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010144static int alc861_parse_auto_config(struct hda_codec *codec)
10145{
10146 struct alc_spec *spec = codec->spec;
10147 int err;
10148 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10149
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010150 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10151 alc861_ignore);
10152 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010153 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010154 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010155 return 0; /* can't find valid BIOS pin config */
10156
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010157 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
10158 if (err < 0)
10159 return err;
10160 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
10161 if (err < 0)
10162 return err;
10163 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
10164 if (err < 0)
10165 return err;
10166 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
10167 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010168 return err;
10169
10170 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10171
10172 if (spec->autocfg.dig_out_pin)
10173 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
10174
10175 if (spec->kctl_alloc)
10176 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10177
10178 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
10179
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010180 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010181 spec->input_mux = &spec->private_imux;
10182
10183 spec->adc_nids = alc861_adc_nids;
10184 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
10185 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
10186 spec->num_mixers++;
10187
10188 return 1;
10189}
10190
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010191/* additional initialization for auto-configuration model */
10192static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010193{
Kailang Yangdf694da2005-12-05 19:42:22 +010010194 alc861_auto_init_multi_out(codec);
10195 alc861_auto_init_hp_out(codec);
10196 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010197}
10198
Takashi Iwaicb53c622007-08-10 17:21:45 +020010199#ifdef CONFIG_SND_HDA_POWER_SAVE
10200static struct hda_amp_list alc861_loopbacks[] = {
10201 { 0x15, HDA_INPUT, 0 },
10202 { 0x15, HDA_INPUT, 1 },
10203 { 0x15, HDA_INPUT, 2 },
10204 { 0x15, HDA_INPUT, 3 },
10205 { } /* end */
10206};
10207#endif
10208
Kailang Yangdf694da2005-12-05 19:42:22 +010010209
10210/*
10211 * configuration and preset
10212 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010213static const char *alc861_models[ALC861_MODEL_LAST] = {
10214 [ALC861_3ST] = "3stack",
10215 [ALC660_3ST] = "3stack-660",
10216 [ALC861_3ST_DIG] = "3stack-dig",
10217 [ALC861_6ST_DIG] = "6stack-dig",
10218 [ALC861_UNIWILL_M31] = "uniwill-m31",
10219 [ALC861_TOSHIBA] = "toshiba",
10220 [ALC861_ASUS] = "asus",
10221 [ALC861_ASUS_LAPTOP] = "asus-laptop",
10222 [ALC861_AUTO] = "auto",
10223};
10224
10225static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010010226 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010227 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10228 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +020010229 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020010230 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010231 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +020010232 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010010233 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020010234 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10235 * Any other models that need this preset?
10236 */
10237 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010238 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +020010239 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +010010240 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +010010241 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010242 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020010243 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10244 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010010245 {}
10246};
10247
10248static struct alc_config_preset alc861_presets[] = {
10249 [ALC861_3ST] = {
10250 .mixers = { alc861_3ST_mixer },
10251 .init_verbs = { alc861_threestack_init_verbs },
10252 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10253 .dac_nids = alc861_dac_nids,
10254 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10255 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010256 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010010257 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10258 .adc_nids = alc861_adc_nids,
10259 .input_mux = &alc861_capture_source,
10260 },
10261 [ALC861_3ST_DIG] = {
10262 .mixers = { alc861_base_mixer },
10263 .init_verbs = { alc861_threestack_init_verbs },
10264 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10265 .dac_nids = alc861_dac_nids,
10266 .dig_out_nid = ALC861_DIGOUT_NID,
10267 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10268 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010269 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010010270 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10271 .adc_nids = alc861_adc_nids,
10272 .input_mux = &alc861_capture_source,
10273 },
10274 [ALC861_6ST_DIG] = {
10275 .mixers = { alc861_base_mixer },
10276 .init_verbs = { alc861_base_init_verbs },
10277 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10278 .dac_nids = alc861_dac_nids,
10279 .dig_out_nid = ALC861_DIGOUT_NID,
10280 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
10281 .channel_mode = alc861_8ch_modes,
10282 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10283 .adc_nids = alc861_adc_nids,
10284 .input_mux = &alc861_capture_source,
10285 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010286 [ALC660_3ST] = {
10287 .mixers = { alc861_3ST_mixer },
10288 .init_verbs = { alc861_threestack_init_verbs },
10289 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
10290 .dac_nids = alc660_dac_nids,
10291 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10292 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010293 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010294 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10295 .adc_nids = alc861_adc_nids,
10296 .input_mux = &alc861_capture_source,
10297 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010298 [ALC861_UNIWILL_M31] = {
10299 .mixers = { alc861_uniwill_m31_mixer },
10300 .init_verbs = { alc861_uniwill_m31_init_verbs },
10301 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10302 .dac_nids = alc861_dac_nids,
10303 .dig_out_nid = ALC861_DIGOUT_NID,
10304 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
10305 .channel_mode = alc861_uniwill_m31_modes,
10306 .need_dac_fix = 1,
10307 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10308 .adc_nids = alc861_adc_nids,
10309 .input_mux = &alc861_capture_source,
10310 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010311 [ALC861_TOSHIBA] = {
10312 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010313 .init_verbs = { alc861_base_init_verbs,
10314 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010315 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10316 .dac_nids = alc861_dac_nids,
10317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10318 .channel_mode = alc883_3ST_2ch_modes,
10319 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10320 .adc_nids = alc861_adc_nids,
10321 .input_mux = &alc861_capture_source,
10322 .unsol_event = alc861_toshiba_unsol_event,
10323 .init_hook = alc861_toshiba_automute,
10324 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010325 [ALC861_ASUS] = {
10326 .mixers = { alc861_asus_mixer },
10327 .init_verbs = { alc861_asus_init_verbs },
10328 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10329 .dac_nids = alc861_dac_nids,
10330 .dig_out_nid = ALC861_DIGOUT_NID,
10331 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
10332 .channel_mode = alc861_asus_modes,
10333 .need_dac_fix = 1,
10334 .hp_nid = 0x06,
10335 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10336 .adc_nids = alc861_adc_nids,
10337 .input_mux = &alc861_capture_source,
10338 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010339 [ALC861_ASUS_LAPTOP] = {
10340 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
10341 .init_verbs = { alc861_asus_init_verbs,
10342 alc861_asus_laptop_init_verbs },
10343 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10344 .dac_nids = alc861_dac_nids,
10345 .dig_out_nid = ALC861_DIGOUT_NID,
10346 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10347 .channel_mode = alc883_3ST_2ch_modes,
10348 .need_dac_fix = 1,
10349 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10350 .adc_nids = alc861_adc_nids,
10351 .input_mux = &alc861_capture_source,
10352 },
10353};
Kailang Yangdf694da2005-12-05 19:42:22 +010010354
10355
10356static int patch_alc861(struct hda_codec *codec)
10357{
10358 struct alc_spec *spec;
10359 int board_config;
10360 int err;
10361
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010362 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010363 if (spec == NULL)
10364 return -ENOMEM;
10365
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010366 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010367
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010368 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
10369 alc861_models,
10370 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010371
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010372 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010373 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
10374 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010375 board_config = ALC861_AUTO;
10376 }
10377
10378 if (board_config == ALC861_AUTO) {
10379 /* automatic parse from the BIOS config */
10380 err = alc861_parse_auto_config(codec);
10381 if (err < 0) {
10382 alc_free(codec);
10383 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010384 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010385 printk(KERN_INFO
10386 "hda_codec: Cannot set up configuration "
10387 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010388 board_config = ALC861_3ST_DIG;
10389 }
10390 }
10391
10392 if (board_config != ALC861_AUTO)
10393 setup_preset(spec, &alc861_presets[board_config]);
10394
10395 spec->stream_name_analog = "ALC861 Analog";
10396 spec->stream_analog_playback = &alc861_pcm_analog_playback;
10397 spec->stream_analog_capture = &alc861_pcm_analog_capture;
10398
10399 spec->stream_name_digital = "ALC861 Digital";
10400 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10401 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10402
10403 codec->patch_ops = alc_patch_ops;
10404 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010405 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010406#ifdef CONFIG_SND_HDA_POWER_SAVE
10407 if (!spec->loopback.amplist)
10408 spec->loopback.amplist = alc861_loopbacks;
10409#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010410
10411 return 0;
10412}
10413
10414/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010415 * ALC861-VD support
10416 *
10417 * Based on ALC882
10418 *
10419 * In addition, an independent DAC
10420 */
10421#define ALC861VD_DIGOUT_NID 0x06
10422
10423static hda_nid_t alc861vd_dac_nids[4] = {
10424 /* front, surr, clfe, side surr */
10425 0x02, 0x03, 0x04, 0x05
10426};
10427
10428/* dac_nids for ALC660vd are in a different order - according to
10429 * Realtek's driver.
10430 * This should probably tesult in a different mixer for 6stack models
10431 * of ALC660vd codecs, but for now there is only 3stack mixer
10432 * - and it is the same as in 861vd.
10433 * adc_nids in ALC660vd are (is) the same as in 861vd
10434 */
10435static hda_nid_t alc660vd_dac_nids[3] = {
10436 /* front, rear, clfe, rear_surr */
10437 0x02, 0x04, 0x03
10438};
10439
10440static hda_nid_t alc861vd_adc_nids[1] = {
10441 /* ADC0 */
10442 0x09,
10443};
10444
10445/* input MUX */
10446/* FIXME: should be a matrix-type input source selection */
10447static struct hda_input_mux alc861vd_capture_source = {
10448 .num_items = 4,
10449 .items = {
10450 { "Mic", 0x0 },
10451 { "Front Mic", 0x1 },
10452 { "Line", 0x2 },
10453 { "CD", 0x4 },
10454 },
10455};
10456
Kailang Yang272a5272007-05-14 11:00:38 +020010457static struct hda_input_mux alc861vd_dallas_capture_source = {
10458 .num_items = 3,
10459 .items = {
10460 { "Front Mic", 0x0 },
10461 { "ATAPI Mic", 0x1 },
10462 { "Line In", 0x5 },
10463 },
10464};
10465
Kailang Yangd1a991a2007-08-15 16:21:59 +020010466static struct hda_input_mux alc861vd_hp_capture_source = {
10467 .num_items = 2,
10468 .items = {
10469 { "Front Mic", 0x0 },
10470 { "ATAPI Mic", 0x1 },
10471 },
10472};
10473
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010474#define alc861vd_mux_enum_info alc_mux_enum_info
10475#define alc861vd_mux_enum_get alc_mux_enum_get
10476
10477static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10478 struct snd_ctl_elem_value *ucontrol)
10479{
10480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10481 struct alc_spec *spec = codec->spec;
10482 const struct hda_input_mux *imux = spec->input_mux;
10483 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10484 static hda_nid_t capture_mixers[1] = { 0x22 };
10485 hda_nid_t nid = capture_mixers[adc_idx];
10486 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10487 unsigned int i, idx;
10488
10489 idx = ucontrol->value.enumerated.item[0];
10490 if (idx >= imux->num_items)
10491 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010492 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010493 return 0;
10494 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020010495 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10496 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10497 imux->items[i].index,
10498 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010499 }
10500 *cur_val = idx;
10501 return 1;
10502}
10503
10504/*
10505 * 2ch mode
10506 */
10507static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10508 { 2, NULL }
10509};
10510
10511/*
10512 * 6ch mode
10513 */
10514static struct hda_verb alc861vd_6stack_ch6_init[] = {
10515 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10516 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10517 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10518 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10519 { } /* end */
10520};
10521
10522/*
10523 * 8ch mode
10524 */
10525static struct hda_verb alc861vd_6stack_ch8_init[] = {
10526 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10527 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10528 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10529 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10530 { } /* end */
10531};
10532
10533static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10534 { 6, alc861vd_6stack_ch6_init },
10535 { 8, alc861vd_6stack_ch8_init },
10536};
10537
10538static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10539 {
10540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10541 .name = "Channel Mode",
10542 .info = alc_ch_mode_info,
10543 .get = alc_ch_mode_get,
10544 .put = alc_ch_mode_put,
10545 },
10546 { } /* end */
10547};
10548
10549static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10550 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10551 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10552
10553 {
10554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10555 /* The multiple "Capture Source" controls confuse alsamixer
10556 * So call somewhat different..
10557 *FIXME: the controls appear in the "playback" view!
10558 */
10559 /* .name = "Capture Source", */
10560 .name = "Input Source",
10561 .count = 1,
10562 .info = alc861vd_mux_enum_info,
10563 .get = alc861vd_mux_enum_get,
10564 .put = alc861vd_mux_enum_put,
10565 },
10566 { } /* end */
10567};
10568
10569/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10570 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10571 */
10572static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10575
10576 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10577 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10578
10579 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10580 HDA_OUTPUT),
10581 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10582 HDA_OUTPUT),
10583 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10584 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10585
10586 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10587 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10588
10589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10590
10591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10594
10595 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10598
10599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10601
10602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10604
10605 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10606 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10607
10608 { } /* end */
10609};
10610
10611static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10612 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10614
10615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10616
10617 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10620
10621 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10623 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10624
10625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10627
10628 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10629 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10630
10631 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10632 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10633
10634 { } /* end */
10635};
10636
Kailang Yangbdd148a2007-05-08 15:19:08 +020010637static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10638 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10639 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10640 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10641
10642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10643
10644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10647
10648 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10650 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10651
10652 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10653 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10654
10655 { } /* end */
10656};
10657
Kailang Yang272a5272007-05-14 11:00:38 +020010658/* Pin assignment: Front=0x14, HP = 0x15,
10659 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10660 */
10661static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10662 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10665 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10666 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10668 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10669 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020010672 { } /* end */
10673};
10674
Kailang Yangd1a991a2007-08-15 16:21:59 +020010675/* Pin assignment: Speaker=0x14, Line-out = 0x15,
10676 * Front Mic=0x18, ATAPI Mic = 0x19,
10677 */
10678static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10679 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10680 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10682 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10684 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10685 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10686 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10687
10688 { } /* end */
10689};
10690
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010691/*
10692 * generic initialization of ADC, input mixers and output mixers
10693 */
10694static struct hda_verb alc861vd_volume_init_verbs[] = {
10695 /*
10696 * Unmute ADC0 and set the default input to mic-in
10697 */
10698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10700
10701 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10702 * the analog-loopback mixer widget
10703 */
10704 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010710
10711 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010716
10717 /*
10718 * Set up output mixers (0x02 - 0x05)
10719 */
10720 /* set vol=0 to output mixers */
10721 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10722 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10723 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10725
10726 /* set up input amps for analog loopback */
10727 /* Amp Indices: DAC = 0, mixer = 1 */
10728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10729 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10730 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10731 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10734 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10735 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10736
10737 { }
10738};
10739
10740/*
10741 * 3-stack pin configuration:
10742 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10743 */
10744static struct hda_verb alc861vd_3stack_init_verbs[] = {
10745 /*
10746 * Set pin mode and muting
10747 */
10748 /* set front pin widgets 0x14 for output */
10749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10752
10753 /* Mic (rear) pin: input vref at 80% */
10754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10756 /* Front Mic pin: input vref at 80% */
10757 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10759 /* Line In pin: input */
10760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10762 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10763 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10764 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10765 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10766 /* CD pin widget for input */
10767 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10768
10769 { }
10770};
10771
10772/*
10773 * 6-stack pin configuration:
10774 */
10775static struct hda_verb alc861vd_6stack_init_verbs[] = {
10776 /*
10777 * Set pin mode and muting
10778 */
10779 /* set front pin widgets 0x14 for output */
10780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10781 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10782 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10783
10784 /* Rear Pin: output 1 (0x0d) */
10785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10787 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10788 /* CLFE Pin: output 2 (0x0e) */
10789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10790 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10791 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10792 /* Side Pin: output 3 (0x0f) */
10793 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10795 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10796
10797 /* Mic (rear) pin: input vref at 80% */
10798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10800 /* Front Mic pin: input vref at 80% */
10801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10803 /* Line In pin: input */
10804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10806 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10809 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10810 /* CD pin widget for input */
10811 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10812
10813 { }
10814};
10815
Kailang Yangbdd148a2007-05-08 15:19:08 +020010816static struct hda_verb alc861vd_eapd_verbs[] = {
10817 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10818 { }
10819};
10820
10821static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10825 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10826 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10827 {}
10828};
10829
10830/* toggle speaker-output according to the hp-jack state */
10831static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10832{
10833 unsigned int present;
10834 unsigned char bits;
10835
10836 present = snd_hda_codec_read(codec, 0x1b, 0,
10837 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010838 bits = present ? HDA_AMP_MUTE : 0;
10839 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10840 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010841}
10842
10843static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10844{
10845 unsigned int present;
10846 unsigned char bits;
10847
10848 present = snd_hda_codec_read(codec, 0x18, 0,
10849 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010850 bits = present ? HDA_AMP_MUTE : 0;
10851 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10852 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010853}
10854
10855static void alc861vd_lenovo_automute(struct hda_codec *codec)
10856{
10857 alc861vd_lenovo_hp_automute(codec);
10858 alc861vd_lenovo_mic_automute(codec);
10859}
10860
10861static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10862 unsigned int res)
10863{
10864 switch (res >> 26) {
10865 case ALC880_HP_EVENT:
10866 alc861vd_lenovo_hp_automute(codec);
10867 break;
10868 case ALC880_MIC_EVENT:
10869 alc861vd_lenovo_mic_automute(codec);
10870 break;
10871 }
10872}
10873
Kailang Yang272a5272007-05-14 11:00:38 +020010874static struct hda_verb alc861vd_dallas_verbs[] = {
10875 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10876 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10877 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10878 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10879
10880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10888
10889 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10893 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10895 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10896 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10897
10898 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10899 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10900 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10901 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10902 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10903 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10905 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10906
10907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10910 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10911
10912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10913 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10914 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10915
10916 { } /* end */
10917};
10918
10919/* toggle speaker-output according to the hp-jack state */
10920static void alc861vd_dallas_automute(struct hda_codec *codec)
10921{
10922 unsigned int present;
10923
10924 present = snd_hda_codec_read(codec, 0x15, 0,
10925 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010926 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10927 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020010928}
10929
10930static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10931{
10932 if ((res >> 26) == ALC880_HP_EVENT)
10933 alc861vd_dallas_automute(codec);
10934}
10935
Takashi Iwaicb53c622007-08-10 17:21:45 +020010936#ifdef CONFIG_SND_HDA_POWER_SAVE
10937#define alc861vd_loopbacks alc880_loopbacks
10938#endif
10939
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010940/* pcm configuration: identiacal with ALC880 */
10941#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10942#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10943#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10944#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10945
10946/*
10947 * configuration and preset
10948 */
10949static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10950 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010951 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010952 [ALC861VD_3ST] = "3stack",
10953 [ALC861VD_3ST_DIG] = "3stack-digout",
10954 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010955 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010956 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010957 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010958 [ALC861VD_AUTO] = "auto",
10959};
10960
10961static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010962 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010963 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010964 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010965 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10966 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10967
Takashi Iwai38baf5a2007-08-16 17:52:43 +020010968 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020010969 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010970 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10971 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010972 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020010973 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020010974 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Tobin Davis625dc0b2007-07-30 21:42:10 +020010975 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010976 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010977 {}
10978};
10979
10980static struct alc_config_preset alc861vd_presets[] = {
10981 [ALC660VD_3ST] = {
10982 .mixers = { alc861vd_3st_mixer },
10983 .init_verbs = { alc861vd_volume_init_verbs,
10984 alc861vd_3stack_init_verbs },
10985 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10986 .dac_nids = alc660vd_dac_nids,
10987 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10988 .adc_nids = alc861vd_adc_nids,
10989 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10990 .channel_mode = alc861vd_3stack_2ch_modes,
10991 .input_mux = &alc861vd_capture_source,
10992 },
Mike Crash6963f842007-06-25 12:12:51 +020010993 [ALC660VD_3ST_DIG] = {
10994 .mixers = { alc861vd_3st_mixer },
10995 .init_verbs = { alc861vd_volume_init_verbs,
10996 alc861vd_3stack_init_verbs },
10997 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10998 .dac_nids = alc660vd_dac_nids,
10999 .dig_out_nid = ALC861VD_DIGOUT_NID,
11000 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11001 .adc_nids = alc861vd_adc_nids,
11002 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11003 .channel_mode = alc861vd_3stack_2ch_modes,
11004 .input_mux = &alc861vd_capture_source,
11005 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011006 [ALC861VD_3ST] = {
11007 .mixers = { alc861vd_3st_mixer },
11008 .init_verbs = { alc861vd_volume_init_verbs,
11009 alc861vd_3stack_init_verbs },
11010 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11011 .dac_nids = alc861vd_dac_nids,
11012 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11013 .channel_mode = alc861vd_3stack_2ch_modes,
11014 .input_mux = &alc861vd_capture_source,
11015 },
11016 [ALC861VD_3ST_DIG] = {
11017 .mixers = { alc861vd_3st_mixer },
11018 .init_verbs = { alc861vd_volume_init_verbs,
11019 alc861vd_3stack_init_verbs },
11020 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11021 .dac_nids = alc861vd_dac_nids,
11022 .dig_out_nid = ALC861VD_DIGOUT_NID,
11023 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11024 .channel_mode = alc861vd_3stack_2ch_modes,
11025 .input_mux = &alc861vd_capture_source,
11026 },
11027 [ALC861VD_6ST_DIG] = {
11028 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
11029 .init_verbs = { alc861vd_volume_init_verbs,
11030 alc861vd_6stack_init_verbs },
11031 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11032 .dac_nids = alc861vd_dac_nids,
11033 .dig_out_nid = ALC861VD_DIGOUT_NID,
11034 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
11035 .channel_mode = alc861vd_6stack_modes,
11036 .input_mux = &alc861vd_capture_source,
11037 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020011038 [ALC861VD_LENOVO] = {
11039 .mixers = { alc861vd_lenovo_mixer },
11040 .init_verbs = { alc861vd_volume_init_verbs,
11041 alc861vd_3stack_init_verbs,
11042 alc861vd_eapd_verbs,
11043 alc861vd_lenovo_unsol_verbs },
11044 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11045 .dac_nids = alc660vd_dac_nids,
11046 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11047 .adc_nids = alc861vd_adc_nids,
11048 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11049 .channel_mode = alc861vd_3stack_2ch_modes,
11050 .input_mux = &alc861vd_capture_source,
11051 .unsol_event = alc861vd_lenovo_unsol_event,
11052 .init_hook = alc861vd_lenovo_automute,
11053 },
Kailang Yang272a5272007-05-14 11:00:38 +020011054 [ALC861VD_DALLAS] = {
11055 .mixers = { alc861vd_dallas_mixer },
11056 .init_verbs = { alc861vd_dallas_verbs },
11057 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11058 .dac_nids = alc861vd_dac_nids,
11059 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11060 .adc_nids = alc861vd_adc_nids,
11061 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11062 .channel_mode = alc861vd_3stack_2ch_modes,
11063 .input_mux = &alc861vd_dallas_capture_source,
11064 .unsol_event = alc861vd_dallas_unsol_event,
11065 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011066 },
11067 [ALC861VD_HP] = {
11068 .mixers = { alc861vd_hp_mixer },
11069 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
11070 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11071 .dac_nids = alc861vd_dac_nids,
11072 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11073 .dig_out_nid = ALC861VD_DIGOUT_NID,
11074 .adc_nids = alc861vd_adc_nids,
11075 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11076 .channel_mode = alc861vd_3stack_2ch_modes,
11077 .input_mux = &alc861vd_hp_capture_source,
11078 .unsol_event = alc861vd_dallas_unsol_event,
11079 .init_hook = alc861vd_dallas_automute,
11080 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011081};
11082
11083/*
11084 * BIOS auto configuration
11085 */
11086static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
11087 hda_nid_t nid, int pin_type, int dac_idx)
11088{
11089 /* set as output */
11090 snd_hda_codec_write(codec, nid, 0,
11091 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11092 snd_hda_codec_write(codec, nid, 0,
11093 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11094}
11095
11096static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
11097{
11098 struct alc_spec *spec = codec->spec;
11099 int i;
11100
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011101 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011102 for (i = 0; i <= HDA_SIDE; i++) {
11103 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011104 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011105 if (nid)
11106 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011107 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011108 }
11109}
11110
11111
11112static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
11113{
11114 struct alc_spec *spec = codec->spec;
11115 hda_nid_t pin;
11116
11117 pin = spec->autocfg.hp_pins[0];
11118 if (pin) /* connect to front and use dac 0 */
11119 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11120}
11121
11122#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
11123#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
11124
11125static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
11126{
11127 struct alc_spec *spec = codec->spec;
11128 int i;
11129
11130 for (i = 0; i < AUTO_PIN_LAST; i++) {
11131 hda_nid_t nid = spec->autocfg.input_pins[i];
11132 if (alc861vd_is_input_pin(nid)) {
11133 snd_hda_codec_write(codec, nid, 0,
11134 AC_VERB_SET_PIN_WIDGET_CONTROL,
11135 i <= AUTO_PIN_FRONT_MIC ?
11136 PIN_VREF80 : PIN_IN);
11137 if (nid != ALC861VD_PIN_CD_NID)
11138 snd_hda_codec_write(codec, nid, 0,
11139 AC_VERB_SET_AMP_GAIN_MUTE,
11140 AMP_OUT_MUTE);
11141 }
11142 }
11143}
11144
11145#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
11146#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
11147
11148/* add playback controls from the parsed DAC table */
11149/* Based on ALC880 version. But ALC861VD has separate,
11150 * different NIDs for mute/unmute switch and volume control */
11151static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
11152 const struct auto_pin_cfg *cfg)
11153{
11154 char name[32];
11155 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
11156 hda_nid_t nid_v, nid_s;
11157 int i, err;
11158
11159 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011160 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011161 continue;
11162 nid_v = alc861vd_idx_to_mixer_vol(
11163 alc880_dac_to_idx(
11164 spec->multiout.dac_nids[i]));
11165 nid_s = alc861vd_idx_to_mixer_switch(
11166 alc880_dac_to_idx(
11167 spec->multiout.dac_nids[i]));
11168
11169 if (i == 2) {
11170 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011171 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11172 "Center Playback Volume",
11173 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
11174 HDA_OUTPUT));
11175 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011177 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11178 "LFE Playback Volume",
11179 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
11180 HDA_OUTPUT));
11181 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011182 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011183 err = add_control(spec, ALC_CTL_BIND_MUTE,
11184 "Center Playback Switch",
11185 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
11186 HDA_INPUT));
11187 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011188 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011189 err = add_control(spec, ALC_CTL_BIND_MUTE,
11190 "LFE Playback Switch",
11191 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
11192 HDA_INPUT));
11193 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011194 return err;
11195 } else {
11196 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011197 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11198 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
11199 HDA_OUTPUT));
11200 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011201 return err;
11202 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011203 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020011204 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011205 HDA_INPUT));
11206 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011207 return err;
11208 }
11209 }
11210 return 0;
11211}
11212
11213/* add playback controls for speaker and HP outputs */
11214/* Based on ALC880 version. But ALC861VD has separate,
11215 * different NIDs for mute/unmute switch and volume control */
11216static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
11217 hda_nid_t pin, const char *pfx)
11218{
11219 hda_nid_t nid_v, nid_s;
11220 int err;
11221 char name[32];
11222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011223 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011224 return 0;
11225
11226 if (alc880_is_fixed_pin(pin)) {
11227 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11228 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011229 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011230 spec->multiout.hp_nid = nid_v;
11231 else
11232 spec->multiout.extra_out_nid[0] = nid_v;
11233 /* control HP volume/switch on the output mixer amp */
11234 nid_v = alc861vd_idx_to_mixer_vol(
11235 alc880_fixed_pin_idx(pin));
11236 nid_s = alc861vd_idx_to_mixer_switch(
11237 alc880_fixed_pin_idx(pin));
11238
11239 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011240 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11241 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
11242 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011243 return err;
11244 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011245 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11246 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
11247 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011248 return err;
11249 } else if (alc880_is_multi_pin(pin)) {
11250 /* set manual connection */
11251 /* we have only a switch on HP-out PIN */
11252 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011253 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11254 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11255 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011256 return err;
11257 }
11258 return 0;
11259}
11260
11261/* parse the BIOS configuration and set up the alc_spec
11262 * return 1 if successful, 0 if the proper config is not found,
11263 * or a negative error code
11264 * Based on ALC880 version - had to change it to override
11265 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
11266static int alc861vd_parse_auto_config(struct hda_codec *codec)
11267{
11268 struct alc_spec *spec = codec->spec;
11269 int err;
11270 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
11271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011272 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11273 alc861vd_ignore);
11274 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011275 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011276 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011277 return 0; /* can't find valid BIOS pin config */
11278
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011279 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11280 if (err < 0)
11281 return err;
11282 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
11283 if (err < 0)
11284 return err;
11285 err = alc861vd_auto_create_extra_out(spec,
11286 spec->autocfg.speaker_pins[0],
11287 "Speaker");
11288 if (err < 0)
11289 return err;
11290 err = alc861vd_auto_create_extra_out(spec,
11291 spec->autocfg.hp_pins[0],
11292 "Headphone");
11293 if (err < 0)
11294 return err;
11295 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
11296 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011297 return err;
11298
11299 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11300
11301 if (spec->autocfg.dig_out_pin)
11302 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
11303
11304 if (spec->kctl_alloc)
11305 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11306
11307 spec->init_verbs[spec->num_init_verbs++]
11308 = alc861vd_volume_init_verbs;
11309
11310 spec->num_mux_defs = 1;
11311 spec->input_mux = &spec->private_imux;
11312
Takashi Iwai776e1842007-08-29 15:07:11 +020011313 err = alc_auto_add_mic_boost(codec);
11314 if (err < 0)
11315 return err;
11316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011317 return 1;
11318}
11319
11320/* additional initialization for auto-configuration model */
11321static void alc861vd_auto_init(struct hda_codec *codec)
11322{
11323 alc861vd_auto_init_multi_out(codec);
11324 alc861vd_auto_init_hp_out(codec);
11325 alc861vd_auto_init_analog_input(codec);
11326}
11327
11328static int patch_alc861vd(struct hda_codec *codec)
11329{
11330 struct alc_spec *spec;
11331 int err, board_config;
11332
11333 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11334 if (spec == NULL)
11335 return -ENOMEM;
11336
11337 codec->spec = spec;
11338
11339 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
11340 alc861vd_models,
11341 alc861vd_cfg_tbl);
11342
11343 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
11344 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
11345 "ALC861VD, trying auto-probe from BIOS...\n");
11346 board_config = ALC861VD_AUTO;
11347 }
11348
11349 if (board_config == ALC861VD_AUTO) {
11350 /* automatic parse from the BIOS config */
11351 err = alc861vd_parse_auto_config(codec);
11352 if (err < 0) {
11353 alc_free(codec);
11354 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011355 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011356 printk(KERN_INFO
11357 "hda_codec: Cannot set up configuration "
11358 "from BIOS. Using base mode...\n");
11359 board_config = ALC861VD_3ST;
11360 }
11361 }
11362
11363 if (board_config != ALC861VD_AUTO)
11364 setup_preset(spec, &alc861vd_presets[board_config]);
11365
11366 spec->stream_name_analog = "ALC861VD Analog";
11367 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
11368 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
11369
11370 spec->stream_name_digital = "ALC861VD Digital";
11371 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
11372 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
11373
11374 spec->adc_nids = alc861vd_adc_nids;
11375 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
11376
11377 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11378 spec->num_mixers++;
11379
11380 codec->patch_ops = alc_patch_ops;
11381
11382 if (board_config == ALC861VD_AUTO)
11383 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011384#ifdef CONFIG_SND_HDA_POWER_SAVE
11385 if (!spec->loopback.amplist)
11386 spec->loopback.amplist = alc861vd_loopbacks;
11387#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011388
11389 return 0;
11390}
11391
11392/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011393 * ALC662 support
11394 *
11395 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
11396 * configuration. Each pin widget can choose any input DACs and a mixer.
11397 * Each ADC is connected from a mixer of all inputs. This makes possible
11398 * 6-channel independent captures.
11399 *
11400 * In addition, an independent DAC for the multi-playback (not used in this
11401 * driver yet).
11402 */
11403#define ALC662_DIGOUT_NID 0x06
11404#define ALC662_DIGIN_NID 0x0a
11405
11406static hda_nid_t alc662_dac_nids[4] = {
11407 /* front, rear, clfe, rear_surr */
11408 0x02, 0x03, 0x04
11409};
11410
11411static hda_nid_t alc662_adc_nids[1] = {
11412 /* ADC1-2 */
11413 0x09,
11414};
11415/* input MUX */
11416/* FIXME: should be a matrix-type input source selection */
11417
11418static struct hda_input_mux alc662_capture_source = {
11419 .num_items = 4,
11420 .items = {
11421 { "Mic", 0x0 },
11422 { "Front Mic", 0x1 },
11423 { "Line", 0x2 },
11424 { "CD", 0x4 },
11425 },
11426};
11427
11428static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11429 .num_items = 2,
11430 .items = {
11431 { "Mic", 0x1 },
11432 { "Line", 0x2 },
11433 },
11434};
11435#define alc662_mux_enum_info alc_mux_enum_info
11436#define alc662_mux_enum_get alc_mux_enum_get
11437
11438static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11439 struct snd_ctl_elem_value *ucontrol)
11440{
11441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11442 struct alc_spec *spec = codec->spec;
11443 const struct hda_input_mux *imux = spec->input_mux;
11444 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020011445 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011446 hda_nid_t nid = capture_mixers[adc_idx];
11447 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11448 unsigned int i, idx;
11449
11450 idx = ucontrol->value.enumerated.item[0];
11451 if (idx >= imux->num_items)
11452 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011453 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011454 return 0;
11455 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011456 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11457 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11458 imux->items[i].index,
11459 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011460 }
11461 *cur_val = idx;
11462 return 1;
11463}
11464/*
11465 * 2ch mode
11466 */
11467static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11468 { 2, NULL }
11469};
11470
11471/*
11472 * 2ch mode
11473 */
11474static struct hda_verb alc662_3ST_ch2_init[] = {
11475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11477 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11478 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11479 { } /* end */
11480};
11481
11482/*
11483 * 6ch mode
11484 */
11485static struct hda_verb alc662_3ST_ch6_init[] = {
11486 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11487 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11488 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11489 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11490 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11491 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11492 { } /* end */
11493};
11494
11495static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11496 { 2, alc662_3ST_ch2_init },
11497 { 6, alc662_3ST_ch6_init },
11498};
11499
11500/*
11501 * 2ch mode
11502 */
11503static struct hda_verb alc662_sixstack_ch6_init[] = {
11504 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11505 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11506 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11507 { } /* end */
11508};
11509
11510/*
11511 * 6ch mode
11512 */
11513static struct hda_verb alc662_sixstack_ch8_init[] = {
11514 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11515 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11516 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11517 { } /* end */
11518};
11519
11520static struct hda_channel_mode alc662_5stack_modes[2] = {
11521 { 2, alc662_sixstack_ch6_init },
11522 { 6, alc662_sixstack_ch8_init },
11523};
11524
11525/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11526 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11527 */
11528
11529static struct snd_kcontrol_new alc662_base_mixer[] = {
11530 /* output mixer control */
11531 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11532 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11533 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11534 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11535 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11536 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11537 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11538 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11539 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11540
11541 /*Input mixer control */
11542 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11543 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11544 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11545 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11546 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11547 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11548 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11549 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11550
11551 /* Capture mixer control */
11552 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11553 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11554 {
11555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11556 .name = "Capture Source",
11557 .count = 1,
11558 .info = alc_mux_enum_info,
11559 .get = alc_mux_enum_get,
11560 .put = alc_mux_enum_put,
11561 },
11562 { } /* end */
11563};
11564
11565static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11566 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11567 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11569 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11570 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11571 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11572 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11575 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11576 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11577 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11578 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11579 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11580 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11581 {
11582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11583 /* .name = "Capture Source", */
11584 .name = "Input Source",
11585 .count = 1,
11586 .info = alc662_mux_enum_info,
11587 .get = alc662_mux_enum_get,
11588 .put = alc662_mux_enum_put,
11589 },
11590 { } /* end */
11591};
11592
11593static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11594 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11595 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11596 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11597 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11598 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11599 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11600 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11601 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11602 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11603 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11604 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11605 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11606 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11609 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11610 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11611 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11612 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11613 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11614 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11615 {
11616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11617 /* .name = "Capture Source", */
11618 .name = "Input Source",
11619 .count = 1,
11620 .info = alc662_mux_enum_info,
11621 .get = alc662_mux_enum_get,
11622 .put = alc662_mux_enum_put,
11623 },
11624 { } /* end */
11625};
11626
11627static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11628 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11629 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11630 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11631 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11632 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11633 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11634 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11637 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11638 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11639 {
11640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11641 /* .name = "Capture Source", */
11642 .name = "Input Source",
11643 .count = 1,
11644 .info = alc662_mux_enum_info,
11645 .get = alc662_mux_enum_get,
11646 .put = alc662_mux_enum_put,
11647 },
11648 { } /* end */
11649};
11650
11651static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11652 {
11653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11654 .name = "Channel Mode",
11655 .info = alc_ch_mode_info,
11656 .get = alc_ch_mode_get,
11657 .put = alc_ch_mode_put,
11658 },
11659 { } /* end */
11660};
11661
11662static struct hda_verb alc662_init_verbs[] = {
11663 /* ADC: mute amp left and right */
11664 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11665 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11666 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11667
Takashi Iwaicb53c622007-08-10 17:21:45 +020011668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011673
Kailang Yangb60dd392007-09-20 12:50:29 +020011674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011680
11681 /* Front Pin: output 0 (0x0c) */
11682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11684
11685 /* Rear Pin: output 1 (0x0d) */
11686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11688
11689 /* CLFE Pin: output 2 (0x0e) */
11690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11692
11693 /* Mic (rear) pin: input vref at 80% */
11694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11696 /* Front Mic pin: input vref at 80% */
11697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11699 /* Line In pin: input */
11700 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11702 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11704 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11705 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11706 /* CD pin widget for input */
11707 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11708
11709 /* FIXME: use matrix-type input source selection */
11710 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11711 /* Input mixer */
11712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11716 { }
11717};
11718
11719static struct hda_verb alc662_sue_init_verbs[] = {
11720 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11721 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11722 {}
11723};
11724
11725/*
11726 * generic initialization of ADC, input mixers and output mixers
11727 */
11728static struct hda_verb alc662_auto_init_verbs[] = {
11729 /*
11730 * Unmute ADC and set the default input to mic-in
11731 */
11732 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11734
11735 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11736 * mixer widget
11737 * Note: PASD motherboards uses the Line In 2 as the input for front
11738 * panel mic (mic 2)
11739 */
11740 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011746
11747 /*
11748 * Set up output mixers (0x0c - 0x0f)
11749 */
11750 /* set vol=0 to output mixers */
11751 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11752 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11753 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11754
11755 /* set up input amps for analog loopback */
11756 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020011757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011763
11764
11765 /* FIXME: use matrix-type input source selection */
11766 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11767 /* Input mixer */
11768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020011769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011770 { }
11771};
11772
11773/* capture mixer elements */
11774static struct snd_kcontrol_new alc662_capture_mixer[] = {
11775 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11776 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11777 {
11778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11779 /* The multiple "Capture Source" controls confuse alsamixer
11780 * So call somewhat different..
11781 * FIXME: the controls appear in the "playback" view!
11782 */
11783 /* .name = "Capture Source", */
11784 .name = "Input Source",
11785 .count = 1,
11786 .info = alc882_mux_enum_info,
11787 .get = alc882_mux_enum_get,
11788 .put = alc882_mux_enum_put,
11789 },
11790 { } /* end */
11791};
11792
11793static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11794{
11795 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011796 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011797
11798 present = snd_hda_codec_read(codec, 0x14, 0,
11799 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011800 bits = present ? HDA_AMP_MUTE : 0;
11801 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11802 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011803}
11804
11805static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11806{
11807 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011808 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011809
11810 present = snd_hda_codec_read(codec, 0x1b, 0,
11811 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011812 bits = present ? HDA_AMP_MUTE : 0;
11813 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11814 HDA_AMP_MUTE, bits);
11815 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11816 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011817}
11818
11819static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11820 unsigned int res)
11821{
11822 if ((res >> 26) == ALC880_HP_EVENT)
11823 alc662_lenovo_101e_all_automute(codec);
11824 if ((res >> 26) == ALC880_FRONT_EVENT)
11825 alc662_lenovo_101e_ispeaker_automute(codec);
11826}
11827
Takashi Iwaicb53c622007-08-10 17:21:45 +020011828#ifdef CONFIG_SND_HDA_POWER_SAVE
11829#define alc662_loopbacks alc880_loopbacks
11830#endif
11831
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011832
11833/* pcm configuration: identiacal with ALC880 */
11834#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11835#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11836#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11837#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11838
11839/*
11840 * configuration and preset
11841 */
11842static const char *alc662_models[ALC662_MODEL_LAST] = {
11843 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11844 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11845 [ALC662_3ST_6ch] = "3stack-6ch",
11846 [ALC662_5ST_DIG] = "6stack-dig",
11847 [ALC662_LENOVO_101E] = "lenovo-101e",
11848 [ALC662_AUTO] = "auto",
11849};
11850
11851static struct snd_pci_quirk alc662_cfg_tbl[] = {
11852 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11853 {}
11854};
11855
11856static struct alc_config_preset alc662_presets[] = {
11857 [ALC662_3ST_2ch_DIG] = {
11858 .mixers = { alc662_3ST_2ch_mixer },
11859 .init_verbs = { alc662_init_verbs },
11860 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11861 .dac_nids = alc662_dac_nids,
11862 .dig_out_nid = ALC662_DIGOUT_NID,
11863 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11864 .adc_nids = alc662_adc_nids,
11865 .dig_in_nid = ALC662_DIGIN_NID,
11866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11867 .channel_mode = alc662_3ST_2ch_modes,
11868 .input_mux = &alc662_capture_source,
11869 },
11870 [ALC662_3ST_6ch_DIG] = {
11871 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11872 .init_verbs = { alc662_init_verbs },
11873 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11874 .dac_nids = alc662_dac_nids,
11875 .dig_out_nid = ALC662_DIGOUT_NID,
11876 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11877 .adc_nids = alc662_adc_nids,
11878 .dig_in_nid = ALC662_DIGIN_NID,
11879 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11880 .channel_mode = alc662_3ST_6ch_modes,
11881 .need_dac_fix = 1,
11882 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011883 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011884 [ALC662_3ST_6ch] = {
11885 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11886 .init_verbs = { alc662_init_verbs },
11887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11888 .dac_nids = alc662_dac_nids,
11889 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11890 .adc_nids = alc662_adc_nids,
11891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11892 .channel_mode = alc662_3ST_6ch_modes,
11893 .need_dac_fix = 1,
11894 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011895 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011896 [ALC662_5ST_DIG] = {
11897 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11898 .init_verbs = { alc662_init_verbs },
11899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11900 .dac_nids = alc662_dac_nids,
11901 .dig_out_nid = ALC662_DIGOUT_NID,
11902 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11903 .adc_nids = alc662_adc_nids,
11904 .dig_in_nid = ALC662_DIGIN_NID,
11905 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11906 .channel_mode = alc662_5stack_modes,
11907 .input_mux = &alc662_capture_source,
11908 },
11909 [ALC662_LENOVO_101E] = {
11910 .mixers = { alc662_lenovo_101e_mixer },
11911 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11913 .dac_nids = alc662_dac_nids,
11914 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11915 .adc_nids = alc662_adc_nids,
11916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11917 .channel_mode = alc662_3ST_2ch_modes,
11918 .input_mux = &alc662_lenovo_101e_capture_source,
11919 .unsol_event = alc662_lenovo_101e_unsol_event,
11920 .init_hook = alc662_lenovo_101e_all_automute,
11921 },
11922
11923};
11924
11925
11926/*
11927 * BIOS auto configuration
11928 */
11929
11930/* add playback controls from the parsed DAC table */
11931static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11932 const struct auto_pin_cfg *cfg)
11933{
11934 char name[32];
11935 static const char *chname[4] = {
11936 "Front", "Surround", NULL /*CLFE*/, "Side"
11937 };
11938 hda_nid_t nid;
11939 int i, err;
11940
11941 for (i = 0; i < cfg->line_outs; i++) {
11942 if (!spec->multiout.dac_nids[i])
11943 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020011944 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011945 if (i == 2) {
11946 /* Center/LFE */
11947 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11948 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011949 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11950 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011951 if (err < 0)
11952 return err;
11953 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11954 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011955 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11956 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011957 if (err < 0)
11958 return err;
11959 err = add_control(spec, ALC_CTL_BIND_MUTE,
11960 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011961 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11962 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011963 if (err < 0)
11964 return err;
11965 err = add_control(spec, ALC_CTL_BIND_MUTE,
11966 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011967 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11968 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011969 if (err < 0)
11970 return err;
11971 } else {
11972 sprintf(name, "%s Playback Volume", chname[i]);
11973 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011974 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11975 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011976 if (err < 0)
11977 return err;
11978 sprintf(name, "%s Playback Switch", chname[i]);
11979 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011980 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11981 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011982 if (err < 0)
11983 return err;
11984 }
11985 }
11986 return 0;
11987}
11988
11989/* add playback controls for speaker and HP outputs */
11990static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11991 const char *pfx)
11992{
11993 hda_nid_t nid;
11994 int err;
11995 char name[32];
11996
11997 if (!pin)
11998 return 0;
11999
12000 if (alc880_is_fixed_pin(pin)) {
12001 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12002 /* printk("DAC nid=%x\n",nid); */
12003 /* specify the DAC as the extra output */
12004 if (!spec->multiout.hp_nid)
12005 spec->multiout.hp_nid = nid;
12006 else
12007 spec->multiout.extra_out_nid[0] = nid;
12008 /* control HP volume/switch on the output mixer amp */
12009 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12010 sprintf(name, "%s Playback Volume", pfx);
12011 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12012 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12013 if (err < 0)
12014 return err;
12015 sprintf(name, "%s Playback Switch", pfx);
12016 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12017 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
12018 if (err < 0)
12019 return err;
12020 } else if (alc880_is_multi_pin(pin)) {
12021 /* set manual connection */
12022 /* we have only a switch on HP-out PIN */
12023 sprintf(name, "%s Playback Switch", pfx);
12024 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12025 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12026 if (err < 0)
12027 return err;
12028 }
12029 return 0;
12030}
12031
12032/* create playback/capture controls for input pins */
12033static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
12034 const struct auto_pin_cfg *cfg)
12035{
12036 struct hda_input_mux *imux = &spec->private_imux;
12037 int i, err, idx;
12038
12039 for (i = 0; i < AUTO_PIN_LAST; i++) {
12040 if (alc880_is_input_pin(cfg->input_pins[i])) {
12041 idx = alc880_input_pin_idx(cfg->input_pins[i]);
12042 err = new_analog_input(spec, cfg->input_pins[i],
12043 auto_pin_cfg_labels[i],
12044 idx, 0x0b);
12045 if (err < 0)
12046 return err;
12047 imux->items[imux->num_items].label =
12048 auto_pin_cfg_labels[i];
12049 imux->items[imux->num_items].index =
12050 alc880_input_pin_idx(cfg->input_pins[i]);
12051 imux->num_items++;
12052 }
12053 }
12054 return 0;
12055}
12056
12057static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
12058 hda_nid_t nid, int pin_type,
12059 int dac_idx)
12060{
12061 /* set as output */
12062 snd_hda_codec_write(codec, nid, 0,
12063 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12064 snd_hda_codec_write(codec, nid, 0,
12065 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12066 /* need the manual connection? */
12067 if (alc880_is_multi_pin(nid)) {
12068 struct alc_spec *spec = codec->spec;
12069 int idx = alc880_multi_pin_idx(nid);
12070 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
12071 AC_VERB_SET_CONNECT_SEL,
12072 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
12073 }
12074}
12075
12076static void alc662_auto_init_multi_out(struct hda_codec *codec)
12077{
12078 struct alc_spec *spec = codec->spec;
12079 int i;
12080
12081 for (i = 0; i <= HDA_SIDE; i++) {
12082 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012083 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012084 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012085 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012086 i);
12087 }
12088}
12089
12090static void alc662_auto_init_hp_out(struct hda_codec *codec)
12091{
12092 struct alc_spec *spec = codec->spec;
12093 hda_nid_t pin;
12094
12095 pin = spec->autocfg.hp_pins[0];
12096 if (pin) /* connect to front */
12097 /* use dac 0 */
12098 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12099}
12100
12101#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
12102#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
12103
12104static void alc662_auto_init_analog_input(struct hda_codec *codec)
12105{
12106 struct alc_spec *spec = codec->spec;
12107 int i;
12108
12109 for (i = 0; i < AUTO_PIN_LAST; i++) {
12110 hda_nid_t nid = spec->autocfg.input_pins[i];
12111 if (alc662_is_input_pin(nid)) {
12112 snd_hda_codec_write(codec, nid, 0,
12113 AC_VERB_SET_PIN_WIDGET_CONTROL,
12114 (i <= AUTO_PIN_FRONT_MIC ?
12115 PIN_VREF80 : PIN_IN));
12116 if (nid != ALC662_PIN_CD_NID)
12117 snd_hda_codec_write(codec, nid, 0,
12118 AC_VERB_SET_AMP_GAIN_MUTE,
12119 AMP_OUT_MUTE);
12120 }
12121 }
12122}
12123
12124static int alc662_parse_auto_config(struct hda_codec *codec)
12125{
12126 struct alc_spec *spec = codec->spec;
12127 int err;
12128 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
12129
12130 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12131 alc662_ignore);
12132 if (err < 0)
12133 return err;
12134 if (!spec->autocfg.line_outs)
12135 return 0; /* can't find valid BIOS pin config */
12136
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012137 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12138 if (err < 0)
12139 return err;
12140 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
12141 if (err < 0)
12142 return err;
12143 err = alc662_auto_create_extra_out(spec,
12144 spec->autocfg.speaker_pins[0],
12145 "Speaker");
12146 if (err < 0)
12147 return err;
12148 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
12149 "Headphone");
12150 if (err < 0)
12151 return err;
12152 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
12153 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012154 return err;
12155
12156 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12157
12158 if (spec->autocfg.dig_out_pin)
12159 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
12160
12161 if (spec->kctl_alloc)
12162 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12163
12164 spec->num_mux_defs = 1;
12165 spec->input_mux = &spec->private_imux;
12166
Takashi Iwai8c87286f2007-06-19 12:11:16 +020012167 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012168 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
12169 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020012170 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012171}
12172
12173/* additional initialization for auto-configuration model */
12174static void alc662_auto_init(struct hda_codec *codec)
12175{
12176 alc662_auto_init_multi_out(codec);
12177 alc662_auto_init_hp_out(codec);
12178 alc662_auto_init_analog_input(codec);
12179}
12180
12181static int patch_alc662(struct hda_codec *codec)
12182{
12183 struct alc_spec *spec;
12184 int err, board_config;
12185
12186 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12187 if (!spec)
12188 return -ENOMEM;
12189
12190 codec->spec = spec;
12191
12192 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
12193 alc662_models,
12194 alc662_cfg_tbl);
12195 if (board_config < 0) {
12196 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
12197 "trying auto-probe from BIOS...\n");
12198 board_config = ALC662_AUTO;
12199 }
12200
12201 if (board_config == ALC662_AUTO) {
12202 /* automatic parse from the BIOS config */
12203 err = alc662_parse_auto_config(codec);
12204 if (err < 0) {
12205 alc_free(codec);
12206 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020012207 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012208 printk(KERN_INFO
12209 "hda_codec: Cannot set up configuration "
12210 "from BIOS. Using base mode...\n");
12211 board_config = ALC662_3ST_2ch_DIG;
12212 }
12213 }
12214
12215 if (board_config != ALC662_AUTO)
12216 setup_preset(spec, &alc662_presets[board_config]);
12217
12218 spec->stream_name_analog = "ALC662 Analog";
12219 spec->stream_analog_playback = &alc662_pcm_analog_playback;
12220 spec->stream_analog_capture = &alc662_pcm_analog_capture;
12221
12222 spec->stream_name_digital = "ALC662 Digital";
12223 spec->stream_digital_playback = &alc662_pcm_digital_playback;
12224 spec->stream_digital_capture = &alc662_pcm_digital_capture;
12225
12226 if (!spec->adc_nids && spec->input_mux) {
12227 spec->adc_nids = alc662_adc_nids;
12228 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12229 }
12230
12231 codec->patch_ops = alc_patch_ops;
12232 if (board_config == ALC662_AUTO)
12233 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012234#ifdef CONFIG_SND_HDA_POWER_SAVE
12235 if (!spec->loopback.amplist)
12236 spec->loopback.amplist = alc662_loopbacks;
12237#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012238
12239 return 0;
12240}
12241
12242/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070012243 * patch entries
12244 */
12245struct hda_codec_preset snd_hda_preset_realtek[] = {
12246 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012247 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020012248 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012249 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012250 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012251 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
12252 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
12253 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012254 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
12255 .patch = patch_alc883 },
12256 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
12257 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012258 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070012259 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012260 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012261 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012262 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070012263 {} /* terminator */
12264};