Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for ALC 260/880/882 codecs |
| 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 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 | |
| 35 | |
| 36 | /* ALC880 board config type */ |
| 37 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | ALC880_3ST, |
| 39 | ALC880_3ST_DIG, |
| 40 | ALC880_5ST, |
| 41 | ALC880_5ST_DIG, |
| 42 | ALC880_W810, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 43 | ALC880_Z71V, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 44 | ALC880_6ST, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 45 | ALC880_6ST_DIG, |
| 46 | ALC880_F1734, |
| 47 | ALC880_ASUS, |
| 48 | ALC880_ASUS_DIG, |
| 49 | ALC880_ASUS_W1V, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 50 | ALC880_ASUS_DIG2, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 51 | ALC880_UNIWILL_DIG, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 52 | ALC880_CLEVO, |
| 53 | ALC880_TCL_S700, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 54 | ALC880_LG, |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 55 | ALC880_LG_LW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 56 | #ifdef CONFIG_SND_DEBUG |
| 57 | ALC880_TEST, |
| 58 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 59 | ALC880_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 60 | ALC880_MODEL_LAST /* last tag */ |
| 61 | }; |
| 62 | |
| 63 | /* ALC260 models */ |
| 64 | enum { |
| 65 | ALC260_BASIC, |
| 66 | ALC260_HP, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 67 | ALC260_HP_3013, |
| 68 | ALC260_FUJITSU_S702X, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 69 | ALC260_ACER, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 70 | #ifdef CONFIG_SND_DEBUG |
| 71 | ALC260_TEST, |
| 72 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 73 | ALC260_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 74 | ALC260_MODEL_LAST /* last tag */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 77 | /* ALC262 models */ |
| 78 | enum { |
| 79 | ALC262_BASIC, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 80 | ALC262_FUJITSU, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 81 | ALC262_AUTO, |
| 82 | ALC262_MODEL_LAST /* last tag */ |
| 83 | }; |
| 84 | |
| 85 | /* ALC861 models */ |
| 86 | enum { |
| 87 | ALC861_3ST, |
| 88 | ALC861_3ST_DIG, |
| 89 | ALC861_6ST_DIG, |
| 90 | ALC861_AUTO, |
| 91 | ALC861_MODEL_LAST, |
| 92 | }; |
| 93 | |
| 94 | /* ALC882 models */ |
| 95 | enum { |
| 96 | ALC882_3ST_DIG, |
| 97 | ALC882_6ST_DIG, |
| 98 | ALC882_AUTO, |
| 99 | ALC882_MODEL_LAST, |
| 100 | }; |
| 101 | |
| 102 | /* for GPIO Poll */ |
| 103 | #define GPIO_MASK 0x03 |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | struct alc_spec { |
| 106 | /* codec parameterization */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 107 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | unsigned int num_mixers; |
| 109 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 110 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 111 | * don't forget NULL termination! |
| 112 | */ |
| 113 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 115 | char *stream_name_analog; /* analog PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | struct hda_pcm_stream *stream_analog_playback; |
| 117 | struct hda_pcm_stream *stream_analog_capture; |
| 118 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 119 | char *stream_name_digital; /* digital PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | struct hda_pcm_stream *stream_digital_playback; |
| 121 | struct hda_pcm_stream *stream_digital_capture; |
| 122 | |
| 123 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 124 | struct hda_multi_out multiout; /* playback set-up |
| 125 | * max_channels, dacs must be set |
| 126 | * dig_out_nid and hp_nid are optional |
| 127 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | /* capture */ |
| 130 | unsigned int num_adc_nids; |
| 131 | hda_nid_t *adc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 132 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 135 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | const struct hda_input_mux *input_mux; |
| 137 | unsigned int cur_mux[3]; |
| 138 | |
| 139 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 140 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | int num_channel_mode; |
| 142 | |
| 143 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 144 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 145 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 146 | /* dynamic controls, init_verbs and input_mux */ |
| 147 | struct auto_pin_cfg autocfg; |
| 148 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 149 | struct snd_kcontrol_new *kctl_alloc; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 150 | struct hda_input_mux private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 151 | hda_nid_t private_dac_nids[5]; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 152 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 153 | /* hooks */ |
| 154 | void (*init_hook)(struct hda_codec *codec); |
| 155 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
| 156 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 157 | /* for pin sensing */ |
| 158 | unsigned int sense_updated: 1; |
| 159 | unsigned int jack_present: 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | /* |
| 163 | * configuration template - to be copied to the spec instance |
| 164 | */ |
| 165 | struct alc_config_preset { |
| 166 | struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ |
| 167 | const struct hda_verb *init_verbs[5]; |
| 168 | unsigned int num_dacs; |
| 169 | hda_nid_t *dac_nids; |
| 170 | hda_nid_t dig_out_nid; /* optional */ |
| 171 | hda_nid_t hp_nid; /* optional */ |
| 172 | unsigned int num_adc_nids; |
| 173 | hda_nid_t *adc_nids; |
| 174 | hda_nid_t dig_in_nid; |
| 175 | unsigned int num_channel_mode; |
| 176 | const struct hda_channel_mode *channel_mode; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 177 | unsigned int num_mux_defs; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 178 | const struct hda_input_mux *input_mux; |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 179 | void (*unsol_event)(struct hda_codec *, unsigned int); |
| 180 | void (*init_hook)(struct hda_codec *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | }; |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | /* |
| 185 | * input MUX handling |
| 186 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 187 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
| 189 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 190 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 191 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 192 | if (mux_idx >= spec->num_mux_defs) |
| 193 | mux_idx = 0; |
| 194 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 197 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
| 199 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 200 | struct alc_spec *spec = codec->spec; |
| 201 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 202 | |
| 203 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 204 | return 0; |
| 205 | } |
| 206 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 207 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | { |
| 209 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 210 | struct alc_spec *spec = codec->spec; |
| 211 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 212 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 213 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 215 | } |
| 216 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* |
| 219 | * channel mode setting |
| 220 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 221 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
| 223 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 224 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 225 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 226 | spec->num_channel_mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 229 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | { |
| 231 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 232 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 233 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 234 | spec->num_channel_mode, spec->multiout.max_channels); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 237 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
| 239 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 240 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 241 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 242 | spec->num_channel_mode, &spec->multiout.max_channels); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | /* |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 246 | * Control the mode of pin widget settings via the mixer. "pc" is used |
| 247 | * instead of "%" to avoid consequences of accidently treating the % as |
| 248 | * being part of a format specifier. Maximum allowed length of a value is |
| 249 | * 63 characters plus NULL terminator. |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 250 | * |
| 251 | * Note: some retasking pin complexes seem to ignore requests for input |
| 252 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these |
| 253 | * are requested. Therefore order this list so that this behaviour will not |
| 254 | * cause problems when mixer clients move through the enum sequentially. |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 255 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
| 256 | * March 2006. |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 257 | */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 258 | static char *alc_pin_mode_names[] = { |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 259 | "Mic 50pc bias", "Mic 80pc bias", |
| 260 | "Line in", "Line out", "Headphone out", |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 261 | }; |
| 262 | static unsigned char alc_pin_mode_values[] = { |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 263 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 264 | }; |
| 265 | /* The control can present all 5 options, or it can limit the options based |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 266 | * in the pin being assumed to be exclusively an input or an output pin. In |
| 267 | * addition, "input" pins may or may not process the mic bias option |
| 268 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to |
| 269 | * accept requests for bias as of chip versions up to March 2006) and/or |
| 270 | * wiring in the computer. |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 271 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 272 | #define ALC_PIN_DIR_IN 0x00 |
| 273 | #define ALC_PIN_DIR_OUT 0x01 |
| 274 | #define ALC_PIN_DIR_INOUT 0x02 |
| 275 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 |
| 276 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 277 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 278 | /* Info about the pin modes supported by the different pin direction modes. |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 279 | * For each direction the minimum and maximum values are given. |
| 280 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 281 | static signed char alc_pin_mode_dir_info[5][2] = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 282 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
| 283 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ |
| 284 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 285 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
| 286 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 287 | }; |
| 288 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) |
| 289 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) |
| 290 | #define alc_pin_mode_n_items(_dir) \ |
| 291 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) |
| 292 | |
| 293 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 294 | { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 295 | unsigned int item_num = uinfo->value.enumerated.item; |
| 296 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| 297 | |
| 298 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 299 | uinfo->count = 1; |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 300 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
| 301 | |
| 302 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) |
| 303 | item_num = alc_pin_mode_min(dir); |
| 304 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 308 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 309 | { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 310 | unsigned int i; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 311 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 312 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 313 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 314 | long *valp = ucontrol->value.integer.value; |
| 315 | unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 316 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 317 | /* Find enumerated value for current pinctl setting */ |
| 318 | i = alc_pin_mode_min(dir); |
| 319 | while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir)) |
| 320 | i++; |
| 321 | *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir); |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 326 | { |
| 327 | signed int change; |
| 328 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 329 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 330 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| 331 | long val = *ucontrol->value.integer.value; |
| 332 | unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); |
| 333 | |
| 334 | if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir)) |
| 335 | val = alc_pin_mode_min(dir); |
| 336 | |
| 337 | change = pinctl != alc_pin_mode_values[val]; |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 338 | if (change) { |
| 339 | /* Set pin mode to that requested */ |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 340 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 341 | alc_pin_mode_values[val]); |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 342 | |
| 343 | /* Also enable the retasking pin's input/output as required |
| 344 | * for the requested pin mode. Enum values of 2 or less are |
| 345 | * input modes. |
| 346 | * |
| 347 | * Dynamically switching the input/output buffers probably |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 348 | * reduces noise slightly (particularly on input) so we'll |
| 349 | * do it. However, having both input and output buffers |
| 350 | * enabled simultaneously doesn't seem to be problematic if |
| 351 | * this turns out to be necessary in the future. |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 352 | */ |
| 353 | if (val <= 2) { |
| 354 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, |
| 355 | AMP_OUT_MUTE); |
| 356 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, |
| 357 | AMP_IN_UNMUTE(0)); |
| 358 | } else { |
| 359 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, |
| 360 | AMP_IN_MUTE(0)); |
| 361 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, |
| 362 | AMP_OUT_UNMUTE); |
| 363 | } |
| 364 | } |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 365 | return change; |
| 366 | } |
| 367 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 368 | #define ALC_PIN_MODE(xname, nid, dir) \ |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 369 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 370 | .info = alc_pin_mode_info, \ |
| 371 | .get = alc_pin_mode_get, \ |
| 372 | .put = alc_pin_mode_put, \ |
| 373 | .private_value = nid | (dir<<16) } |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 374 | |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 375 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
| 376 | * together using a mask with more than one bit set. This control is |
| 377 | * currently used only by the ALC260 test model. At this stage they are not |
| 378 | * needed for any "production" models. |
| 379 | */ |
| 380 | #ifdef CONFIG_SND_DEBUG |
| 381 | static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 382 | { |
| 383 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 384 | uinfo->count = 1; |
| 385 | uinfo->value.integer.min = 0; |
| 386 | uinfo->value.integer.max = 1; |
| 387 | return 0; |
| 388 | } |
| 389 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 390 | { |
| 391 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 392 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 393 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 394 | long *valp = ucontrol->value.integer.value; |
| 395 | unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); |
| 396 | |
| 397 | *valp = (val & mask) != 0; |
| 398 | return 0; |
| 399 | } |
| 400 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 401 | { |
| 402 | signed int change; |
| 403 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 404 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 405 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 406 | long val = *ucontrol->value.integer.value; |
| 407 | unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); |
| 408 | |
| 409 | /* Set/unset the masked GPIO bit(s) as needed */ |
| 410 | change = (val==0?0:mask) != (gpio_data & mask); |
| 411 | if (val==0) |
| 412 | gpio_data &= ~mask; |
| 413 | else |
| 414 | gpio_data |= mask; |
| 415 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data); |
| 416 | |
| 417 | return change; |
| 418 | } |
| 419 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ |
| 420 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 421 | .info = alc_gpio_data_info, \ |
| 422 | .get = alc_gpio_data_get, \ |
| 423 | .put = alc_gpio_data_put, \ |
| 424 | .private_value = nid | (mask<<16) } |
| 425 | #endif /* CONFIG_SND_DEBUG */ |
| 426 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 427 | /* A switch control to allow the enabling of the digital IO pins on the |
| 428 | * ALC260. This is incredibly simplistic; the intention of this control is |
| 429 | * to provide something in the test model allowing digital outputs to be |
| 430 | * identified if present. If models are found which can utilise these |
| 431 | * outputs a more complete mixer control can be devised for those models if |
| 432 | * necessary. |
| 433 | */ |
| 434 | #ifdef CONFIG_SND_DEBUG |
| 435 | static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 436 | { |
| 437 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 438 | uinfo->count = 1; |
| 439 | uinfo->value.integer.min = 0; |
| 440 | uinfo->value.integer.max = 1; |
| 441 | return 0; |
| 442 | } |
| 443 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 444 | { |
| 445 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 446 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 447 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 448 | long *valp = ucontrol->value.integer.value; |
| 449 | unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); |
| 450 | |
| 451 | *valp = (val & mask) != 0; |
| 452 | return 0; |
| 453 | } |
| 454 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 455 | { |
| 456 | signed int change; |
| 457 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 458 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 459 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 460 | long val = *ucontrol->value.integer.value; |
| 461 | unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); |
| 462 | |
| 463 | /* Set/unset the masked control bit(s) as needed */ |
| 464 | change = (val==0?0:mask) != (ctrl_data & mask); |
| 465 | if (val==0) |
| 466 | ctrl_data &= ~mask; |
| 467 | else |
| 468 | ctrl_data |= mask; |
| 469 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data); |
| 470 | |
| 471 | return change; |
| 472 | } |
| 473 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ |
| 474 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 475 | .info = alc_spdif_ctrl_info, \ |
| 476 | .get = alc_spdif_ctrl_get, \ |
| 477 | .put = alc_spdif_ctrl_put, \ |
| 478 | .private_value = nid | (mask<<16) } |
| 479 | #endif /* CONFIG_SND_DEBUG */ |
| 480 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 481 | /* |
| 482 | * set up from the preset table |
| 483 | */ |
| 484 | static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) |
| 485 | { |
| 486 | int i; |
| 487 | |
| 488 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
| 489 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; |
| 490 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) |
| 491 | spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; |
| 492 | |
| 493 | spec->channel_mode = preset->channel_mode; |
| 494 | spec->num_channel_mode = preset->num_channel_mode; |
| 495 | |
| 496 | spec->multiout.max_channels = spec->channel_mode[0].channels; |
| 497 | |
| 498 | spec->multiout.num_dacs = preset->num_dacs; |
| 499 | spec->multiout.dac_nids = preset->dac_nids; |
| 500 | spec->multiout.dig_out_nid = preset->dig_out_nid; |
| 501 | spec->multiout.hp_nid = preset->hp_nid; |
| 502 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 503 | spec->num_mux_defs = preset->num_mux_defs; |
| 504 | if (! spec->num_mux_defs) |
| 505 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 506 | spec->input_mux = preset->input_mux; |
| 507 | |
| 508 | spec->num_adc_nids = preset->num_adc_nids; |
| 509 | spec->adc_nids = preset->adc_nids; |
| 510 | spec->dig_in_nid = preset->dig_in_nid; |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 511 | |
| 512 | spec->unsol_event = preset->unsol_event; |
| 513 | spec->init_hook = preset->init_hook; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 516 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 517 | * ALC880 3-stack model |
| 518 | * |
| 519 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) |
| 520 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b |
| 521 | * HP = 0x19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | */ |
| 523 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 524 | static hda_nid_t alc880_dac_nids[4] = { |
| 525 | /* front, rear, clfe, rear_surr */ |
| 526 | 0x02, 0x05, 0x04, 0x03 |
| 527 | }; |
| 528 | |
| 529 | static hda_nid_t alc880_adc_nids[3] = { |
| 530 | /* ADC0-2 */ |
| 531 | 0x07, 0x08, 0x09, |
| 532 | }; |
| 533 | |
| 534 | /* The datasheet says the node 0x07 is connected from inputs, |
| 535 | * but it shows zero connection in the real implementation on some devices. |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 536 | * Note: this is a 915GAV bug, fixed on 915GLV |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 538 | static hda_nid_t alc880_adc_nids_alt[2] = { |
| 539 | /* ADC1-2 */ |
| 540 | 0x08, 0x09, |
| 541 | }; |
| 542 | |
| 543 | #define ALC880_DIGOUT_NID 0x06 |
| 544 | #define ALC880_DIGIN_NID 0x0a |
| 545 | |
| 546 | static struct hda_input_mux alc880_capture_source = { |
| 547 | .num_items = 4, |
| 548 | .items = { |
| 549 | { "Mic", 0x0 }, |
| 550 | { "Front Mic", 0x3 }, |
| 551 | { "Line", 0x2 }, |
| 552 | { "CD", 0x4 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | /* channel source setting (2/6 channel selection for 3-stack) */ |
| 557 | /* 2ch mode */ |
| 558 | static struct hda_verb alc880_threestack_ch2_init[] = { |
| 559 | /* set line-in to input, mute it */ |
| 560 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 561 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 562 | /* set mic-in to input vref 80%, mute it */ |
| 563 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 564 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | { } /* end */ |
| 566 | }; |
| 567 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 568 | /* 6ch mode */ |
| 569 | static struct hda_verb alc880_threestack_ch6_init[] = { |
| 570 | /* set line-in to output, unmute it */ |
| 571 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 572 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 573 | /* set mic-in to output, unmute it */ |
| 574 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 575 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 576 | { } /* end */ |
| 577 | }; |
| 578 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 579 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 580 | { 2, alc880_threestack_ch2_init }, |
| 581 | { 6, alc880_threestack_ch6_init }, |
| 582 | }; |
| 583 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 584 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 585 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 586 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 587 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 588 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 589 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 590 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 591 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 592 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 594 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 595 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 596 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 597 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 598 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 599 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 600 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 601 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 602 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 604 | { |
| 605 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 606 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 607 | .info = alc_ch_mode_info, |
| 608 | .get = alc_ch_mode_get, |
| 609 | .put = alc_ch_mode_put, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 610 | }, |
| 611 | { } /* end */ |
| 612 | }; |
| 613 | |
| 614 | /* capture mixer elements */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 615 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 616 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 617 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 618 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 619 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 620 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 621 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 622 | { |
| 623 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 624 | /* The multiple "Capture Source" controls confuse alsamixer |
| 625 | * So call somewhat different.. |
| 626 | * FIXME: the controls appear in the "playback" view! |
| 627 | */ |
| 628 | /* .name = "Capture Source", */ |
| 629 | .name = "Input Source", |
| 630 | .count = 3, |
| 631 | .info = alc_mux_enum_info, |
| 632 | .get = alc_mux_enum_get, |
| 633 | .put = alc_mux_enum_put, |
| 634 | }, |
| 635 | { } /* end */ |
| 636 | }; |
| 637 | |
| 638 | /* capture mixer elements (in case NID 0x07 not available) */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 639 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 640 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 641 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 642 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 643 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | { |
| 645 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 646 | /* The multiple "Capture Source" controls confuse alsamixer |
| 647 | * So call somewhat different.. |
| 648 | * FIXME: the controls appear in the "playback" view! |
| 649 | */ |
| 650 | /* .name = "Capture Source", */ |
| 651 | .name = "Input Source", |
| 652 | .count = 2, |
| 653 | .info = alc_mux_enum_info, |
| 654 | .get = alc_mux_enum_get, |
| 655 | .put = alc_mux_enum_put, |
| 656 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | { } /* end */ |
| 658 | }; |
| 659 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 660 | |
| 661 | |
| 662 | /* |
| 663 | * ALC880 5-stack model |
| 664 | * |
| 665 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) |
| 666 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
| 667 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 |
| 668 | */ |
| 669 | |
| 670 | /* additional mixers to alc880_three_stack_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 671 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 672 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 673 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | { } /* end */ |
| 675 | }; |
| 676 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 677 | /* channel source setting (6/8 channel selection for 5-stack) */ |
| 678 | /* 6ch mode */ |
| 679 | static struct hda_verb alc880_fivestack_ch6_init[] = { |
| 680 | /* set line-in to input, mute it */ |
| 681 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 682 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 683 | { } /* end */ |
| 684 | }; |
| 685 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 686 | /* 8ch mode */ |
| 687 | static struct hda_verb alc880_fivestack_ch8_init[] = { |
| 688 | /* set line-in to output, unmute it */ |
| 689 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 690 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 691 | { } /* end */ |
| 692 | }; |
| 693 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 694 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 695 | { 6, alc880_fivestack_ch6_init }, |
| 696 | { 8, alc880_fivestack_ch8_init }, |
| 697 | }; |
| 698 | |
| 699 | |
| 700 | /* |
| 701 | * ALC880 6-stack model |
| 702 | * |
| 703 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) |
| 704 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
| 705 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b |
| 706 | */ |
| 707 | |
| 708 | static hda_nid_t alc880_6st_dac_nids[4] = { |
| 709 | /* front, rear, clfe, rear_surr */ |
| 710 | 0x02, 0x03, 0x04, 0x05 |
| 711 | }; |
| 712 | |
| 713 | static struct hda_input_mux alc880_6stack_capture_source = { |
| 714 | .num_items = 4, |
| 715 | .items = { |
| 716 | { "Mic", 0x0 }, |
| 717 | { "Front Mic", 0x1 }, |
| 718 | { "Line", 0x2 }, |
| 719 | { "CD", 0x4 }, |
| 720 | }, |
| 721 | }; |
| 722 | |
| 723 | /* fixed 8-channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 724 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 725 | { 8, NULL }, |
| 726 | }; |
| 727 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 728 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 729 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 730 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 731 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 732 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 733 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 734 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 735 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 736 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 737 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 738 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 739 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 740 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 741 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 742 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 743 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 744 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 745 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 746 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 747 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 748 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 749 | { |
| 750 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 751 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 752 | .info = alc_ch_mode_info, |
| 753 | .get = alc_ch_mode_get, |
| 754 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 755 | }, |
| 756 | { } /* end */ |
| 757 | }; |
| 758 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 759 | |
| 760 | /* |
| 761 | * ALC880 W810 model |
| 762 | * |
| 763 | * W810 has rear IO for: |
| 764 | * Front (DAC 02) |
| 765 | * Surround (DAC 03) |
| 766 | * Center/LFE (DAC 04) |
| 767 | * Digital out (06) |
| 768 | * |
| 769 | * The system also has a pair of internal speakers, and a headphone jack. |
| 770 | * These are both connected to Line2 on the codec, hence to DAC 02. |
| 771 | * |
| 772 | * There is a variable resistor to control the speaker or headphone |
| 773 | * volume. This is a hardware-only device without a software API. |
| 774 | * |
| 775 | * Plugging headphones in will disable the internal speakers. This is |
| 776 | * implemented in hardware, not via the driver using jack sense. In |
| 777 | * a similar fashion, plugging into the rear socket marked "front" will |
| 778 | * disable both the speakers and headphones. |
| 779 | * |
| 780 | * For input, there's a microphone jack, and an "audio in" jack. |
| 781 | * These may not do anything useful with this driver yet, because I |
| 782 | * haven't setup any initialization verbs for these yet... |
| 783 | */ |
| 784 | |
| 785 | static hda_nid_t alc880_w810_dac_nids[3] = { |
| 786 | /* front, rear/surround, clfe */ |
| 787 | 0x02, 0x03, 0x04 |
| 788 | }; |
| 789 | |
| 790 | /* fixed 6 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 791 | static struct hda_channel_mode alc880_w810_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 792 | { 6, NULL } |
| 793 | }; |
| 794 | |
| 795 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 796 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 797 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 798 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 799 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 800 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 801 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 802 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 803 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 804 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 805 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 806 | { } /* end */ |
| 807 | }; |
| 808 | |
| 809 | |
| 810 | /* |
| 811 | * Z710V model |
| 812 | * |
| 813 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) |
| 814 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a |
| 815 | */ |
| 816 | |
| 817 | static hda_nid_t alc880_z71v_dac_nids[1] = { |
| 818 | 0x02 |
| 819 | }; |
| 820 | #define ALC880_Z71V_HP_DAC 0x03 |
| 821 | |
| 822 | /* fixed 2 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 823 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 824 | { 2, NULL } |
| 825 | }; |
| 826 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 827 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 828 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 829 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 830 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 831 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 832 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 833 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 834 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 835 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 836 | { } /* end */ |
| 837 | }; |
| 838 | |
| 839 | |
| 840 | /* FIXME! */ |
| 841 | /* |
| 842 | * ALC880 F1734 model |
| 843 | * |
| 844 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) |
| 845 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 |
| 846 | */ |
| 847 | |
| 848 | static hda_nid_t alc880_f1734_dac_nids[1] = { |
| 849 | 0x03 |
| 850 | }; |
| 851 | #define ALC880_F1734_HP_DAC 0x02 |
| 852 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 853 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 854 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 855 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 856 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 857 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 858 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 859 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 860 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 861 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 862 | { } /* end */ |
| 863 | }; |
| 864 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 865 | |
| 866 | /* FIXME! */ |
| 867 | /* |
| 868 | * ALC880 ASUS model |
| 869 | * |
| 870 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 871 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 872 | * Mic = 0x18, Line = 0x1a |
| 873 | */ |
| 874 | |
| 875 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ |
| 876 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ |
| 877 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 878 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 879 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 880 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 881 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 882 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 883 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 884 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 885 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 886 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 887 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 888 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 889 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 890 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 891 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 892 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 893 | { |
| 894 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 895 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 896 | .info = alc_ch_mode_info, |
| 897 | .get = alc_ch_mode_get, |
| 898 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 899 | }, |
| 900 | { } /* end */ |
| 901 | }; |
| 902 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 903 | /* FIXME! */ |
| 904 | /* |
| 905 | * ALC880 ASUS W1V model |
| 906 | * |
| 907 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 908 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 909 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b |
| 910 | */ |
| 911 | |
| 912 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 913 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 914 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
| 915 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 916 | { } /* end */ |
| 917 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 918 | |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 919 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 920 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 921 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 922 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 923 | { } /* end */ |
| 924 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 925 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 926 | /* TCL S700 */ |
| 927 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { |
| 928 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 929 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 930 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 931 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), |
| 932 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), |
| 933 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), |
| 934 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), |
| 935 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 936 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 937 | { |
| 938 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 939 | /* The multiple "Capture Source" controls confuse alsamixer |
| 940 | * So call somewhat different.. |
| 941 | * FIXME: the controls appear in the "playback" view! |
| 942 | */ |
| 943 | /* .name = "Capture Source", */ |
| 944 | .name = "Input Source", |
| 945 | .count = 1, |
| 946 | .info = alc_mux_enum_info, |
| 947 | .get = alc_mux_enum_get, |
| 948 | .put = alc_mux_enum_put, |
| 949 | }, |
| 950 | { } /* end */ |
| 951 | }; |
| 952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 954 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | */ |
| 956 | static int alc_build_controls(struct hda_codec *codec) |
| 957 | { |
| 958 | struct alc_spec *spec = codec->spec; |
| 959 | int err; |
| 960 | int i; |
| 961 | |
| 962 | for (i = 0; i < spec->num_mixers; i++) { |
| 963 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 964 | if (err < 0) |
| 965 | return err; |
| 966 | } |
| 967 | |
| 968 | if (spec->multiout.dig_out_nid) { |
| 969 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 970 | if (err < 0) |
| 971 | return err; |
| 972 | } |
| 973 | if (spec->dig_in_nid) { |
| 974 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 975 | if (err < 0) |
| 976 | return err; |
| 977 | } |
| 978 | return 0; |
| 979 | } |
| 980 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 981 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | /* |
| 983 | * initialize the codec volumes, etc |
| 984 | */ |
| 985 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 986 | /* |
| 987 | * generic initialization of ADC, input mixers and output mixers |
| 988 | */ |
| 989 | static struct hda_verb alc880_volume_init_verbs[] = { |
| 990 | /* |
| 991 | * Unmute ADC0-2 and set the default input to mic-in |
| 992 | */ |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 993 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 994 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 995 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 996 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 997 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 998 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1000 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 1001 | * mixer widget |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 1003 | * mic (mic 2) |
| 1004 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1005 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1006 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1007 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1008 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 1009 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 1010 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1012 | /* |
| 1013 | * Set up output mixers (0x0c - 0x0f) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1015 | /* set vol=0 to output mixers */ |
| 1016 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1017 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1018 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1019 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1020 | /* set up input amps for analog loopback */ |
| 1021 | /* Amp Indices: DAC = 0, mixer = 1 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1022 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1023 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1024 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1025 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1026 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1027 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1028 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1029 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
| 1031 | { } |
| 1032 | }; |
| 1033 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1034 | /* |
| 1035 | * 3-stack pin configuration: |
| 1036 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b |
| 1037 | */ |
| 1038 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { |
| 1039 | /* |
| 1040 | * preset connection lists of input pins |
| 1041 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 1042 | */ |
| 1043 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
| 1044 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1045 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ |
| 1046 | |
| 1047 | /* |
| 1048 | * Set pin mode and muting |
| 1049 | */ |
| 1050 | /* set front pin widgets 0x14 for output */ |
| 1051 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1052 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1053 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 1054 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1055 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1056 | /* Mic2 (as headphone out) for HP output */ |
| 1057 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1058 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1059 | /* Line In pin widget for input */ |
| 1060 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1061 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1062 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 1063 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1064 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1065 | /* CD pin widget for input */ |
| 1066 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1067 | |
| 1068 | { } |
| 1069 | }; |
| 1070 | |
| 1071 | /* |
| 1072 | * 5-stack pin configuration: |
| 1073 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, |
| 1074 | * line-in/side = 0x1a, f-mic = 0x1b |
| 1075 | */ |
| 1076 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { |
| 1077 | /* |
| 1078 | * preset connection lists of input pins |
| 1079 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 1080 | */ |
| 1081 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1082 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ |
| 1083 | |
| 1084 | /* |
| 1085 | * Set pin mode and muting |
| 1086 | */ |
| 1087 | /* set pin widgets 0x14-0x17 for output */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1088 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1089 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1090 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1091 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1092 | /* unmute pins for output (no gain on this amp) */ |
| 1093 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1094 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1095 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1096 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1097 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1099 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1100 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1101 | /* Mic2 (as headphone out) for HP output */ |
| 1102 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1103 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1104 | /* Line In pin widget for input */ |
| 1105 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1106 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1107 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 1108 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1109 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1110 | /* CD pin widget for input */ |
| 1111 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | |
| 1113 | { } |
| 1114 | }; |
| 1115 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1116 | /* |
| 1117 | * W810 pin configuration: |
| 1118 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b |
| 1119 | */ |
| 1120 | static struct hda_verb alc880_pin_w810_init_verbs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | /* hphone/speaker input selector: front DAC */ |
| 1122 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1123 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1124 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1125 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1126 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1127 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1128 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1129 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1130 | |
| 1131 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1132 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | { } |
| 1135 | }; |
| 1136 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1137 | /* |
| 1138 | * Z71V pin configuration: |
| 1139 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) |
| 1140 | */ |
| 1141 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1142 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1143 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1144 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1145 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1146 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1147 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1148 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1149 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1150 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1151 | |
| 1152 | { } |
| 1153 | }; |
| 1154 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1155 | /* |
| 1156 | * 6-stack pin configuration: |
| 1157 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, |
| 1158 | * line = 0x1a, HP = 0x1b |
| 1159 | */ |
| 1160 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { |
| 1161 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1162 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1163 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1164 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1165 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1166 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1167 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1168 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1169 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1170 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1171 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1172 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1173 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1174 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1175 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1176 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1177 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1178 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1179 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1180 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1181 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1182 | { } |
| 1183 | }; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1184 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1185 | /* FIXME! */ |
| 1186 | /* |
| 1187 | * F1734 pin configuration: |
| 1188 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 |
| 1189 | */ |
| 1190 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { |
| 1191 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 1192 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1193 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1194 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1195 | |
| 1196 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1197 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1198 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1199 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1200 | |
| 1201 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1202 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1203 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1204 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1205 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1206 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1207 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1208 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1209 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1210 | |
| 1211 | { } |
| 1212 | }; |
| 1213 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1214 | /* FIXME! */ |
| 1215 | /* |
| 1216 | * ASUS pin configuration: |
| 1217 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a |
| 1218 | */ |
| 1219 | static struct hda_verb alc880_pin_asus_init_verbs[] = { |
| 1220 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 1221 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1222 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1223 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1224 | |
| 1225 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1226 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1227 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1228 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1229 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1230 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1231 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1232 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1233 | |
| 1234 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1235 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1236 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1237 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1238 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1239 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1240 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1241 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1242 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1243 | |
| 1244 | { } |
| 1245 | }; |
| 1246 | |
| 1247 | /* Enable GPIO mask and set output */ |
| 1248 | static struct hda_verb alc880_gpio1_init_verbs[] = { |
| 1249 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 1250 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 1251 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1252 | |
| 1253 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1254 | }; |
| 1255 | |
| 1256 | /* Enable GPIO mask and set output */ |
| 1257 | static struct hda_verb alc880_gpio2_init_verbs[] = { |
| 1258 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 1259 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 1260 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1261 | |
| 1262 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1263 | }; |
| 1264 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1265 | /* Clevo m520g init */ |
| 1266 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { |
| 1267 | /* headphone output */ |
| 1268 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1269 | /* line-out */ |
| 1270 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1271 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1272 | /* Line-in */ |
| 1273 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1274 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1275 | /* CD */ |
| 1276 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1277 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1278 | /* Mic1 (rear panel) */ |
| 1279 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1280 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1281 | /* Mic2 (front panel) */ |
| 1282 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1283 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1284 | /* headphone */ |
| 1285 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1286 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1287 | /* change to EAPD mode */ |
| 1288 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1289 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| 1290 | |
| 1291 | { } |
| 1292 | }; |
| 1293 | |
| 1294 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
| 1295 | /* Headphone output */ |
| 1296 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1297 | /* Front output*/ |
| 1298 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1299 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1300 | |
| 1301 | /* Line In pin widget for input */ |
| 1302 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1303 | /* CD pin widget for input */ |
| 1304 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1305 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 1306 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1307 | |
| 1308 | /* change to EAPD mode */ |
| 1309 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1310 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, |
| 1311 | |
| 1312 | { } |
| 1313 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1314 | |
| 1315 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1316 | * LG m1 express dual |
| 1317 | * |
| 1318 | * Pin assignment: |
| 1319 | * Rear Line-In/Out (blue): 0x14 |
| 1320 | * Build-in Mic-In: 0x15 |
| 1321 | * Speaker-out: 0x17 |
| 1322 | * HP-Out (green): 0x1b |
| 1323 | * Mic-In/Out (red): 0x19 |
| 1324 | * SPDIF-Out: 0x1e |
| 1325 | */ |
| 1326 | |
| 1327 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ |
| 1328 | static hda_nid_t alc880_lg_dac_nids[3] = { |
| 1329 | 0x05, 0x02, 0x03 |
| 1330 | }; |
| 1331 | |
| 1332 | /* seems analog CD is not working */ |
| 1333 | static struct hda_input_mux alc880_lg_capture_source = { |
| 1334 | .num_items = 3, |
| 1335 | .items = { |
| 1336 | { "Mic", 0x1 }, |
| 1337 | { "Line", 0x5 }, |
| 1338 | { "Internal Mic", 0x6 }, |
| 1339 | }, |
| 1340 | }; |
| 1341 | |
| 1342 | /* 2,4,6 channel modes */ |
| 1343 | static struct hda_verb alc880_lg_ch2_init[] = { |
| 1344 | /* set line-in and mic-in to input */ |
| 1345 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1346 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1347 | { } |
| 1348 | }; |
| 1349 | |
| 1350 | static struct hda_verb alc880_lg_ch4_init[] = { |
| 1351 | /* set line-in to out and mic-in to input */ |
| 1352 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1353 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1354 | { } |
| 1355 | }; |
| 1356 | |
| 1357 | static struct hda_verb alc880_lg_ch6_init[] = { |
| 1358 | /* set line-in and mic-in to output */ |
| 1359 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1360 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1361 | { } |
| 1362 | }; |
| 1363 | |
| 1364 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { |
| 1365 | { 2, alc880_lg_ch2_init }, |
| 1366 | { 4, alc880_lg_ch4_init }, |
| 1367 | { 6, alc880_lg_ch6_init }, |
| 1368 | }; |
| 1369 | |
| 1370 | static struct snd_kcontrol_new alc880_lg_mixer[] = { |
| 1371 | /* FIXME: it's not really "master" but front channels */ |
| 1372 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| 1373 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), |
| 1374 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1375 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1376 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1377 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), |
| 1378 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), |
| 1379 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), |
| 1380 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 1381 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 1382 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), |
| 1383 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), |
| 1384 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), |
| 1385 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), |
| 1386 | { |
| 1387 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1388 | .name = "Channel Mode", |
| 1389 | .info = alc_ch_mode_info, |
| 1390 | .get = alc_ch_mode_get, |
| 1391 | .put = alc_ch_mode_put, |
| 1392 | }, |
| 1393 | { } /* end */ |
| 1394 | }; |
| 1395 | |
| 1396 | static struct hda_verb alc880_lg_init_verbs[] = { |
| 1397 | /* set capture source to mic-in */ |
| 1398 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1399 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1400 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1401 | /* mute all amp mixer inputs */ |
| 1402 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, |
| 1403 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, |
| 1404 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, |
| 1405 | /* line-in to input */ |
| 1406 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1407 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1408 | /* built-in mic */ |
| 1409 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1410 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1411 | /* speaker-out */ |
| 1412 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1413 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1414 | /* mic-in to input */ |
| 1415 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1416 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1417 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1418 | /* HP-out */ |
| 1419 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1420 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1421 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1422 | /* jack sense */ |
| 1423 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, |
| 1424 | { } |
| 1425 | }; |
| 1426 | |
| 1427 | /* toggle speaker-output according to the hp-jack state */ |
| 1428 | static void alc880_lg_automute(struct hda_codec *codec) |
| 1429 | { |
| 1430 | unsigned int present; |
| 1431 | |
| 1432 | present = snd_hda_codec_read(codec, 0x1b, 0, |
| 1433 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1434 | snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, |
| 1435 | 0x80, present ? 0x80 : 0); |
| 1436 | snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, |
| 1437 | 0x80, present ? 0x80 : 0); |
| 1438 | } |
| 1439 | |
| 1440 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1441 | { |
| 1442 | /* Looks like the unsol event is incompatible with the standard |
| 1443 | * definition. 4bit tag is placed at 28 bit! |
| 1444 | */ |
| 1445 | if ((res >> 28) == 0x01) |
| 1446 | alc880_lg_automute(codec); |
| 1447 | } |
| 1448 | |
| 1449 | /* |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 1450 | * LG LW20 |
| 1451 | * |
| 1452 | * Pin assignment: |
| 1453 | * Speaker-out: 0x14 |
| 1454 | * Mic-In: 0x18 |
| 1455 | * Built-in Mic-In: 0x19 (?) |
| 1456 | * HP-Out: 0x1b |
| 1457 | * SPDIF-Out: 0x1e |
| 1458 | */ |
| 1459 | |
| 1460 | /* seems analog CD is not working */ |
| 1461 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
| 1462 | .num_items = 2, |
| 1463 | .items = { |
| 1464 | { "Mic", 0x0 }, |
| 1465 | { "Internal Mic", 0x1 }, |
| 1466 | }, |
| 1467 | }; |
| 1468 | |
| 1469 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
| 1470 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1471 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1472 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 1473 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 1474 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 1475 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 1476 | { } /* end */ |
| 1477 | }; |
| 1478 | |
| 1479 | static struct hda_verb alc880_lg_lw_init_verbs[] = { |
| 1480 | /* set capture source to mic-in */ |
| 1481 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1482 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1483 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1484 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, |
| 1485 | /* speaker-out */ |
| 1486 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1487 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1488 | /* HP-out */ |
| 1489 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1490 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1491 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1492 | /* mic-in to input */ |
| 1493 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1494 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1495 | /* built-in mic */ |
| 1496 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1497 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1498 | /* jack sense */ |
| 1499 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, |
| 1500 | { } |
| 1501 | }; |
| 1502 | |
| 1503 | /* toggle speaker-output according to the hp-jack state */ |
| 1504 | static void alc880_lg_lw_automute(struct hda_codec *codec) |
| 1505 | { |
| 1506 | unsigned int present; |
| 1507 | |
| 1508 | present = snd_hda_codec_read(codec, 0x1b, 0, |
| 1509 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1510 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
| 1511 | 0x80, present ? 0x80 : 0); |
| 1512 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
| 1513 | 0x80, present ? 0x80 : 0); |
| 1514 | } |
| 1515 | |
| 1516 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1517 | { |
| 1518 | /* Looks like the unsol event is incompatible with the standard |
| 1519 | * definition. 4bit tag is placed at 28 bit! |
| 1520 | */ |
| 1521 | if ((res >> 28) == 0x01) |
| 1522 | alc880_lg_lw_automute(codec); |
| 1523 | } |
| 1524 | |
| 1525 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1526 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1527 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | static int alc_init(struct hda_codec *codec) |
| 1530 | { |
| 1531 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1532 | unsigned int i; |
| 1533 | |
| 1534 | for (i = 0; i < spec->num_init_verbs; i++) |
| 1535 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1536 | |
| 1537 | if (spec->init_hook) |
| 1538 | spec->init_hook(codec); |
| 1539 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | return 0; |
| 1541 | } |
| 1542 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1543 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1544 | { |
| 1545 | struct alc_spec *spec = codec->spec; |
| 1546 | |
| 1547 | if (spec->unsol_event) |
| 1548 | spec->unsol_event(codec, res); |
| 1549 | } |
| 1550 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1551 | #ifdef CONFIG_PM |
| 1552 | /* |
| 1553 | * resume |
| 1554 | */ |
| 1555 | static int alc_resume(struct hda_codec *codec) |
| 1556 | { |
| 1557 | struct alc_spec *spec = codec->spec; |
| 1558 | int i; |
| 1559 | |
| 1560 | alc_init(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1561 | for (i = 0; i < spec->num_mixers; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1562 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | if (spec->multiout.dig_out_nid) |
| 1564 | snd_hda_resume_spdif_out(codec); |
| 1565 | if (spec->dig_in_nid) |
| 1566 | snd_hda_resume_spdif_in(codec); |
| 1567 | |
| 1568 | return 0; |
| 1569 | } |
| 1570 | #endif |
| 1571 | |
| 1572 | /* |
| 1573 | * Analog playback callbacks |
| 1574 | */ |
| 1575 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1576 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1577 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | { |
| 1579 | struct alc_spec *spec = codec->spec; |
| 1580 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 1581 | } |
| 1582 | |
| 1583 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1584 | struct hda_codec *codec, |
| 1585 | unsigned int stream_tag, |
| 1586 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1587 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | { |
| 1589 | struct alc_spec *spec = codec->spec; |
| 1590 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 1591 | format, substream); |
| 1592 | } |
| 1593 | |
| 1594 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1595 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1596 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1597 | { |
| 1598 | struct alc_spec *spec = codec->spec; |
| 1599 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1600 | } |
| 1601 | |
| 1602 | /* |
| 1603 | * Digital out |
| 1604 | */ |
| 1605 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1606 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1607 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1608 | { |
| 1609 | struct alc_spec *spec = codec->spec; |
| 1610 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1611 | } |
| 1612 | |
| 1613 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1614 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1615 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1616 | { |
| 1617 | struct alc_spec *spec = codec->spec; |
| 1618 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1619 | } |
| 1620 | |
| 1621 | /* |
| 1622 | * Analog capture |
| 1623 | */ |
| 1624 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1625 | struct hda_codec *codec, |
| 1626 | unsigned int stream_tag, |
| 1627 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1628 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | { |
| 1630 | struct alc_spec *spec = codec->spec; |
| 1631 | |
| 1632 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1633 | stream_tag, 0, format); |
| 1634 | return 0; |
| 1635 | } |
| 1636 | |
| 1637 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1638 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1639 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | { |
| 1641 | struct alc_spec *spec = codec->spec; |
| 1642 | |
| 1643 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 1644 | return 0; |
| 1645 | } |
| 1646 | |
| 1647 | |
| 1648 | /* |
| 1649 | */ |
| 1650 | static struct hda_pcm_stream alc880_pcm_analog_playback = { |
| 1651 | .substreams = 1, |
| 1652 | .channels_min = 2, |
| 1653 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1654 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | .ops = { |
| 1656 | .open = alc880_playback_pcm_open, |
| 1657 | .prepare = alc880_playback_pcm_prepare, |
| 1658 | .cleanup = alc880_playback_pcm_cleanup |
| 1659 | }, |
| 1660 | }; |
| 1661 | |
| 1662 | static struct hda_pcm_stream alc880_pcm_analog_capture = { |
| 1663 | .substreams = 2, |
| 1664 | .channels_min = 2, |
| 1665 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1666 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | .ops = { |
| 1668 | .prepare = alc880_capture_pcm_prepare, |
| 1669 | .cleanup = alc880_capture_pcm_cleanup |
| 1670 | }, |
| 1671 | }; |
| 1672 | |
| 1673 | static struct hda_pcm_stream alc880_pcm_digital_playback = { |
| 1674 | .substreams = 1, |
| 1675 | .channels_min = 2, |
| 1676 | .channels_max = 2, |
| 1677 | /* NID is set in alc_build_pcms */ |
| 1678 | .ops = { |
| 1679 | .open = alc880_dig_playback_pcm_open, |
| 1680 | .close = alc880_dig_playback_pcm_close |
| 1681 | }, |
| 1682 | }; |
| 1683 | |
| 1684 | static struct hda_pcm_stream alc880_pcm_digital_capture = { |
| 1685 | .substreams = 1, |
| 1686 | .channels_min = 2, |
| 1687 | .channels_max = 2, |
| 1688 | /* NID is set in alc_build_pcms */ |
| 1689 | }; |
| 1690 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1691 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
| 1692 | static struct hda_pcm_stream alc_pcm_null_playback = { |
| 1693 | .substreams = 0, |
| 1694 | .channels_min = 0, |
| 1695 | .channels_max = 0, |
| 1696 | }; |
| 1697 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | static int alc_build_pcms(struct hda_codec *codec) |
| 1699 | { |
| 1700 | struct alc_spec *spec = codec->spec; |
| 1701 | struct hda_pcm *info = spec->pcm_rec; |
| 1702 | int i; |
| 1703 | |
| 1704 | codec->num_pcms = 1; |
| 1705 | codec->pcm_info = info; |
| 1706 | |
| 1707 | info->name = spec->stream_name_analog; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1708 | if (spec->stream_analog_playback) { |
| 1709 | snd_assert(spec->multiout.dac_nids, return -EINVAL); |
| 1710 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
| 1711 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 1712 | } |
| 1713 | if (spec->stream_analog_capture) { |
| 1714 | snd_assert(spec->adc_nids, return -EINVAL); |
| 1715 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| 1716 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1717 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1719 | if (spec->channel_mode) { |
| 1720 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 1721 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 1722 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 1723 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 1724 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | } |
| 1726 | } |
| 1727 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1728 | /* If the use of more than one ADC is requested for the current |
| 1729 | * model, configure a second analog capture-only PCM. |
| 1730 | */ |
| 1731 | if (spec->num_adc_nids > 1) { |
| 1732 | codec->num_pcms++; |
| 1733 | info++; |
| 1734 | info->name = spec->stream_name_analog; |
| 1735 | /* No playback stream for second PCM */ |
| 1736 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; |
| 1737 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 1738 | if (spec->stream_analog_capture) { |
| 1739 | snd_assert(spec->adc_nids, return -EINVAL); |
| 1740 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| 1741 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; |
| 1742 | } |
| 1743 | } |
| 1744 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 1746 | codec->num_pcms++; |
| 1747 | info++; |
| 1748 | info->name = spec->stream_name_digital; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1749 | if (spec->multiout.dig_out_nid && |
| 1750 | spec->stream_digital_playback) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
| 1752 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 1753 | } |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1754 | if (spec->dig_in_nid && |
| 1755 | spec->stream_digital_capture) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
| 1757 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | return 0; |
| 1762 | } |
| 1763 | |
| 1764 | static void alc_free(struct hda_codec *codec) |
| 1765 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1766 | struct alc_spec *spec = codec->spec; |
| 1767 | unsigned int i; |
| 1768 | |
| 1769 | if (! spec) |
| 1770 | return; |
| 1771 | |
| 1772 | if (spec->kctl_alloc) { |
| 1773 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1774 | kfree(spec->kctl_alloc[i].name); |
| 1775 | kfree(spec->kctl_alloc); |
| 1776 | } |
| 1777 | kfree(spec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | /* |
| 1781 | */ |
| 1782 | static struct hda_codec_ops alc_patch_ops = { |
| 1783 | .build_controls = alc_build_controls, |
| 1784 | .build_pcms = alc_build_pcms, |
| 1785 | .init = alc_init, |
| 1786 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1787 | .unsol_event = alc_unsol_event, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | #ifdef CONFIG_PM |
| 1789 | .resume = alc_resume, |
| 1790 | #endif |
| 1791 | }; |
| 1792 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1793 | |
| 1794 | /* |
| 1795 | * Test configuration for debugging |
| 1796 | * |
| 1797 | * Almost all inputs/outputs are enabled. I/O pins can be configured via |
| 1798 | * enum controls. |
| 1799 | */ |
| 1800 | #ifdef CONFIG_SND_DEBUG |
| 1801 | static hda_nid_t alc880_test_dac_nids[4] = { |
| 1802 | 0x02, 0x03, 0x04, 0x05 |
| 1803 | }; |
| 1804 | |
| 1805 | static struct hda_input_mux alc880_test_capture_source = { |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1806 | .num_items = 7, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1807 | .items = { |
| 1808 | { "In-1", 0x0 }, |
| 1809 | { "In-2", 0x1 }, |
| 1810 | { "In-3", 0x2 }, |
| 1811 | { "In-4", 0x3 }, |
| 1812 | { "CD", 0x4 }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1813 | { "Front", 0x5 }, |
| 1814 | { "Surround", 0x6 }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1815 | }, |
| 1816 | }; |
| 1817 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 1818 | static struct hda_channel_mode alc880_test_modes[4] = { |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1819 | { 2, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1820 | { 4, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1821 | { 6, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1822 | { 8, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1823 | }; |
| 1824 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1825 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1826 | { |
| 1827 | static char *texts[] = { |
| 1828 | "N/A", "Line Out", "HP Out", |
| 1829 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" |
| 1830 | }; |
| 1831 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1832 | uinfo->count = 1; |
| 1833 | uinfo->value.enumerated.items = 8; |
| 1834 | if (uinfo->value.enumerated.item >= 8) |
| 1835 | uinfo->value.enumerated.item = 7; |
| 1836 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1837 | return 0; |
| 1838 | } |
| 1839 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1840 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1841 | { |
| 1842 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1843 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1844 | unsigned int pin_ctl, item = 0; |
| 1845 | |
| 1846 | pin_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1847 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1848 | if (pin_ctl & AC_PINCTL_OUT_EN) { |
| 1849 | if (pin_ctl & AC_PINCTL_HP_EN) |
| 1850 | item = 2; |
| 1851 | else |
| 1852 | item = 1; |
| 1853 | } else if (pin_ctl & AC_PINCTL_IN_EN) { |
| 1854 | switch (pin_ctl & AC_PINCTL_VREFEN) { |
| 1855 | case AC_PINCTL_VREF_HIZ: item = 3; break; |
| 1856 | case AC_PINCTL_VREF_50: item = 4; break; |
| 1857 | case AC_PINCTL_VREF_GRD: item = 5; break; |
| 1858 | case AC_PINCTL_VREF_80: item = 6; break; |
| 1859 | case AC_PINCTL_VREF_100: item = 7; break; |
| 1860 | } |
| 1861 | } |
| 1862 | ucontrol->value.enumerated.item[0] = item; |
| 1863 | return 0; |
| 1864 | } |
| 1865 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1866 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1867 | { |
| 1868 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1869 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1870 | static unsigned int ctls[] = { |
| 1871 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, |
| 1872 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, |
| 1873 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, |
| 1874 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, |
| 1875 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, |
| 1876 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, |
| 1877 | }; |
| 1878 | unsigned int old_ctl, new_ctl; |
| 1879 | |
| 1880 | old_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1881 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1882 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; |
| 1883 | if (old_ctl != new_ctl) { |
| 1884 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); |
| 1885 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1886 | ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); |
| 1887 | return 1; |
| 1888 | } |
| 1889 | return 0; |
| 1890 | } |
| 1891 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1892 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1893 | { |
| 1894 | static char *texts[] = { |
| 1895 | "Front", "Surround", "CLFE", "Side" |
| 1896 | }; |
| 1897 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1898 | uinfo->count = 1; |
| 1899 | uinfo->value.enumerated.items = 4; |
| 1900 | if (uinfo->value.enumerated.item >= 4) |
| 1901 | uinfo->value.enumerated.item = 3; |
| 1902 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1903 | return 0; |
| 1904 | } |
| 1905 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1906 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1907 | { |
| 1908 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1909 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1910 | unsigned int sel; |
| 1911 | |
| 1912 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1913 | ucontrol->value.enumerated.item[0] = sel & 3; |
| 1914 | return 0; |
| 1915 | } |
| 1916 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1917 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1918 | { |
| 1919 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1920 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1921 | unsigned int sel; |
| 1922 | |
| 1923 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; |
| 1924 | if (ucontrol->value.enumerated.item[0] != sel) { |
| 1925 | sel = ucontrol->value.enumerated.item[0] & 3; |
| 1926 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); |
| 1927 | return 1; |
| 1928 | } |
| 1929 | return 0; |
| 1930 | } |
| 1931 | |
| 1932 | #define PIN_CTL_TEST(xname,nid) { \ |
| 1933 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1934 | .name = xname, \ |
| 1935 | .info = alc_test_pin_ctl_info, \ |
| 1936 | .get = alc_test_pin_ctl_get, \ |
| 1937 | .put = alc_test_pin_ctl_put, \ |
| 1938 | .private_value = nid \ |
| 1939 | } |
| 1940 | |
| 1941 | #define PIN_SRC_TEST(xname,nid) { \ |
| 1942 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1943 | .name = xname, \ |
| 1944 | .info = alc_test_pin_src_info, \ |
| 1945 | .get = alc_test_pin_src_get, \ |
| 1946 | .put = alc_test_pin_src_put, \ |
| 1947 | .private_value = nid \ |
| 1948 | } |
| 1949 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1950 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1951 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1952 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| 1953 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
| 1954 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1955 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1956 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| 1957 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), |
| 1958 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1959 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
| 1960 | PIN_CTL_TEST("Surround Pin Mode", 0x15), |
| 1961 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), |
| 1962 | PIN_CTL_TEST("Side Pin Mode", 0x17), |
| 1963 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), |
| 1964 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), |
| 1965 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), |
| 1966 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), |
| 1967 | PIN_SRC_TEST("In-1 Pin Source", 0x18), |
| 1968 | PIN_SRC_TEST("In-2 Pin Source", 0x19), |
| 1969 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), |
| 1970 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), |
| 1971 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 1972 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 1973 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 1974 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 1975 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), |
| 1976 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), |
| 1977 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 1978 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 1979 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), |
| 1980 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1981 | { |
| 1982 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1983 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1984 | .info = alc_ch_mode_info, |
| 1985 | .get = alc_ch_mode_get, |
| 1986 | .put = alc_ch_mode_put, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1987 | }, |
| 1988 | { } /* end */ |
| 1989 | }; |
| 1990 | |
| 1991 | static struct hda_verb alc880_test_init_verbs[] = { |
| 1992 | /* Unmute inputs of 0x0c - 0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1993 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1994 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1995 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1996 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1997 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1998 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1999 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2000 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2001 | /* Vol output for 0x0c-0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2002 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2003 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2004 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2005 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2006 | /* Set output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2007 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2008 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2009 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2010 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2011 | /* Unmute output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2012 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2013 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2014 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2015 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2016 | /* Set input pins 0x18-0x1c */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2017 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2018 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2019 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2020 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2021 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2022 | /* Mute input pins 0x18-0x1b */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2023 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2024 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2025 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2026 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2027 | /* ADC set up */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2028 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2029 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2030 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2031 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2032 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2033 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2034 | /* Analog input/passthru */ |
| 2035 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2036 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2037 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2038 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2039 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2040 | { } |
| 2041 | }; |
| 2042 | #endif |
| 2043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | /* |
| 2045 | */ |
| 2046 | |
| 2047 | static struct hda_board_config alc880_cfg_tbl[] = { |
| 2048 | /* Back 3 jack, front 2 jack */ |
| 2049 | { .modelname = "3stack", .config = ALC880_3ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2050 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, |
| 2051 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, |
| 2052 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, |
| 2053 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, |
| 2054 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, |
| 2055 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, |
| 2056 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, |
| 2057 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, |
| 2058 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, |
| 2059 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, |
| 2060 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, |
| 2061 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, |
| 2062 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, |
| 2063 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, |
| 2064 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, |
| 2065 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, |
| 2066 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, |
| 2067 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, |
| 2068 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, |
| 2069 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, |
| 2070 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, |
| 2071 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, |
| 2072 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, |
| 2073 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, |
| 2074 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, |
| 2075 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, |
| 2076 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, |
| 2077 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, |
| 2078 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, |
| 2079 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, |
| 2080 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, |
| 2081 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2082 | /* TCL S700 */ |
| 2083 | { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | |
| 2085 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2086 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2087 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, |
Davide Libenzi | 0ca2161 | 2005-09-05 11:56:47 +0200 | [diff] [blame] | 2088 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | |
| 2090 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ |
| 2091 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2092 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, |
Jaroslav Kysela | 5a47fe3 | 2005-08-15 20:01:40 +0200 | [diff] [blame] | 2093 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2094 | /* Clevo m520G NB */ |
| 2095 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | |
| 2097 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2098 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, |
| 2099 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, |
| 2100 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | |
| 2102 | /* Back 5 jack, front 2 jack */ |
| 2103 | { .modelname = "5stack", .config = ALC880_5ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2104 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, |
| 2105 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, |
| 2106 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, |
| 2107 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2108 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | |
| 2110 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ |
| 2111 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2112 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, |
| 2113 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, |
| 2114 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, |
| 2115 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, |
| 2116 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, |
| 2117 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, |
| 2118 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, |
| 2119 | { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2120 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, |
Takashi Iwai | ede3531 | 2006-03-13 14:21:16 +0100 | [diff] [blame] | 2121 | { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, |
| 2122 | .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */ |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 2123 | /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2124 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2125 | /* note subvendor = 0 below */ |
| 2126 | /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | |
| 2128 | { .modelname = "w810", .config = ALC880_W810 }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2129 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 2131 | { .modelname = "z71v", .config = ALC880_Z71V }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2132 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 2133 | |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2134 | { .modelname = "6stack", .config = ALC880_6ST }, |
Takashi Iwai | 7632c7b | 2005-12-07 18:25:47 +0100 | [diff] [blame] | 2135 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2136 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 2137 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ |
Arnaud Patard | bae2bdb | 2006-01-27 12:05:02 +0100 | [diff] [blame] | 2138 | { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */ |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2139 | |
| 2140 | { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2141 | { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, |
| 2142 | { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, |
| 2143 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, |
| 2144 | { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2145 | { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, |
| 2146 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, |
| 2147 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, |
| 2148 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, |
Takashi Iwai | 041dec0 | 2005-12-23 12:27:52 +0100 | [diff] [blame] | 2149 | { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ |
Takashi Iwai | a12606c | 2006-03-15 18:24:43 +0100 | [diff] [blame] | 2150 | { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */ |
Takashi Iwai | 531213a | 2006-04-18 13:46:08 +0200 | [diff] [blame] | 2151 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2152 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2153 | { .modelname = "asus", .config = ALC880_ASUS }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2154 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, |
| 2155 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, |
| 2156 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, |
| 2157 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 8648811 | 2005-09-09 13:56:32 +0200 | [diff] [blame] | 2158 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2159 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, |
| 2160 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, |
| 2161 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, |
| 2162 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, |
| 2163 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, |
| 2164 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, |
Takashi Iwai | 84f3430 | 2006-03-21 19:12:53 +0100 | [diff] [blame] | 2165 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2166 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2167 | |
| 2168 | { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, |
| 2169 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, |
| 2170 | |
| 2171 | { .modelname = "F1734", .config = ALC880_F1734 }, |
| 2172 | { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2173 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2174 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2175 | { .modelname = "lg", .config = ALC880_LG }, |
| 2176 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG }, |
Takashi Iwai | 886da86 | 2006-05-02 18:17:57 +0200 | [diff] [blame^] | 2177 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2178 | |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 2179 | { .modelname = "lg-lw", .config = ALC880_LG_LW }, |
| 2180 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW }, |
| 2181 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2182 | #ifdef CONFIG_SND_DEBUG |
| 2183 | { .modelname = "test", .config = ALC880_TEST }, |
| 2184 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2185 | { .modelname = "auto", .config = ALC880_AUTO }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2186 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | {} |
| 2188 | }; |
| 2189 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2190 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2191 | * ALC880 codec presets |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2192 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2193 | static struct alc_config_preset alc880_presets[] = { |
| 2194 | [ALC880_3ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2195 | .mixers = { alc880_three_stack_mixer }, |
| 2196 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2197 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2198 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2199 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2200 | .channel_mode = alc880_threestack_modes, |
| 2201 | .input_mux = &alc880_capture_source, |
| 2202 | }, |
| 2203 | [ALC880_3ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2204 | .mixers = { alc880_three_stack_mixer }, |
| 2205 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2206 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2207 | .dac_nids = alc880_dac_nids, |
| 2208 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2209 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2210 | .channel_mode = alc880_threestack_modes, |
| 2211 | .input_mux = &alc880_capture_source, |
| 2212 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2213 | [ALC880_TCL_S700] = { |
| 2214 | .mixers = { alc880_tcl_s700_mixer }, |
| 2215 | .init_verbs = { alc880_volume_init_verbs, |
| 2216 | alc880_pin_tcl_S700_init_verbs, |
| 2217 | alc880_gpio2_init_verbs }, |
| 2218 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2219 | .dac_nids = alc880_dac_nids, |
| 2220 | .hp_nid = 0x03, |
| 2221 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2222 | .channel_mode = alc880_2_jack_modes, |
| 2223 | .input_mux = &alc880_capture_source, |
| 2224 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2225 | [ALC880_5ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2226 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, |
| 2227 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2228 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2229 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2230 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 2231 | .channel_mode = alc880_fivestack_modes, |
| 2232 | .input_mux = &alc880_capture_source, |
| 2233 | }, |
| 2234 | [ALC880_5ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2235 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, |
| 2236 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2237 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2238 | .dac_nids = alc880_dac_nids, |
| 2239 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2240 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 2241 | .channel_mode = alc880_fivestack_modes, |
| 2242 | .input_mux = &alc880_capture_source, |
| 2243 | }, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2244 | [ALC880_6ST] = { |
| 2245 | .mixers = { alc880_six_stack_mixer }, |
| 2246 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
| 2247 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 2248 | .dac_nids = alc880_6st_dac_nids, |
| 2249 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 2250 | .channel_mode = alc880_sixstack_modes, |
| 2251 | .input_mux = &alc880_6stack_capture_source, |
| 2252 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2253 | [ALC880_6ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2254 | .mixers = { alc880_six_stack_mixer }, |
| 2255 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2256 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 2257 | .dac_nids = alc880_6st_dac_nids, |
| 2258 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2259 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 2260 | .channel_mode = alc880_sixstack_modes, |
| 2261 | .input_mux = &alc880_6stack_capture_source, |
| 2262 | }, |
| 2263 | [ALC880_W810] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2264 | .mixers = { alc880_w810_base_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2265 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, |
| 2266 | alc880_gpio2_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2267 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
| 2268 | .dac_nids = alc880_w810_dac_nids, |
| 2269 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2270 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
| 2271 | .channel_mode = alc880_w810_modes, |
| 2272 | .input_mux = &alc880_capture_source, |
| 2273 | }, |
| 2274 | [ALC880_Z71V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2275 | .mixers = { alc880_z71v_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2276 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2277 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
| 2278 | .dac_nids = alc880_z71v_dac_nids, |
| 2279 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2280 | .hp_nid = 0x03, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2281 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2282 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2283 | .input_mux = &alc880_capture_source, |
| 2284 | }, |
| 2285 | [ALC880_F1734] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2286 | .mixers = { alc880_f1734_mixer }, |
| 2287 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, |
| 2288 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
| 2289 | .dac_nids = alc880_f1734_dac_nids, |
| 2290 | .hp_nid = 0x02, |
| 2291 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2292 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2293 | .input_mux = &alc880_capture_source, |
| 2294 | }, |
| 2295 | [ALC880_ASUS] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2296 | .mixers = { alc880_asus_mixer }, |
| 2297 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2298 | alc880_gpio1_init_verbs }, |
| 2299 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2300 | .dac_nids = alc880_asus_dac_nids, |
| 2301 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2302 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2303 | .input_mux = &alc880_capture_source, |
| 2304 | }, |
| 2305 | [ALC880_ASUS_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2306 | .mixers = { alc880_asus_mixer }, |
| 2307 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2308 | alc880_gpio1_init_verbs }, |
| 2309 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2310 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2311 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2312 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2313 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2314 | .input_mux = &alc880_capture_source, |
| 2315 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2316 | [ALC880_ASUS_DIG2] = { |
| 2317 | .mixers = { alc880_asus_mixer }, |
| 2318 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2319 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
| 2320 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2321 | .dac_nids = alc880_asus_dac_nids, |
| 2322 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2323 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2324 | .channel_mode = alc880_asus_modes, |
| 2325 | .input_mux = &alc880_capture_source, |
| 2326 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2327 | [ALC880_ASUS_W1V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2328 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
| 2329 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2330 | alc880_gpio1_init_verbs }, |
| 2331 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2332 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2333 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2334 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2335 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2336 | .input_mux = &alc880_capture_source, |
| 2337 | }, |
| 2338 | [ALC880_UNIWILL_DIG] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 2339 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2340 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, |
| 2341 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2342 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2343 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2344 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2345 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2346 | .input_mux = &alc880_capture_source, |
| 2347 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2348 | [ALC880_CLEVO] = { |
| 2349 | .mixers = { alc880_three_stack_mixer }, |
| 2350 | .init_verbs = { alc880_volume_init_verbs, |
| 2351 | alc880_pin_clevo_init_verbs }, |
| 2352 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2353 | .dac_nids = alc880_dac_nids, |
| 2354 | .hp_nid = 0x03, |
| 2355 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2356 | .channel_mode = alc880_threestack_modes, |
| 2357 | .input_mux = &alc880_capture_source, |
| 2358 | }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2359 | [ALC880_LG] = { |
| 2360 | .mixers = { alc880_lg_mixer }, |
| 2361 | .init_verbs = { alc880_volume_init_verbs, |
| 2362 | alc880_lg_init_verbs }, |
| 2363 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), |
| 2364 | .dac_nids = alc880_lg_dac_nids, |
| 2365 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2366 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), |
| 2367 | .channel_mode = alc880_lg_ch_modes, |
| 2368 | .input_mux = &alc880_lg_capture_source, |
| 2369 | .unsol_event = alc880_lg_unsol_event, |
| 2370 | .init_hook = alc880_lg_automute, |
| 2371 | }, |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 2372 | [ALC880_LG_LW] = { |
| 2373 | .mixers = { alc880_lg_lw_mixer }, |
| 2374 | .init_verbs = { alc880_volume_init_verbs, |
| 2375 | alc880_lg_lw_init_verbs }, |
| 2376 | .num_dacs = 1, |
| 2377 | .dac_nids = alc880_dac_nids, |
| 2378 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2379 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2380 | .channel_mode = alc880_2_jack_modes, |
| 2381 | .input_mux = &alc880_lg_lw_capture_source, |
| 2382 | .unsol_event = alc880_lg_lw_unsol_event, |
| 2383 | .init_hook = alc880_lg_lw_automute, |
| 2384 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2385 | #ifdef CONFIG_SND_DEBUG |
| 2386 | [ALC880_TEST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2387 | .mixers = { alc880_test_mixer }, |
| 2388 | .init_verbs = { alc880_test_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2389 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
| 2390 | .dac_nids = alc880_test_dac_nids, |
| 2391 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2392 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
| 2393 | .channel_mode = alc880_test_modes, |
| 2394 | .input_mux = &alc880_test_capture_source, |
| 2395 | }, |
| 2396 | #endif |
| 2397 | }; |
| 2398 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2399 | /* |
| 2400 | * Automatic parse of I/O pins from the BIOS configuration |
| 2401 | */ |
| 2402 | |
| 2403 | #define NUM_CONTROL_ALLOC 32 |
| 2404 | #define NUM_VERB_ALLOC 32 |
| 2405 | |
| 2406 | enum { |
| 2407 | ALC_CTL_WIDGET_VOL, |
| 2408 | ALC_CTL_WIDGET_MUTE, |
| 2409 | ALC_CTL_BIND_MUTE, |
| 2410 | }; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2411 | static struct snd_kcontrol_new alc880_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2412 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2413 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2414 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2415 | }; |
| 2416 | |
| 2417 | /* add dynamic controls */ |
| 2418 | static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) |
| 2419 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2420 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2421 | |
| 2422 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2423 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2424 | |
| 2425 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2426 | if (! knew) |
| 2427 | return -ENOMEM; |
| 2428 | if (spec->kctl_alloc) { |
| 2429 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2430 | kfree(spec->kctl_alloc); |
| 2431 | } |
| 2432 | spec->kctl_alloc = knew; |
| 2433 | spec->num_kctl_alloc = num; |
| 2434 | } |
| 2435 | |
| 2436 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2437 | *knew = alc880_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2438 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2439 | if (! knew->name) |
| 2440 | return -ENOMEM; |
| 2441 | knew->private_value = val; |
| 2442 | spec->num_kctl_used++; |
| 2443 | return 0; |
| 2444 | } |
| 2445 | |
| 2446 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
| 2447 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
| 2448 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
| 2449 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) |
| 2450 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) |
| 2451 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) |
| 2452 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) |
| 2453 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) |
| 2454 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) |
| 2455 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) |
| 2456 | #define ALC880_PIN_CD_NID 0x1c |
| 2457 | |
| 2458 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2459 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 2460 | { |
| 2461 | hda_nid_t nid; |
| 2462 | int assigned[4]; |
| 2463 | int i, j; |
| 2464 | |
| 2465 | memset(assigned, 0, sizeof(assigned)); |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2466 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2467 | |
| 2468 | /* check the pins hardwired to audio widget */ |
| 2469 | for (i = 0; i < cfg->line_outs; i++) { |
| 2470 | nid = cfg->line_out_pins[i]; |
| 2471 | if (alc880_is_fixed_pin(nid)) { |
| 2472 | int idx = alc880_fixed_pin_idx(nid); |
Libin Yang | 5014f19 | 2005-11-23 15:48:36 +0100 | [diff] [blame] | 2473 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2474 | assigned[idx] = 1; |
| 2475 | } |
| 2476 | } |
| 2477 | /* left pins can be connect to any audio widget */ |
| 2478 | for (i = 0; i < cfg->line_outs; i++) { |
| 2479 | nid = cfg->line_out_pins[i]; |
| 2480 | if (alc880_is_fixed_pin(nid)) |
| 2481 | continue; |
| 2482 | /* search for an empty channel */ |
| 2483 | for (j = 0; j < cfg->line_outs; j++) { |
| 2484 | if (! assigned[j]) { |
| 2485 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); |
| 2486 | assigned[j] = 1; |
| 2487 | break; |
| 2488 | } |
| 2489 | } |
| 2490 | } |
| 2491 | spec->multiout.num_dacs = cfg->line_outs; |
| 2492 | return 0; |
| 2493 | } |
| 2494 | |
| 2495 | /* add playback controls from the parsed DAC table */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2496 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 2497 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2498 | { |
| 2499 | char name[32]; |
| 2500 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2501 | hda_nid_t nid; |
| 2502 | int i, err; |
| 2503 | |
| 2504 | for (i = 0; i < cfg->line_outs; i++) { |
| 2505 | if (! spec->multiout.dac_nids[i]) |
| 2506 | continue; |
| 2507 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
| 2508 | if (i == 2) { |
| 2509 | /* Center/LFE */ |
| 2510 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", |
| 2511 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 2512 | return err; |
| 2513 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", |
| 2514 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 2515 | return err; |
| 2516 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 2517 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) |
| 2518 | return err; |
| 2519 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 2520 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) |
| 2521 | return err; |
| 2522 | } else { |
| 2523 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2524 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
| 2525 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2526 | return err; |
| 2527 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2528 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 2529 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2530 | return err; |
| 2531 | } |
| 2532 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2533 | return 0; |
| 2534 | } |
| 2535 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2536 | /* add playback controls for speaker and HP outputs */ |
| 2537 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, |
| 2538 | const char *pfx) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2539 | { |
| 2540 | hda_nid_t nid; |
| 2541 | int err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2542 | char name[32]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2543 | |
| 2544 | if (! pin) |
| 2545 | return 0; |
| 2546 | |
| 2547 | if (alc880_is_fixed_pin(pin)) { |
| 2548 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2549 | /* specify the DAC as the extra output */ |
| 2550 | if (! spec->multiout.hp_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2551 | spec->multiout.hp_nid = nid; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2552 | else |
| 2553 | spec->multiout.extra_out_nid[0] = nid; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2554 | /* control HP volume/switch on the output mixer amp */ |
| 2555 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2556 | sprintf(name, "%s Playback Volume", pfx); |
| 2557 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2558 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2559 | return err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2560 | sprintf(name, "%s Playback Switch", pfx); |
| 2561 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2562 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2563 | return err; |
| 2564 | } else if (alc880_is_multi_pin(pin)) { |
| 2565 | /* set manual connection */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2566 | /* we have only a switch on HP-out PIN */ |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2567 | sprintf(name, "%s Playback Switch", pfx); |
| 2568 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2569 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) |
| 2570 | return err; |
| 2571 | } |
| 2572 | return 0; |
| 2573 | } |
| 2574 | |
| 2575 | /* create input playback/capture controls for the given pin */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2576 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, |
| 2577 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2578 | { |
| 2579 | char name[32]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2580 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2581 | |
| 2582 | sprintf(name, "%s Playback Volume", ctlname); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2583 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2584 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2585 | return err; |
| 2586 | sprintf(name, "%s Playback Switch", ctlname); |
| 2587 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2588 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2589 | return err; |
| 2590 | return 0; |
| 2591 | } |
| 2592 | |
| 2593 | /* create playback/capture controls for input pins */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2594 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 2595 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2596 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2597 | struct hda_input_mux *imux = &spec->private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2598 | int i, err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2599 | |
| 2600 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2601 | if (alc880_is_input_pin(cfg->input_pins[i])) { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2602 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2603 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2604 | auto_pin_cfg_labels[i], |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2605 | idx, 0x0b); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2606 | if (err < 0) |
| 2607 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2608 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2609 | imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); |
| 2610 | imux->num_items++; |
| 2611 | } |
| 2612 | } |
| 2613 | return 0; |
| 2614 | } |
| 2615 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2616 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2617 | hda_nid_t nid, int pin_type, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2618 | int dac_idx) |
| 2619 | { |
| 2620 | /* set as output */ |
| 2621 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2622 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2623 | /* need the manual connection? */ |
| 2624 | if (alc880_is_multi_pin(nid)) { |
| 2625 | struct alc_spec *spec = codec->spec; |
| 2626 | int idx = alc880_multi_pin_idx(nid); |
| 2627 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, |
| 2628 | AC_VERB_SET_CONNECT_SEL, |
| 2629 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); |
| 2630 | } |
| 2631 | } |
| 2632 | |
| 2633 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
| 2634 | { |
| 2635 | struct alc_spec *spec = codec->spec; |
| 2636 | int i; |
| 2637 | |
| 2638 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2639 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2640 | alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2641 | } |
| 2642 | } |
| 2643 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2644 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2645 | { |
| 2646 | struct alc_spec *spec = codec->spec; |
| 2647 | hda_nid_t pin; |
| 2648 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2649 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2650 | if (pin) /* connect to front */ |
| 2651 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2652 | pin = spec->autocfg.hp_pin; |
| 2653 | if (pin) /* connect to front */ |
| 2654 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2655 | } |
| 2656 | |
| 2657 | static void alc880_auto_init_analog_input(struct hda_codec *codec) |
| 2658 | { |
| 2659 | struct alc_spec *spec = codec->spec; |
| 2660 | int i; |
| 2661 | |
| 2662 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2663 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2664 | if (alc880_is_input_pin(nid)) { |
| 2665 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2666 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2667 | if (nid != ALC880_PIN_CD_NID) |
| 2668 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2669 | AMP_OUT_MUTE); |
| 2670 | } |
| 2671 | } |
| 2672 | } |
| 2673 | |
| 2674 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2675 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2676 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 2677 | { |
| 2678 | struct alc_spec *spec = codec->spec; |
| 2679 | int err; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2680 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2681 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2682 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 2683 | alc880_ignore)) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2684 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2685 | if (! spec->autocfg.line_outs) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2686 | return 0; /* can't find valid BIOS pin config */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2687 | |
| 2688 | if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 2689 | (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2690 | (err = alc880_auto_create_extra_out(spec, |
| 2691 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2692 | "Speaker")) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2693 | (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin, |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2694 | "Headphone")) < 0 || |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2695 | (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2696 | return err; |
| 2697 | |
| 2698 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2699 | |
| 2700 | if (spec->autocfg.dig_out_pin) |
| 2701 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
| 2702 | if (spec->autocfg.dig_in_pin) |
| 2703 | spec->dig_in_nid = ALC880_DIGIN_NID; |
| 2704 | |
| 2705 | if (spec->kctl_alloc) |
| 2706 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2707 | |
| 2708 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; |
| 2709 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2710 | spec->num_mux_defs = 1; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2711 | spec->input_mux = &spec->private_imux; |
| 2712 | |
| 2713 | return 1; |
| 2714 | } |
| 2715 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2716 | /* additional initialization for auto-configuration model */ |
| 2717 | static void alc880_auto_init(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2718 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2719 | alc880_auto_init_multi_out(codec); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2720 | alc880_auto_init_extra_out(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2721 | alc880_auto_init_analog_input(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2722 | } |
| 2723 | |
| 2724 | /* |
| 2725 | * OK, here we have finally the patch for ALC880 |
| 2726 | */ |
| 2727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | static int patch_alc880(struct hda_codec *codec) |
| 2729 | { |
| 2730 | struct alc_spec *spec; |
| 2731 | int board_config; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2732 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2733 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 2734 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2735 | if (spec == NULL) |
| 2736 | return -ENOMEM; |
| 2737 | |
| 2738 | codec->spec = spec; |
| 2739 | |
| 2740 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2741 | if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2742 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); |
| 2743 | board_config = ALC880_AUTO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2744 | } |
| 2745 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2746 | if (board_config == ALC880_AUTO) { |
| 2747 | /* automatic parse from the BIOS config */ |
| 2748 | err = alc880_parse_auto_config(codec); |
| 2749 | if (err < 0) { |
| 2750 | alc_free(codec); |
| 2751 | return err; |
| 2752 | } else if (! err) { |
| 2753 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); |
| 2754 | board_config = ALC880_3ST; |
| 2755 | } |
| 2756 | } |
| 2757 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2758 | if (board_config != ALC880_AUTO) |
| 2759 | setup_preset(spec, &alc880_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2760 | |
| 2761 | spec->stream_name_analog = "ALC880 Analog"; |
| 2762 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
| 2763 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
| 2764 | |
| 2765 | spec->stream_name_digital = "ALC880 Digital"; |
| 2766 | spec->stream_digital_playback = &alc880_pcm_digital_playback; |
| 2767 | spec->stream_digital_capture = &alc880_pcm_digital_capture; |
| 2768 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2769 | if (! spec->adc_nids && spec->input_mux) { |
| 2770 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 54d1740 | 2005-11-21 16:33:22 +0100 | [diff] [blame] | 2771 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2772 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 2773 | if (wcap != AC_WID_AUD_IN) { |
| 2774 | spec->adc_nids = alc880_adc_nids_alt; |
| 2775 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
| 2776 | spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; |
| 2777 | spec->num_mixers++; |
| 2778 | } else { |
| 2779 | spec->adc_nids = alc880_adc_nids; |
| 2780 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
| 2781 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; |
| 2782 | spec->num_mixers++; |
| 2783 | } |
| 2784 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2785 | |
| 2786 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2787 | if (board_config == ALC880_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2788 | spec->init_hook = alc880_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2789 | |
| 2790 | return 0; |
| 2791 | } |
| 2792 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2793 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2794 | /* |
| 2795 | * ALC260 support |
| 2796 | */ |
| 2797 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2798 | static hda_nid_t alc260_dac_nids[1] = { |
| 2799 | /* front */ |
| 2800 | 0x02, |
| 2801 | }; |
| 2802 | |
| 2803 | static hda_nid_t alc260_adc_nids[1] = { |
| 2804 | /* ADC0 */ |
| 2805 | 0x04, |
| 2806 | }; |
| 2807 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2808 | static hda_nid_t alc260_adc_nids_alt[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2809 | /* ADC1 */ |
| 2810 | 0x05, |
| 2811 | }; |
| 2812 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2813 | static hda_nid_t alc260_hp_adc_nids[2] = { |
| 2814 | /* ADC1, 0 */ |
| 2815 | 0x05, 0x04 |
| 2816 | }; |
| 2817 | |
Jonathan Woithe | d57fdac | 2006-02-28 11:38:35 +0100 | [diff] [blame] | 2818 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
| 2819 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. |
| 2820 | */ |
| 2821 | static hda_nid_t alc260_dual_adc_nids[2] = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2822 | /* ADC0, ADC1 */ |
| 2823 | 0x04, 0x05 |
| 2824 | }; |
| 2825 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2826 | #define ALC260_DIGOUT_NID 0x03 |
| 2827 | #define ALC260_DIGIN_NID 0x06 |
| 2828 | |
| 2829 | static struct hda_input_mux alc260_capture_source = { |
| 2830 | .num_items = 4, |
| 2831 | .items = { |
| 2832 | { "Mic", 0x0 }, |
| 2833 | { "Front Mic", 0x1 }, |
| 2834 | { "Line", 0x2 }, |
| 2835 | { "CD", 0x4 }, |
| 2836 | }, |
| 2837 | }; |
| 2838 | |
Jonathan Woithe | 17e7aec | 2006-02-28 11:35:18 +0100 | [diff] [blame] | 2839 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2840 | * headphone jack and the internal CD lines since these are the only pins at |
| 2841 | * which audio can appear. For flexibility, also allow the option of |
| 2842 | * recording the mixer output on the second ADC (ADC0 doesn't have a |
| 2843 | * connection to the mixer output). |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2844 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2845 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
| 2846 | { |
| 2847 | .num_items = 3, |
| 2848 | .items = { |
| 2849 | { "Mic/Line", 0x0 }, |
| 2850 | { "CD", 0x4 }, |
| 2851 | { "Headphone", 0x2 }, |
| 2852 | }, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2853 | }, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2854 | { |
| 2855 | .num_items = 4, |
| 2856 | .items = { |
| 2857 | { "Mic/Line", 0x0 }, |
| 2858 | { "CD", 0x4 }, |
| 2859 | { "Headphone", 0x2 }, |
| 2860 | { "Mixer", 0x5 }, |
| 2861 | }, |
| 2862 | }, |
| 2863 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2864 | }; |
| 2865 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2866 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
| 2867 | * the Fujitsu S702x, but jacks are marked differently. |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2868 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2869 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
| 2870 | { |
| 2871 | .num_items = 4, |
| 2872 | .items = { |
| 2873 | { "Mic", 0x0 }, |
| 2874 | { "Line", 0x2 }, |
| 2875 | { "CD", 0x4 }, |
| 2876 | { "Headphone", 0x5 }, |
| 2877 | }, |
| 2878 | }, |
| 2879 | { |
| 2880 | .num_items = 5, |
| 2881 | .items = { |
| 2882 | { "Mic", 0x0 }, |
| 2883 | { "Line", 0x2 }, |
| 2884 | { "CD", 0x4 }, |
| 2885 | { "Headphone", 0x6 }, |
| 2886 | { "Mixer", 0x5 }, |
| 2887 | }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2888 | }, |
| 2889 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2890 | /* |
| 2891 | * This is just place-holder, so there's something for alc_build_pcms to look |
| 2892 | * at when it calculates the maximum number of channels. ALC260 has no mixer |
| 2893 | * element which allows changing the channel mode, so the verb list is |
| 2894 | * never used. |
| 2895 | */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 2896 | static struct hda_channel_mode alc260_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | { 2, NULL }, |
| 2898 | }; |
| 2899 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2900 | |
| 2901 | /* Mixer combinations |
| 2902 | * |
| 2903 | * basic: base_output + input + pc_beep + capture |
| 2904 | * HP: base_output + input + capture_alt |
| 2905 | * HP_3013: hp_3013 + input + capture |
| 2906 | * fujitsu: fujitsu + capture |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2907 | * acer: acer + capture |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2908 | */ |
| 2909 | |
| 2910 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2911 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2912 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2913 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 2914 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
| 2915 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 2916 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
| 2917 | { } /* end */ |
| 2918 | }; |
| 2919 | |
| 2920 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2921 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 2922 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 2923 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 2924 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 2925 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 2926 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 2927 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), |
| 2928 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2929 | { } /* end */ |
| 2930 | }; |
| 2931 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2932 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { |
| 2933 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 2934 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 2935 | { } /* end */ |
| 2936 | }; |
| 2937 | |
| 2938 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
| 2939 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 2940 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 2941 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), |
| 2942 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), |
| 2943 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 2944 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 2945 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 2946 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2947 | { } /* end */ |
| 2948 | }; |
| 2949 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2950 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
| 2951 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
| 2952 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2953 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2954 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2955 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2956 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2957 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 2958 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 2959 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 2960 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2961 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2962 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 2963 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 2964 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2965 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2966 | { } /* end */ |
| 2967 | }; |
| 2968 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2969 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
| 2970 | * versions of the ALC260 don't act on requests to enable mic bias from NID |
| 2971 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 |
| 2972 | * datasheet doesn't mention this restriction. At this stage it's not clear |
| 2973 | * whether this behaviour is intentional or is a hardware bug in chip |
| 2974 | * revisions available in early 2006. Therefore for now allow the |
| 2975 | * "Headphone Jack Mode" control to span all choices, but if it turns out |
| 2976 | * that the lack of mic bias for this NID is intentional we could change the |
| 2977 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 2978 | * |
| 2979 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 |
| 2980 | * don't appear to make the mic bias available from the "line" jack, even |
| 2981 | * though the NID used for this jack (0x14) can supply it. The theory is |
| 2982 | * that perhaps Acer have included blocking capacitors between the ALC260 |
| 2983 | * and the output jack. If this turns out to be the case for all such |
| 2984 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT |
| 2985 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 2986 | */ |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2987 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
| 2988 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 2989 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2990 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2991 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 2992 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 2993 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 2994 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 2995 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), |
| 2996 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 2997 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 2998 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
| 2999 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3000 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3001 | { } /* end */ |
| 3002 | }; |
| 3003 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3004 | /* capture mixer elements */ |
| 3005 | static struct snd_kcontrol_new alc260_capture_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3006 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
| 3007 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3008 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
| 3009 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3010 | { |
| 3011 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3012 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3013 | * So call somewhat different.. |
| 3014 | * FIXME: the controls appear in the "playback" view! |
| 3015 | */ |
| 3016 | /* .name = "Capture Source", */ |
| 3017 | .name = "Input Source", |
| 3018 | .count = 2, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3019 | .info = alc_mux_enum_info, |
| 3020 | .get = alc_mux_enum_get, |
| 3021 | .put = alc_mux_enum_put, |
| 3022 | }, |
| 3023 | { } /* end */ |
| 3024 | }; |
| 3025 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3026 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { |
| 3027 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 3028 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 3029 | { |
| 3030 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3031 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3032 | * So call somewhat different.. |
| 3033 | * FIXME: the controls appear in the "playback" view! |
| 3034 | */ |
| 3035 | /* .name = "Capture Source", */ |
| 3036 | .name = "Input Source", |
| 3037 | .count = 1, |
| 3038 | .info = alc_mux_enum_info, |
| 3039 | .get = alc_mux_enum_get, |
| 3040 | .put = alc_mux_enum_put, |
| 3041 | }, |
| 3042 | { } /* end */ |
| 3043 | }; |
| 3044 | |
| 3045 | /* |
| 3046 | * initialization verbs |
| 3047 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3048 | static struct hda_verb alc260_init_verbs[] = { |
| 3049 | /* Line In pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3050 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3052 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3053 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3054 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3055 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3056 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3057 | /* LINE-2 is used for line-out in rear */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3058 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | /* select line-out */ |
Jonathan Woithe | fd56f2d | 2006-01-24 10:35:46 +0100 | [diff] [blame] | 3060 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | /* LINE-OUT pin */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3062 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | /* enable HP */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3064 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3065 | /* enable Mono */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3066 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3067 | /* mute capture amp left and right */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3068 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | /* set connection select to line in (default select for this ADC) */ |
| 3070 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3071 | /* mute capture amp left and right */ |
| 3072 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3073 | /* set connection select to line in (default select for this ADC) */ |
| 3074 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3075 | /* set vol=0 Line-Out mixer amp left and right */ |
| 3076 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3077 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3078 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3079 | /* set vol=0 HP mixer amp left and right */ |
| 3080 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3081 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3082 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3083 | /* set vol=0 Mono mixer amp left and right */ |
| 3084 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3085 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3086 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3087 | /* unmute LINE-2 out pin */ |
| 3088 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3089 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3090 | /* mute CD */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3091 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3092 | /* mute Line In */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3093 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3094 | /* mute Mic */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3095 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3096 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3097 | /* mute Front out path */ |
| 3098 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3099 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3100 | /* mute Headphone out path */ |
| 3101 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3102 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3103 | /* mute Mono out path */ |
| 3104 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3105 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3106 | { } |
| 3107 | }; |
| 3108 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3109 | static struct hda_verb alc260_hp_init_verbs[] = { |
| 3110 | /* Headphone and output */ |
| 3111 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 3112 | /* mono output */ |
| 3113 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3114 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 3115 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3116 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 3117 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3118 | /* Line In pin widget for input */ |
| 3119 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3120 | /* Line-2 pin widget for output */ |
| 3121 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3122 | /* CD pin widget for input */ |
| 3123 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3124 | /* unmute amp left and right */ |
| 3125 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 3126 | /* set connection select to line in (default select for this ADC) */ |
| 3127 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 3128 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 3129 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3130 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3131 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3132 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 3133 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3134 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3135 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3136 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 3137 | /* unmute CD */ |
| 3138 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 3139 | /* unmute Line In */ |
| 3140 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 3141 | /* unmute Mic */ |
| 3142 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3143 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 3144 | /* Unmute Front out path */ |
| 3145 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3146 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3147 | /* Unmute Headphone out path */ |
| 3148 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3149 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3150 | /* Unmute Mono out path */ |
| 3151 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3152 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3153 | { } |
| 3154 | }; |
| 3155 | |
| 3156 | static struct hda_verb alc260_hp_3013_init_verbs[] = { |
| 3157 | /* Line out and output */ |
| 3158 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3159 | /* mono output */ |
| 3160 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3161 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 3162 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3163 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 3164 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3165 | /* Line In pin widget for input */ |
| 3166 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3167 | /* Headphone pin widget for output */ |
| 3168 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 3169 | /* CD pin widget for input */ |
| 3170 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3171 | /* unmute amp left and right */ |
| 3172 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 3173 | /* set connection select to line in (default select for this ADC) */ |
| 3174 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 3175 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 3176 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3177 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3178 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3179 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 3180 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3181 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3182 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3183 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 3184 | /* unmute CD */ |
| 3185 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 3186 | /* unmute Line In */ |
| 3187 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 3188 | /* unmute Mic */ |
| 3189 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3190 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 3191 | /* Unmute Front out path */ |
| 3192 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3193 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3194 | /* Unmute Headphone out path */ |
| 3195 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3196 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3197 | /* Unmute Mono out path */ |
| 3198 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3199 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3200 | { } |
| 3201 | }; |
| 3202 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3203 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3204 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
| 3205 | * audio = 0x16, internal speaker = 0x10. |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3206 | */ |
| 3207 | static struct hda_verb alc260_fujitsu_init_verbs[] = { |
| 3208 | /* Disable all GPIOs */ |
| 3209 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, |
| 3210 | /* Internal speaker is connected to headphone pin */ |
| 3211 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3212 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ |
| 3213 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3214 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
| 3215 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3216 | /* Ensure all other unused pins are disabled and muted. */ |
| 3217 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3218 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3219 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3220 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3221 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3222 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3223 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3224 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3225 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3226 | /* Disable digital (SPDIF) pins */ |
| 3227 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3228 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3229 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3230 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
| 3231 | * when acting as an output. |
| 3232 | */ |
| 3233 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3234 | |
| 3235 | /* Start with output sum widgets muted and their output gains at min */ |
Takashi Iwai | 8b33a5a | 2006-02-09 11:57:01 +0100 | [diff] [blame] | 3236 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3237 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3238 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3239 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3240 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3241 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3242 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3243 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3244 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3245 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3246 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
| 3247 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3248 | /* Unmute Line1 pin widget output buffer since it starts as an output. |
| 3249 | * If the pin mode is changed by the user the pin mode control will |
| 3250 | * take care of enabling the pin's input/output buffers as needed. |
| 3251 | * Therefore there's no need to enable the input buffer at this |
| 3252 | * stage. |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3253 | */ |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3254 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3255 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
| 3256 | * mixer ctrl) |
| 3257 | */ |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3258 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3259 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3260 | /* Mute capture amp left and right */ |
| 3261 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3262 | /* Set ADC connection select to match default mixer setting - line |
| 3263 | * in (on mic1 pin) |
| 3264 | */ |
| 3265 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3266 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3267 | /* Do the same for the second ADC: mute capture input amp and |
| 3268 | * set ADC connection to line in (on mic1 pin) |
| 3269 | */ |
| 3270 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3271 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3272 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3273 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3274 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3275 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3276 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3277 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3278 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3279 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3280 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3281 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3282 | |
| 3283 | { } |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3284 | }; |
| 3285 | |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3286 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
| 3287 | * similar laptops (adapted from Fujitsu init verbs). |
| 3288 | */ |
| 3289 | static struct hda_verb alc260_acer_init_verbs[] = { |
| 3290 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and |
| 3291 | * the headphone jack. Turn this on and rely on the standard mute |
| 3292 | * methods whenever the user wants to turn these outputs off. |
| 3293 | */ |
| 3294 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 3295 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 3296 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 3297 | /* Internal speaker/Headphone jack is connected to Line-out pin */ |
| 3298 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3299 | /* Internal microphone/Mic jack is connected to Mic1 pin */ |
| 3300 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
| 3301 | /* Line In jack is connected to Line1 pin */ |
| 3302 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3303 | /* Ensure all other unused pins are disabled and muted. */ |
| 3304 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3305 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3306 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3307 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3308 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3309 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3310 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3311 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3312 | /* Disable digital (SPDIF) pins */ |
| 3313 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3314 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3315 | |
| 3316 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
| 3317 | * bus when acting as outputs. |
| 3318 | */ |
| 3319 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3320 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3321 | |
| 3322 | /* Start with output sum widgets muted and their output gains at min */ |
| 3323 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3324 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3325 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3326 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3327 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3328 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3329 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3330 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3331 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3332 | |
| 3333 | /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ |
| 3334 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3335 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
| 3336 | * inputs. If the pin mode is changed by the user the pin mode control |
| 3337 | * will take care of enabling the pin's input/output buffers as needed. |
| 3338 | * Therefore there's no need to enable the input buffer at this |
| 3339 | * stage. |
| 3340 | */ |
| 3341 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3342 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3343 | |
| 3344 | /* Mute capture amp left and right */ |
| 3345 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3346 | /* Set ADC connection select to match default mixer setting - mic |
| 3347 | * (on mic1 pin) |
| 3348 | */ |
| 3349 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3350 | |
| 3351 | /* Do similar with the second ADC: mute capture input amp and |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3352 | * set ADC connection to mic to match ALSA's default state. |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3353 | */ |
| 3354 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3355 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3356 | |
| 3357 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3358 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3359 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3360 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3361 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3362 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3363 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3364 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3365 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 3366 | |
| 3367 | { } |
| 3368 | }; |
| 3369 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3370 | /* Test configuration for debugging, modelled after the ALC880 test |
| 3371 | * configuration. |
| 3372 | */ |
| 3373 | #ifdef CONFIG_SND_DEBUG |
| 3374 | static hda_nid_t alc260_test_dac_nids[1] = { |
| 3375 | 0x02, |
| 3376 | }; |
| 3377 | static hda_nid_t alc260_test_adc_nids[2] = { |
| 3378 | 0x04, 0x05, |
| 3379 | }; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3380 | /* For testing the ALC260, each input MUX needs its own definition since |
| 3381 | * the signal assignments are different. This assumes that the first ADC |
| 3382 | * is NID 0x04. |
Jonathan Woithe | 17e7aec | 2006-02-28 11:35:18 +0100 | [diff] [blame] | 3383 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3384 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
| 3385 | { |
| 3386 | .num_items = 7, |
| 3387 | .items = { |
| 3388 | { "MIC1 pin", 0x0 }, |
| 3389 | { "MIC2 pin", 0x1 }, |
| 3390 | { "LINE1 pin", 0x2 }, |
| 3391 | { "LINE2 pin", 0x3 }, |
| 3392 | { "CD pin", 0x4 }, |
| 3393 | { "LINE-OUT pin", 0x5 }, |
| 3394 | { "HP-OUT pin", 0x6 }, |
| 3395 | }, |
| 3396 | }, |
| 3397 | { |
| 3398 | .num_items = 8, |
| 3399 | .items = { |
| 3400 | { "MIC1 pin", 0x0 }, |
| 3401 | { "MIC2 pin", 0x1 }, |
| 3402 | { "LINE1 pin", 0x2 }, |
| 3403 | { "LINE2 pin", 0x3 }, |
| 3404 | { "CD pin", 0x4 }, |
| 3405 | { "Mixer", 0x5 }, |
| 3406 | { "LINE-OUT pin", 0x6 }, |
| 3407 | { "HP-OUT pin", 0x7 }, |
| 3408 | }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3409 | }, |
| 3410 | }; |
| 3411 | static struct snd_kcontrol_new alc260_test_mixer[] = { |
| 3412 | /* Output driver widgets */ |
| 3413 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 3414 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
| 3415 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 3416 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), |
| 3417 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 3418 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), |
| 3419 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3420 | /* Modes for retasking pin widgets |
| 3421 | * Note: the ALC260 doesn't seem to act on requests to enable mic |
| 3422 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't |
| 3423 | * mention this restriction. At this stage it's not clear whether |
| 3424 | * this behaviour is intentional or is a hardware bug in chip |
| 3425 | * revisions available at least up until early 2006. Therefore for |
| 3426 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all |
| 3427 | * choices, but if it turns out that the lack of mic bias for these |
| 3428 | * NIDs is intentional we could change their modes from |
| 3429 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 3430 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3431 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
| 3432 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), |
| 3433 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), |
| 3434 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), |
| 3435 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), |
| 3436 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), |
| 3437 | |
| 3438 | /* Loopback mixer controls */ |
| 3439 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), |
| 3440 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), |
| 3441 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), |
| 3442 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), |
| 3443 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 3444 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 3445 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), |
| 3446 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), |
| 3447 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 3448 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 3449 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3450 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3451 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), |
| 3452 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), |
| 3453 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), |
| 3454 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 3455 | |
| 3456 | /* Controls for GPIO pins, assuming they are configured as outputs */ |
| 3457 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), |
| 3458 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), |
| 3459 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), |
| 3460 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), |
| 3461 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 3462 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
| 3463 | * is ambigious as to which NID is which; testing on laptops which |
| 3464 | * make this output available should provide clarification. |
| 3465 | */ |
| 3466 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), |
| 3467 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), |
| 3468 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3469 | { } /* end */ |
| 3470 | }; |
| 3471 | static struct hda_verb alc260_test_init_verbs[] = { |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 3472 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
| 3473 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, |
| 3474 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 3475 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, |
| 3476 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3477 | /* Enable retasking pins as output, initially without power amp */ |
| 3478 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3479 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3480 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3481 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3482 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3483 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3484 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 3485 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 3486 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 3487 | * payload also sets the generation to 0, output to be in "consumer" |
| 3488 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 3489 | * control. |
| 3490 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3491 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3492 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3493 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3494 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3495 | * OUT1 sum bus when acting as an output. |
| 3496 | */ |
| 3497 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3498 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3499 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3500 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3501 | |
| 3502 | /* Start with output sum widgets muted and their output gains at min */ |
| 3503 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3504 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3505 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3506 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3507 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3508 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3509 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3510 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3511 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3512 | |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3513 | /* Unmute retasking pin widget output buffers since the default |
| 3514 | * state appears to be output. As the pin mode is changed by the |
| 3515 | * user the pin mode control will take care of enabling the pin's |
| 3516 | * input/output buffers as needed. |
| 3517 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3518 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3519 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3520 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3521 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3522 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3523 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3524 | /* Also unmute the mono-out pin widget */ |
| 3525 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3526 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3527 | /* Mute capture amp left and right */ |
| 3528 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3529 | /* Set ADC connection select to match default mixer setting (mic1 |
| 3530 | * pin) |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3531 | */ |
| 3532 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3533 | |
| 3534 | /* Do the same for the second ADC: mute capture input amp and |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3535 | * set ADC connection to mic1 pin |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3536 | */ |
| 3537 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3538 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3539 | |
| 3540 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3541 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3542 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3543 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3544 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3545 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3546 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3547 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3548 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 3549 | |
| 3550 | { } |
| 3551 | }; |
| 3552 | #endif |
| 3553 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3554 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
| 3555 | .substreams = 1, |
| 3556 | .channels_min = 2, |
| 3557 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3558 | }; |
| 3559 | |
| 3560 | static struct hda_pcm_stream alc260_pcm_analog_capture = { |
| 3561 | .substreams = 1, |
| 3562 | .channels_min = 2, |
| 3563 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3564 | }; |
| 3565 | |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 3566 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
| 3567 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture |
| 3568 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3569 | /* |
| 3570 | * for BIOS auto-configuration |
| 3571 | */ |
| 3572 | |
| 3573 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
| 3574 | const char *pfx) |
| 3575 | { |
| 3576 | hda_nid_t nid_vol; |
| 3577 | unsigned long vol_val, sw_val; |
| 3578 | char name[32]; |
| 3579 | int err; |
| 3580 | |
| 3581 | if (nid >= 0x0f && nid < 0x11) { |
| 3582 | nid_vol = nid - 0x7; |
| 3583 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 3584 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3585 | } else if (nid == 0x11) { |
| 3586 | nid_vol = nid - 0x7; |
| 3587 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); |
| 3588 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
| 3589 | } else if (nid >= 0x12 && nid <= 0x15) { |
| 3590 | nid_vol = 0x08; |
| 3591 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 3592 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3593 | } else |
| 3594 | return 0; /* N/A */ |
| 3595 | |
| 3596 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3597 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) |
| 3598 | return err; |
| 3599 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
| 3600 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) |
| 3601 | return err; |
| 3602 | return 1; |
| 3603 | } |
| 3604 | |
| 3605 | /* add playback controls from the parsed DAC table */ |
| 3606 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 3607 | const struct auto_pin_cfg *cfg) |
| 3608 | { |
| 3609 | hda_nid_t nid; |
| 3610 | int err; |
| 3611 | |
| 3612 | spec->multiout.num_dacs = 1; |
| 3613 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 3614 | spec->multiout.dac_nids[0] = 0x02; |
| 3615 | |
| 3616 | nid = cfg->line_out_pins[0]; |
| 3617 | if (nid) { |
| 3618 | err = alc260_add_playback_controls(spec, nid, "Front"); |
| 3619 | if (err < 0) |
| 3620 | return err; |
| 3621 | } |
| 3622 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3623 | nid = cfg->speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3624 | if (nid) { |
| 3625 | err = alc260_add_playback_controls(spec, nid, "Speaker"); |
| 3626 | if (err < 0) |
| 3627 | return err; |
| 3628 | } |
| 3629 | |
| 3630 | nid = cfg->hp_pin; |
| 3631 | if (nid) { |
| 3632 | err = alc260_add_playback_controls(spec, nid, "Headphone"); |
| 3633 | if (err < 0) |
| 3634 | return err; |
| 3635 | } |
| 3636 | return 0; |
| 3637 | } |
| 3638 | |
| 3639 | /* create playback/capture controls for input pins */ |
| 3640 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 3641 | const struct auto_pin_cfg *cfg) |
| 3642 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3643 | struct hda_input_mux *imux = &spec->private_imux; |
| 3644 | int i, err, idx; |
| 3645 | |
| 3646 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 3647 | if (cfg->input_pins[i] >= 0x12) { |
| 3648 | idx = cfg->input_pins[i] - 0x12; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3649 | err = new_analog_input(spec, cfg->input_pins[i], |
| 3650 | auto_pin_cfg_labels[i], idx, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3651 | if (err < 0) |
| 3652 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3653 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3654 | imux->items[imux->num_items].index = idx; |
| 3655 | imux->num_items++; |
| 3656 | } |
| 3657 | if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ |
| 3658 | idx = cfg->input_pins[i] - 0x09; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3659 | err = new_analog_input(spec, cfg->input_pins[i], |
| 3660 | auto_pin_cfg_labels[i], idx, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3661 | if (err < 0) |
| 3662 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3663 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3664 | imux->items[imux->num_items].index = idx; |
| 3665 | imux->num_items++; |
| 3666 | } |
| 3667 | } |
| 3668 | return 0; |
| 3669 | } |
| 3670 | |
| 3671 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3672 | hda_nid_t nid, int pin_type, |
| 3673 | int sel_idx) |
| 3674 | { |
| 3675 | /* set as output */ |
| 3676 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 3677 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 3678 | /* need the manual connection? */ |
| 3679 | if (nid >= 0x12) { |
| 3680 | int idx = nid - 0x12; |
| 3681 | snd_hda_codec_write(codec, idx + 0x0b, 0, |
| 3682 | AC_VERB_SET_CONNECT_SEL, sel_idx); |
| 3683 | |
| 3684 | } |
| 3685 | } |
| 3686 | |
| 3687 | static void alc260_auto_init_multi_out(struct hda_codec *codec) |
| 3688 | { |
| 3689 | struct alc_spec *spec = codec->spec; |
| 3690 | hda_nid_t nid; |
| 3691 | |
| 3692 | nid = spec->autocfg.line_out_pins[0]; |
| 3693 | if (nid) |
| 3694 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3695 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3696 | nid = spec->autocfg.speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3697 | if (nid) |
| 3698 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3699 | |
| 3700 | nid = spec->autocfg.hp_pin; |
| 3701 | if (nid) |
| 3702 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3703 | } |
| 3704 | |
| 3705 | #define ALC260_PIN_CD_NID 0x16 |
| 3706 | static void alc260_auto_init_analog_input(struct hda_codec *codec) |
| 3707 | { |
| 3708 | struct alc_spec *spec = codec->spec; |
| 3709 | int i; |
| 3710 | |
| 3711 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 3712 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 3713 | if (nid >= 0x12) { |
| 3714 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3715 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 3716 | if (nid != ALC260_PIN_CD_NID) |
| 3717 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3718 | AMP_OUT_MUTE); |
| 3719 | } |
| 3720 | } |
| 3721 | } |
| 3722 | |
| 3723 | /* |
| 3724 | * generic initialization of ADC, input mixers and output mixers |
| 3725 | */ |
| 3726 | static struct hda_verb alc260_volume_init_verbs[] = { |
| 3727 | /* |
| 3728 | * Unmute ADC0-1 and set the default input to mic-in |
| 3729 | */ |
| 3730 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3731 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3732 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3733 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3734 | |
| 3735 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3736 | * mixer widget |
| 3737 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 3738 | * mic (mic 2) |
| 3739 | */ |
| 3740 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 3741 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3742 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3743 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3744 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3745 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 3746 | |
| 3747 | /* |
| 3748 | * Set up output mixers (0x08 - 0x0a) |
| 3749 | */ |
| 3750 | /* set vol=0 to output mixers */ |
| 3751 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3752 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3753 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3754 | /* set up input amps for analog loopback */ |
| 3755 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 3756 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3757 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3758 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3759 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3760 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3761 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3762 | |
| 3763 | { } |
| 3764 | }; |
| 3765 | |
| 3766 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 3767 | { |
| 3768 | struct alc_spec *spec = codec->spec; |
| 3769 | unsigned int wcap; |
| 3770 | int err; |
| 3771 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
| 3772 | |
| 3773 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 3774 | alc260_ignore)) < 0) |
| 3775 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3776 | if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) |
| 3777 | return err; |
| 3778 | if (! spec->kctl_alloc) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3779 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3780 | if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3781 | return err; |
| 3782 | |
| 3783 | spec->multiout.max_channels = 2; |
| 3784 | |
| 3785 | if (spec->autocfg.dig_out_pin) |
| 3786 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; |
| 3787 | if (spec->kctl_alloc) |
| 3788 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 3789 | |
| 3790 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; |
| 3791 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3792 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3793 | spec->input_mux = &spec->private_imux; |
| 3794 | |
| 3795 | /* check whether NID 0x04 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3796 | wcap = get_wcaps(codec, 0x04); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3797 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 3798 | if (wcap != AC_WID_AUD_IN) { |
| 3799 | spec->adc_nids = alc260_adc_nids_alt; |
| 3800 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); |
| 3801 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3802 | } else { |
| 3803 | spec->adc_nids = alc260_adc_nids; |
| 3804 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); |
| 3805 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3806 | } |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3807 | spec->num_mixers++; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3808 | |
| 3809 | return 1; |
| 3810 | } |
| 3811 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 3812 | /* additional initialization for auto-configuration model */ |
| 3813 | static void alc260_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3814 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3815 | alc260_auto_init_multi_out(codec); |
| 3816 | alc260_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3817 | } |
| 3818 | |
| 3819 | /* |
| 3820 | * ALC260 configurations |
| 3821 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3822 | static struct hda_board_config alc260_cfg_tbl[] = { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3823 | { .modelname = "basic", .config = ALC260_BASIC }, |
Takashi Iwai | b14e77e | 2006-01-11 18:10:50 +0100 | [diff] [blame] | 3824 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, |
| 3825 | .config = ALC260_BASIC }, /* Sony VAIO */ |
Kenneth Crudup | 5e1b151 | 2006-04-28 13:03:48 +0200 | [diff] [blame] | 3826 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd, |
| 3827 | .config = ALC260_BASIC }, /* Sony VAIO */ |
Takashi Iwai | c1fc804 | 2006-03-06 14:17:31 +0100 | [diff] [blame] | 3828 | { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729, |
| 3829 | .config = ALC260_BASIC }, /* CTL Travel Master U553W */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3830 | { .modelname = "hp", .config = ALC260_HP }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3831 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, |
| 3832 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, |
| 3833 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP }, |
| 3834 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, |
| 3835 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, |
| 3836 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, |
| 3837 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, |
| 3838 | { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, |
| 3839 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3840 | { .modelname = "acer", .config = ALC260_ACER }, |
| 3841 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3842 | #ifdef CONFIG_SND_DEBUG |
| 3843 | { .modelname = "test", .config = ALC260_TEST }, |
| 3844 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3845 | { .modelname = "auto", .config = ALC260_AUTO }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3846 | {} |
| 3847 | }; |
| 3848 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3849 | static struct alc_config_preset alc260_presets[] = { |
| 3850 | [ALC260_BASIC] = { |
| 3851 | .mixers = { alc260_base_output_mixer, |
| 3852 | alc260_input_mixer, |
| 3853 | alc260_pc_beep_mixer, |
| 3854 | alc260_capture_mixer }, |
| 3855 | .init_verbs = { alc260_init_verbs }, |
| 3856 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3857 | .dac_nids = alc260_dac_nids, |
| 3858 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), |
| 3859 | .adc_nids = alc260_adc_nids, |
| 3860 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3861 | .channel_mode = alc260_modes, |
| 3862 | .input_mux = &alc260_capture_source, |
| 3863 | }, |
| 3864 | [ALC260_HP] = { |
| 3865 | .mixers = { alc260_base_output_mixer, |
| 3866 | alc260_input_mixer, |
| 3867 | alc260_capture_alt_mixer }, |
| 3868 | .init_verbs = { alc260_hp_init_verbs }, |
| 3869 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3870 | .dac_nids = alc260_dac_nids, |
| 3871 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 3872 | .adc_nids = alc260_hp_adc_nids, |
| 3873 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3874 | .channel_mode = alc260_modes, |
| 3875 | .input_mux = &alc260_capture_source, |
| 3876 | }, |
| 3877 | [ALC260_HP_3013] = { |
| 3878 | .mixers = { alc260_hp_3013_mixer, |
| 3879 | alc260_input_mixer, |
| 3880 | alc260_capture_alt_mixer }, |
| 3881 | .init_verbs = { alc260_hp_3013_init_verbs }, |
| 3882 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3883 | .dac_nids = alc260_dac_nids, |
| 3884 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 3885 | .adc_nids = alc260_hp_adc_nids, |
| 3886 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3887 | .channel_mode = alc260_modes, |
| 3888 | .input_mux = &alc260_capture_source, |
| 3889 | }, |
| 3890 | [ALC260_FUJITSU_S702X] = { |
| 3891 | .mixers = { alc260_fujitsu_mixer, |
| 3892 | alc260_capture_mixer }, |
| 3893 | .init_verbs = { alc260_fujitsu_init_verbs }, |
| 3894 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3895 | .dac_nids = alc260_dac_nids, |
Jonathan Woithe | d57fdac | 2006-02-28 11:38:35 +0100 | [diff] [blame] | 3896 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
| 3897 | .adc_nids = alc260_dual_adc_nids, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3898 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3899 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3900 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
| 3901 | .input_mux = alc260_fujitsu_capture_sources, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3902 | }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3903 | [ALC260_ACER] = { |
| 3904 | .mixers = { alc260_acer_mixer, |
| 3905 | alc260_capture_mixer }, |
| 3906 | .init_verbs = { alc260_acer_init_verbs }, |
| 3907 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3908 | .dac_nids = alc260_dac_nids, |
| 3909 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
| 3910 | .adc_nids = alc260_dual_adc_nids, |
| 3911 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3912 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3913 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
| 3914 | .input_mux = alc260_acer_capture_sources, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3915 | }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3916 | #ifdef CONFIG_SND_DEBUG |
| 3917 | [ALC260_TEST] = { |
| 3918 | .mixers = { alc260_test_mixer, |
| 3919 | alc260_capture_mixer }, |
| 3920 | .init_verbs = { alc260_test_init_verbs }, |
| 3921 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), |
| 3922 | .dac_nids = alc260_test_dac_nids, |
| 3923 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), |
| 3924 | .adc_nids = alc260_test_adc_nids, |
| 3925 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3926 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3927 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
| 3928 | .input_mux = alc260_test_capture_sources, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3929 | }, |
| 3930 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3931 | }; |
| 3932 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3933 | static int patch_alc260(struct hda_codec *codec) |
| 3934 | { |
| 3935 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3936 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 3938 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3939 | if (spec == NULL) |
| 3940 | return -ENOMEM; |
| 3941 | |
| 3942 | codec->spec = spec; |
| 3943 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3944 | board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); |
| 3945 | if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { |
| 3946 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3947 | board_config = ALC260_AUTO; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3948 | } |
| 3949 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3950 | if (board_config == ALC260_AUTO) { |
| 3951 | /* automatic parse from the BIOS config */ |
| 3952 | err = alc260_parse_auto_config(codec); |
| 3953 | if (err < 0) { |
| 3954 | alc_free(codec); |
| 3955 | return err; |
| 3956 | } else if (! err) { |
| 3957 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 3958 | board_config = ALC260_BASIC; |
| 3959 | } |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3960 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3961 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3962 | if (board_config != ALC260_AUTO) |
| 3963 | setup_preset(spec, &alc260_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | |
| 3965 | spec->stream_name_analog = "ALC260 Analog"; |
| 3966 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
| 3967 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
| 3968 | |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 3969 | spec->stream_name_digital = "ALC260 Digital"; |
| 3970 | spec->stream_digital_playback = &alc260_pcm_digital_playback; |
| 3971 | spec->stream_digital_capture = &alc260_pcm_digital_capture; |
| 3972 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3973 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3974 | if (board_config == ALC260_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 3975 | spec->init_hook = alc260_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3976 | |
| 3977 | return 0; |
| 3978 | } |
| 3979 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 3980 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3981 | /* |
| 3982 | * ALC882 support |
| 3983 | * |
| 3984 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 3985 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 3986 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 3987 | * 6-channel independent captures. |
| 3988 | * |
| 3989 | * In addition, an independent DAC for the multi-playback (not used in this |
| 3990 | * driver yet). |
| 3991 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3992 | #define ALC882_DIGOUT_NID 0x06 |
| 3993 | #define ALC882_DIGIN_NID 0x0a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3994 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 3995 | static struct hda_channel_mode alc882_ch_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | { 8, NULL } |
| 3997 | }; |
| 3998 | |
| 3999 | static hda_nid_t alc882_dac_nids[4] = { |
| 4000 | /* front, rear, clfe, rear_surr */ |
| 4001 | 0x02, 0x03, 0x04, 0x05 |
| 4002 | }; |
| 4003 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4004 | /* identical with ALC880 */ |
| 4005 | #define alc882_adc_nids alc880_adc_nids |
| 4006 | #define alc882_adc_nids_alt alc880_adc_nids_alt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4007 | |
| 4008 | /* input MUX */ |
| 4009 | /* FIXME: should be a matrix-type input source selection */ |
| 4010 | |
| 4011 | static struct hda_input_mux alc882_capture_source = { |
| 4012 | .num_items = 4, |
| 4013 | .items = { |
| 4014 | { "Mic", 0x0 }, |
| 4015 | { "Front Mic", 0x1 }, |
| 4016 | { "Line", 0x2 }, |
| 4017 | { "CD", 0x4 }, |
| 4018 | }, |
| 4019 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4020 | #define alc882_mux_enum_info alc_mux_enum_info |
| 4021 | #define alc882_mux_enum_get alc_mux_enum_get |
| 4022 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 4023 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4024 | { |
| 4025 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4026 | struct alc_spec *spec = codec->spec; |
| 4027 | const struct hda_input_mux *imux = spec->input_mux; |
| 4028 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 4029 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; |
| 4030 | hda_nid_t nid = capture_mixers[adc_idx]; |
| 4031 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
| 4032 | unsigned int i, idx; |
| 4033 | |
| 4034 | idx = ucontrol->value.enumerated.item[0]; |
| 4035 | if (idx >= imux->num_items) |
| 4036 | idx = imux->num_items - 1; |
| 4037 | if (*cur_val == idx && ! codec->in_resume) |
| 4038 | return 0; |
| 4039 | for (i = 0; i < imux->num_items; i++) { |
| 4040 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; |
| 4041 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4042 | v | (imux->items[i].index << 8)); |
| 4043 | } |
| 4044 | *cur_val = idx; |
| 4045 | return 1; |
| 4046 | } |
| 4047 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4048 | /* |
| 4049 | * 6ch mode |
| 4050 | */ |
| 4051 | static struct hda_verb alc882_sixstack_ch6_init[] = { |
| 4052 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4053 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4054 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4055 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4056 | { } /* end */ |
| 4057 | }; |
| 4058 | |
| 4059 | /* |
| 4060 | * 8ch mode |
| 4061 | */ |
| 4062 | static struct hda_verb alc882_sixstack_ch8_init[] = { |
| 4063 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4064 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4065 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4066 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4067 | { } /* end */ |
| 4068 | }; |
| 4069 | |
| 4070 | static struct hda_channel_mode alc882_sixstack_modes[2] = { |
| 4071 | { 6, alc882_sixstack_ch6_init }, |
| 4072 | { 8, alc882_sixstack_ch8_init }, |
| 4073 | }; |
| 4074 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4075 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
| 4076 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
| 4077 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 4078 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4079 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4080 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4081 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4082 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4083 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 4084 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4085 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 4086 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4087 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4088 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4089 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 4090 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4091 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4092 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4093 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4094 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4095 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4096 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 4097 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 4098 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4099 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 4100 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 4101 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 4102 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 4103 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 4104 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 4105 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 4106 | { |
| 4107 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4108 | /* .name = "Capture Source", */ |
| 4109 | .name = "Input Source", |
| 4110 | .count = 3, |
| 4111 | .info = alc882_mux_enum_info, |
| 4112 | .get = alc882_mux_enum_get, |
| 4113 | .put = alc882_mux_enum_put, |
| 4114 | }, |
| 4115 | { } /* end */ |
| 4116 | }; |
| 4117 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4118 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
| 4119 | { |
| 4120 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4121 | .name = "Channel Mode", |
| 4122 | .info = alc_ch_mode_info, |
| 4123 | .get = alc_ch_mode_get, |
| 4124 | .put = alc_ch_mode_put, |
| 4125 | }, |
| 4126 | { } /* end */ |
| 4127 | }; |
| 4128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4129 | static struct hda_verb alc882_init_verbs[] = { |
| 4130 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4131 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4132 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4133 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4134 | /* Rear mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4135 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4136 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4137 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4138 | /* CLFE mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4139 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4140 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4141 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4142 | /* Side mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4143 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4144 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4145 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4146 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4147 | /* Front Pin: output 0 (0x0c) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4148 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4149 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4150 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4151 | /* Rear Pin: output 1 (0x0d) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4152 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4153 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4154 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4155 | /* CLFE Pin: output 2 (0x0e) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4156 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4157 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4158 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4159 | /* Side Pin: output 3 (0x0f) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4160 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4161 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4163 | /* Mic (rear) pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4164 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4165 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4166 | /* Front Mic pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4167 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4168 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4169 | /* Line In pin: input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4170 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4171 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4172 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ |
| 4173 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4174 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4175 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4176 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4177 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4178 | |
| 4179 | /* FIXME: use matrix-type input source selection */ |
| 4180 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4181 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4182 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4183 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4184 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4185 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4186 | /* Input mixer2 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4187 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4188 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4189 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4190 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4191 | /* Input mixer3 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4192 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4193 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4194 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4195 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4196 | /* ADC1: mute amp left and right */ |
| 4197 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4198 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4199 | /* ADC2: mute amp left and right */ |
| 4200 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4201 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4202 | /* ADC3: mute amp left and right */ |
| 4203 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4204 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4205 | |
| 4206 | { } |
| 4207 | }; |
| 4208 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4209 | /* |
| 4210 | * generic initialization of ADC, input mixers and output mixers |
| 4211 | */ |
| 4212 | static struct hda_verb alc882_auto_init_verbs[] = { |
| 4213 | /* |
| 4214 | * Unmute ADC0-2 and set the default input to mic-in |
| 4215 | */ |
| 4216 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4217 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4218 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4219 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4220 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4221 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4222 | |
| 4223 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 4224 | * mixer widget |
| 4225 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 4226 | * mic (mic 2) |
| 4227 | */ |
| 4228 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 4229 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4230 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4231 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4232 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4233 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4234 | |
| 4235 | /* |
| 4236 | * Set up output mixers (0x0c - 0x0f) |
| 4237 | */ |
| 4238 | /* set vol=0 to output mixers */ |
| 4239 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4240 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4241 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4242 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4243 | /* set up input amps for analog loopback */ |
| 4244 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 4245 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4246 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4247 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4248 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4249 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4250 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4251 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4252 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4253 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4254 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4255 | |
| 4256 | /* FIXME: use matrix-type input source selection */ |
| 4257 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4258 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 4259 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4260 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4261 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4262 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4263 | /* Input mixer2 */ |
| 4264 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4265 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4266 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4267 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4268 | /* Input mixer3 */ |
| 4269 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4270 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4271 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4272 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4273 | |
| 4274 | { } |
| 4275 | }; |
| 4276 | |
| 4277 | /* capture mixer elements */ |
| 4278 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { |
| 4279 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4280 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4281 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 4282 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 4283 | { |
| 4284 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4285 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4286 | * So call somewhat different.. |
| 4287 | * FIXME: the controls appear in the "playback" view! |
| 4288 | */ |
| 4289 | /* .name = "Capture Source", */ |
| 4290 | .name = "Input Source", |
| 4291 | .count = 2, |
| 4292 | .info = alc882_mux_enum_info, |
| 4293 | .get = alc882_mux_enum_get, |
| 4294 | .put = alc882_mux_enum_put, |
| 4295 | }, |
| 4296 | { } /* end */ |
| 4297 | }; |
| 4298 | |
| 4299 | static struct snd_kcontrol_new alc882_capture_mixer[] = { |
| 4300 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 4301 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 4302 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 4303 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 4304 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 4305 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 4306 | { |
| 4307 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4308 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4309 | * So call somewhat different.. |
| 4310 | * FIXME: the controls appear in the "playback" view! |
| 4311 | */ |
| 4312 | /* .name = "Capture Source", */ |
| 4313 | .name = "Input Source", |
| 4314 | .count = 3, |
| 4315 | .info = alc882_mux_enum_info, |
| 4316 | .get = alc882_mux_enum_get, |
| 4317 | .put = alc882_mux_enum_put, |
| 4318 | }, |
| 4319 | { } /* end */ |
| 4320 | }; |
| 4321 | |
| 4322 | /* pcm configuration: identiacal with ALC880 */ |
| 4323 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback |
| 4324 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture |
| 4325 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback |
| 4326 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture |
| 4327 | |
| 4328 | /* |
| 4329 | * configuration and preset |
| 4330 | */ |
| 4331 | static struct hda_board_config alc882_cfg_tbl[] = { |
Takashi Iwai | 1494a92 | 2006-01-31 10:58:46 +0100 | [diff] [blame] | 4332 | { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, |
| 4333 | { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4334 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ |
| 4335 | { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ |
| 4336 | { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ |
Takashi Iwai | 1494a92 | 2006-01-31 10:58:46 +0100 | [diff] [blame] | 4337 | { .modelname = "auto", .config = ALC882_AUTO }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4338 | {} |
| 4339 | }; |
| 4340 | |
| 4341 | static struct alc_config_preset alc882_presets[] = { |
| 4342 | [ALC882_3ST_DIG] = { |
| 4343 | .mixers = { alc882_base_mixer }, |
| 4344 | .init_verbs = { alc882_init_verbs }, |
| 4345 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 4346 | .dac_nids = alc882_dac_nids, |
| 4347 | .dig_out_nid = ALC882_DIGOUT_NID, |
| 4348 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), |
| 4349 | .adc_nids = alc882_adc_nids, |
| 4350 | .dig_in_nid = ALC882_DIGIN_NID, |
| 4351 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), |
| 4352 | .channel_mode = alc882_ch_modes, |
| 4353 | .input_mux = &alc882_capture_source, |
| 4354 | }, |
| 4355 | [ALC882_6ST_DIG] = { |
| 4356 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, |
| 4357 | .init_verbs = { alc882_init_verbs }, |
| 4358 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 4359 | .dac_nids = alc882_dac_nids, |
| 4360 | .dig_out_nid = ALC882_DIGOUT_NID, |
| 4361 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), |
| 4362 | .adc_nids = alc882_adc_nids, |
| 4363 | .dig_in_nid = ALC882_DIGIN_NID, |
| 4364 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), |
| 4365 | .channel_mode = alc882_sixstack_modes, |
| 4366 | .input_mux = &alc882_capture_source, |
| 4367 | }, |
| 4368 | }; |
| 4369 | |
| 4370 | |
| 4371 | /* |
| 4372 | * BIOS auto configuration |
| 4373 | */ |
| 4374 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, |
| 4375 | hda_nid_t nid, int pin_type, |
| 4376 | int dac_idx) |
| 4377 | { |
| 4378 | /* set as output */ |
| 4379 | struct alc_spec *spec = codec->spec; |
| 4380 | int idx; |
| 4381 | |
| 4382 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
| 4383 | idx = 4; |
| 4384 | else |
| 4385 | idx = spec->multiout.dac_nids[dac_idx] - 2; |
| 4386 | |
| 4387 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 4388 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 4389 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
| 4390 | |
| 4391 | } |
| 4392 | |
| 4393 | static void alc882_auto_init_multi_out(struct hda_codec *codec) |
| 4394 | { |
| 4395 | struct alc_spec *spec = codec->spec; |
| 4396 | int i; |
| 4397 | |
| 4398 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4399 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4400 | if (nid) |
| 4401 | alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 4402 | } |
| 4403 | } |
| 4404 | |
| 4405 | static void alc882_auto_init_hp_out(struct hda_codec *codec) |
| 4406 | { |
| 4407 | struct alc_spec *spec = codec->spec; |
| 4408 | hda_nid_t pin; |
| 4409 | |
| 4410 | pin = spec->autocfg.hp_pin; |
| 4411 | if (pin) /* connect to front */ |
| 4412 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ |
| 4413 | } |
| 4414 | |
| 4415 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) |
| 4416 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID |
| 4417 | |
| 4418 | static void alc882_auto_init_analog_input(struct hda_codec *codec) |
| 4419 | { |
| 4420 | struct alc_spec *spec = codec->spec; |
| 4421 | int i; |
| 4422 | |
| 4423 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 4424 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 4425 | if (alc882_is_input_pin(nid)) { |
| 4426 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4427 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 4428 | if (nid != ALC882_PIN_CD_NID) |
| 4429 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4430 | AMP_OUT_MUTE); |
| 4431 | } |
| 4432 | } |
| 4433 | } |
| 4434 | |
| 4435 | /* almost identical with ALC880 parser... */ |
| 4436 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 4437 | { |
| 4438 | struct alc_spec *spec = codec->spec; |
| 4439 | int err = alc880_parse_auto_config(codec); |
| 4440 | |
| 4441 | if (err < 0) |
| 4442 | return err; |
Takashi Iwai | c5f2ea0 | 2005-12-06 18:54:31 +0100 | [diff] [blame] | 4443 | else if (err > 0) |
| 4444 | /* hack - override the init verbs */ |
| 4445 | spec->init_verbs[0] = alc882_auto_init_verbs; |
| 4446 | return err; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4447 | } |
| 4448 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4449 | /* additional initialization for auto-configuration model */ |
| 4450 | static void alc882_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4451 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4452 | alc882_auto_init_multi_out(codec); |
| 4453 | alc882_auto_init_hp_out(codec); |
| 4454 | alc882_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4455 | } |
| 4456 | |
| 4457 | /* |
| 4458 | * ALC882 Headphone poll in 3.5.1a or 3.5.2 |
| 4459 | */ |
| 4460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4461 | static int patch_alc882(struct hda_codec *codec) |
| 4462 | { |
| 4463 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4464 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4465 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4466 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4467 | if (spec == NULL) |
| 4468 | return -ENOMEM; |
| 4469 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4470 | codec->spec = spec; |
| 4471 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4472 | board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4473 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4474 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { |
| 4475 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); |
| 4476 | board_config = ALC882_AUTO; |
| 4477 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4478 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4479 | if (board_config == ALC882_AUTO) { |
| 4480 | /* automatic parse from the BIOS config */ |
| 4481 | err = alc882_parse_auto_config(codec); |
| 4482 | if (err < 0) { |
| 4483 | alc_free(codec); |
| 4484 | return err; |
| 4485 | } else if (! err) { |
| 4486 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 4487 | board_config = ALC882_3ST_DIG; |
| 4488 | } |
| 4489 | } |
| 4490 | |
| 4491 | if (board_config != ALC882_AUTO) |
| 4492 | setup_preset(spec, &alc882_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4493 | |
| 4494 | spec->stream_name_analog = "ALC882 Analog"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4495 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
| 4496 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4497 | |
| 4498 | spec->stream_name_digital = "ALC882 Digital"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4499 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
| 4500 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4501 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4502 | if (! spec->adc_nids && spec->input_mux) { |
| 4503 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 4504 | unsigned int wcap = get_wcaps(codec, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4505 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 4506 | if (wcap != AC_WID_AUD_IN) { |
| 4507 | spec->adc_nids = alc882_adc_nids_alt; |
| 4508 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); |
| 4509 | spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; |
| 4510 | spec->num_mixers++; |
| 4511 | } else { |
| 4512 | spec->adc_nids = alc882_adc_nids; |
| 4513 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); |
| 4514 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; |
| 4515 | spec->num_mixers++; |
| 4516 | } |
| 4517 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | |
| 4519 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4520 | if (board_config == ALC882_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4521 | spec->init_hook = alc882_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4522 | |
| 4523 | return 0; |
| 4524 | } |
| 4525 | |
| 4526 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4527 | * ALC262 support |
| 4528 | */ |
| 4529 | |
| 4530 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID |
| 4531 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID |
| 4532 | |
| 4533 | #define alc262_dac_nids alc260_dac_nids |
| 4534 | #define alc262_adc_nids alc882_adc_nids |
| 4535 | #define alc262_adc_nids_alt alc882_adc_nids_alt |
| 4536 | |
| 4537 | #define alc262_modes alc260_modes |
Takashi Iwai | c5f2ea0 | 2005-12-06 18:54:31 +0100 | [diff] [blame] | 4538 | #define alc262_capture_source alc882_capture_source |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4539 | |
| 4540 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
| 4541 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4542 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 4543 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4544 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4545 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4546 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4547 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4548 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4549 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 4550 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 4551 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4552 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
| 4553 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
| 4554 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 4555 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 4556 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4557 | { } /* end */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 4558 | }; |
| 4559 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4560 | #define alc262_capture_mixer alc882_capture_mixer |
| 4561 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer |
| 4562 | |
| 4563 | /* |
| 4564 | * generic initialization of ADC, input mixers and output mixers |
| 4565 | */ |
| 4566 | static struct hda_verb alc262_init_verbs[] = { |
| 4567 | /* |
| 4568 | * Unmute ADC0-2 and set the default input to mic-in |
| 4569 | */ |
| 4570 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4571 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4572 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4573 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4574 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4575 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4576 | |
| 4577 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 4578 | * mixer widget |
| 4579 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 4580 | * mic (mic 2) |
| 4581 | */ |
| 4582 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 4583 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4584 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4585 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4586 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4587 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4588 | |
| 4589 | /* |
| 4590 | * Set up output mixers (0x0c - 0x0e) |
| 4591 | */ |
| 4592 | /* set vol=0 to output mixers */ |
| 4593 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4594 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4595 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4596 | /* set up input amps for analog loopback */ |
| 4597 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 4598 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4599 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4600 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4601 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4602 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4603 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4604 | |
| 4605 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 4606 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 4607 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 4608 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 4609 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 4610 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 4611 | |
| 4612 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 4613 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 4614 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 4615 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 4616 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 4617 | |
| 4618 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4619 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 4620 | |
| 4621 | /* FIXME: use matrix-type input source selection */ |
| 4622 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4623 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 4624 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4625 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4626 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4627 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4628 | /* Input mixer2 */ |
| 4629 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4630 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4631 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4632 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4633 | /* Input mixer3 */ |
| 4634 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4635 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4636 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4637 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4638 | |
| 4639 | { } |
| 4640 | }; |
| 4641 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 4642 | /* |
| 4643 | * fujitsu model |
| 4644 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker |
| 4645 | */ |
| 4646 | |
| 4647 | #define ALC_HP_EVENT 0x37 |
| 4648 | |
| 4649 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { |
| 4650 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
| 4651 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4652 | {} |
| 4653 | }; |
| 4654 | |
| 4655 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
| 4656 | .num_items = 2, |
| 4657 | .items = { |
| 4658 | { "Mic", 0x0 }, |
| 4659 | { "CD", 0x4 }, |
| 4660 | }, |
| 4661 | }; |
| 4662 | |
| 4663 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
| 4664 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
| 4665 | { |
| 4666 | struct alc_spec *spec = codec->spec; |
| 4667 | unsigned int mute; |
| 4668 | |
| 4669 | if (force || ! spec->sense_updated) { |
| 4670 | unsigned int present; |
| 4671 | /* need to execute and sync at first */ |
| 4672 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); |
| 4673 | present = snd_hda_codec_read(codec, 0x14, 0, |
| 4674 | AC_VERB_GET_PIN_SENSE, 0); |
| 4675 | spec->jack_present = (present & 0x80000000) != 0; |
| 4676 | spec->sense_updated = 1; |
| 4677 | } |
| 4678 | if (spec->jack_present) { |
| 4679 | /* mute internal speaker */ |
| 4680 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
| 4681 | 0x80, 0x80); |
| 4682 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
| 4683 | 0x80, 0x80); |
| 4684 | } else { |
| 4685 | /* unmute internal speaker if necessary */ |
| 4686 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
| 4687 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
| 4688 | 0x80, mute & 0x80); |
| 4689 | mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); |
| 4690 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
| 4691 | 0x80, mute & 0x80); |
| 4692 | } |
| 4693 | } |
| 4694 | |
| 4695 | /* unsolicited event for HP jack sensing */ |
| 4696 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, |
| 4697 | unsigned int res) |
| 4698 | { |
| 4699 | if ((res >> 26) != ALC_HP_EVENT) |
| 4700 | return; |
| 4701 | alc262_fujitsu_automute(codec, 1); |
| 4702 | } |
| 4703 | |
| 4704 | /* bind volumes of both NID 0x0c and 0x0d */ |
| 4705 | static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, |
| 4706 | struct snd_ctl_elem_value *ucontrol) |
| 4707 | { |
| 4708 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4709 | long *valp = ucontrol->value.integer.value; |
| 4710 | int change; |
| 4711 | |
| 4712 | change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, |
| 4713 | 0x7f, valp[0] & 0x7f); |
| 4714 | change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, |
| 4715 | 0x7f, valp[1] & 0x7f); |
| 4716 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, |
| 4717 | 0x7f, valp[0] & 0x7f); |
| 4718 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, |
| 4719 | 0x7f, valp[1] & 0x7f); |
| 4720 | return change; |
| 4721 | } |
| 4722 | |
| 4723 | /* bind hp and internal speaker mute (with plug check) */ |
| 4724 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, |
| 4725 | struct snd_ctl_elem_value *ucontrol) |
| 4726 | { |
| 4727 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4728 | long *valp = ucontrol->value.integer.value; |
| 4729 | int change; |
| 4730 | |
| 4731 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
| 4732 | 0x80, valp[0] ? 0 : 0x80); |
| 4733 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
| 4734 | 0x80, valp[1] ? 0 : 0x80); |
| 4735 | if (change || codec->in_resume) |
| 4736 | alc262_fujitsu_automute(codec, codec->in_resume); |
| 4737 | return change; |
| 4738 | } |
| 4739 | |
| 4740 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { |
| 4741 | { |
| 4742 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4743 | .name = "Master Playback Volume", |
| 4744 | .info = snd_hda_mixer_amp_volume_info, |
| 4745 | .get = snd_hda_mixer_amp_volume_get, |
| 4746 | .put = alc262_fujitsu_master_vol_put, |
| 4747 | .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), |
| 4748 | }, |
| 4749 | { |
| 4750 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4751 | .name = "Master Playback Switch", |
| 4752 | .info = snd_hda_mixer_amp_switch_info, |
| 4753 | .get = snd_hda_mixer_amp_switch_get, |
| 4754 | .put = alc262_fujitsu_master_sw_put, |
| 4755 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 4756 | }, |
| 4757 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4758 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4759 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
| 4760 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4761 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4762 | { } /* end */ |
| 4763 | }; |
| 4764 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4765 | /* add playback controls from the parsed DAC table */ |
| 4766 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 4767 | { |
| 4768 | hda_nid_t nid; |
| 4769 | int err; |
| 4770 | |
| 4771 | spec->multiout.num_dacs = 1; /* only use one dac */ |
| 4772 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 4773 | spec->multiout.dac_nids[0] = 2; |
| 4774 | |
| 4775 | nid = cfg->line_out_pins[0]; |
| 4776 | if (nid) { |
| 4777 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", |
| 4778 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) |
| 4779 | return err; |
| 4780 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", |
| 4781 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 4782 | return err; |
| 4783 | } |
| 4784 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4785 | nid = cfg->speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4786 | if (nid) { |
| 4787 | if (nid == 0x16) { |
| 4788 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", |
| 4789 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 4790 | return err; |
| 4791 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 4792 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 4793 | return err; |
| 4794 | } else { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4795 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 4796 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 4797 | return err; |
| 4798 | } |
| 4799 | } |
| 4800 | nid = cfg->hp_pin; |
| 4801 | if (nid) { |
| 4802 | /* spec->multiout.hp_nid = 2; */ |
| 4803 | if (nid == 0x16) { |
| 4804 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 4805 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 4806 | return err; |
| 4807 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 4808 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 4809 | return err; |
| 4810 | } else { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4811 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 4812 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 4813 | return err; |
| 4814 | } |
| 4815 | } |
| 4816 | return 0; |
| 4817 | } |
| 4818 | |
| 4819 | /* identical with ALC880 */ |
| 4820 | #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls |
| 4821 | |
| 4822 | /* |
| 4823 | * generic initialization of ADC, input mixers and output mixers |
| 4824 | */ |
| 4825 | static struct hda_verb alc262_volume_init_verbs[] = { |
| 4826 | /* |
| 4827 | * Unmute ADC0-2 and set the default input to mic-in |
| 4828 | */ |
| 4829 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4830 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4831 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4832 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4833 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4834 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4835 | |
| 4836 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 4837 | * mixer widget |
| 4838 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 4839 | * mic (mic 2) |
| 4840 | */ |
| 4841 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 4842 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4843 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4844 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4845 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4846 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4847 | |
| 4848 | /* |
| 4849 | * Set up output mixers (0x0c - 0x0f) |
| 4850 | */ |
| 4851 | /* set vol=0 to output mixers */ |
| 4852 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4853 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4854 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4855 | |
| 4856 | /* set up input amps for analog loopback */ |
| 4857 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 4858 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4859 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4860 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4861 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4862 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4863 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4864 | |
| 4865 | /* FIXME: use matrix-type input source selection */ |
| 4866 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4867 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 4868 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4869 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4870 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4871 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4872 | /* Input mixer2 */ |
| 4873 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4874 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4875 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4876 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4877 | /* Input mixer3 */ |
| 4878 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4879 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4880 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4881 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4882 | |
| 4883 | { } |
| 4884 | }; |
| 4885 | |
| 4886 | /* pcm configuration: identiacal with ALC880 */ |
| 4887 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback |
| 4888 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture |
| 4889 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback |
| 4890 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture |
| 4891 | |
| 4892 | /* |
| 4893 | * BIOS auto configuration |
| 4894 | */ |
| 4895 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 4896 | { |
| 4897 | struct alc_spec *spec = codec->spec; |
| 4898 | int err; |
| 4899 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
| 4900 | |
| 4901 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 4902 | alc262_ignore)) < 0) |
| 4903 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4904 | if (! spec->autocfg.line_outs) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4905 | return 0; /* can't find valid BIOS pin config */ |
| 4906 | if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 4907 | (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 4908 | return err; |
| 4909 | |
| 4910 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4911 | |
| 4912 | if (spec->autocfg.dig_out_pin) |
| 4913 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; |
| 4914 | if (spec->autocfg.dig_in_pin) |
| 4915 | spec->dig_in_nid = ALC262_DIGIN_NID; |
| 4916 | |
| 4917 | if (spec->kctl_alloc) |
| 4918 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 4919 | |
| 4920 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 4921 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4922 | spec->input_mux = &spec->private_imux; |
| 4923 | |
| 4924 | return 1; |
| 4925 | } |
| 4926 | |
| 4927 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out |
| 4928 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out |
| 4929 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input |
| 4930 | |
| 4931 | |
| 4932 | /* init callback for auto-configuration model -- overriding the default init */ |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4933 | static void alc262_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4934 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4935 | alc262_auto_init_multi_out(codec); |
| 4936 | alc262_auto_init_hp_out(codec); |
| 4937 | alc262_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4938 | } |
| 4939 | |
| 4940 | /* |
| 4941 | * configuration and preset |
| 4942 | */ |
| 4943 | static struct hda_board_config alc262_cfg_tbl[] = { |
| 4944 | { .modelname = "basic", .config = ALC262_BASIC }, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 4945 | { .modelname = "fujitsu", .config = ALC262_FUJITSU }, |
| 4946 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4947 | { .modelname = "auto", .config = ALC262_AUTO }, |
| 4948 | {} |
| 4949 | }; |
| 4950 | |
| 4951 | static struct alc_config_preset alc262_presets[] = { |
| 4952 | [ALC262_BASIC] = { |
| 4953 | .mixers = { alc262_base_mixer }, |
| 4954 | .init_verbs = { alc262_init_verbs }, |
| 4955 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 4956 | .dac_nids = alc262_dac_nids, |
| 4957 | .hp_nid = 0x03, |
| 4958 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 4959 | .channel_mode = alc262_modes, |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 4960 | .input_mux = &alc262_capture_source, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4961 | }, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 4962 | [ALC262_FUJITSU] = { |
| 4963 | .mixers = { alc262_fujitsu_mixer }, |
| 4964 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, |
| 4965 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 4966 | .dac_nids = alc262_dac_nids, |
| 4967 | .hp_nid = 0x03, |
| 4968 | .dig_out_nid = ALC262_DIGOUT_NID, |
| 4969 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 4970 | .channel_mode = alc262_modes, |
| 4971 | .input_mux = &alc262_fujitsu_capture_source, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4972 | .unsol_event = alc262_fujitsu_unsol_event, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 4973 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4974 | }; |
| 4975 | |
| 4976 | static int patch_alc262(struct hda_codec *codec) |
| 4977 | { |
| 4978 | struct alc_spec *spec; |
| 4979 | int board_config; |
| 4980 | int err; |
| 4981 | |
| 4982 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 4983 | if (spec == NULL) |
| 4984 | return -ENOMEM; |
| 4985 | |
| 4986 | codec->spec = spec; |
| 4987 | #if 0 |
| 4988 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ |
| 4989 | { |
| 4990 | int tmp; |
| 4991 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4992 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 4993 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4994 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 4995 | } |
| 4996 | #endif |
| 4997 | |
| 4998 | board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); |
| 4999 | if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { |
| 5000 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); |
| 5001 | board_config = ALC262_AUTO; |
| 5002 | } |
| 5003 | |
| 5004 | if (board_config == ALC262_AUTO) { |
| 5005 | /* automatic parse from the BIOS config */ |
| 5006 | err = alc262_parse_auto_config(codec); |
| 5007 | if (err < 0) { |
| 5008 | alc_free(codec); |
| 5009 | return err; |
| 5010 | } else if (! err) { |
| 5011 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 5012 | board_config = ALC262_BASIC; |
| 5013 | } |
| 5014 | } |
| 5015 | |
| 5016 | if (board_config != ALC262_AUTO) |
| 5017 | setup_preset(spec, &alc262_presets[board_config]); |
| 5018 | |
| 5019 | spec->stream_name_analog = "ALC262 Analog"; |
| 5020 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
| 5021 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
| 5022 | |
| 5023 | spec->stream_name_digital = "ALC262 Digital"; |
| 5024 | spec->stream_digital_playback = &alc262_pcm_digital_playback; |
| 5025 | spec->stream_digital_capture = &alc262_pcm_digital_capture; |
| 5026 | |
| 5027 | if (! spec->adc_nids && spec->input_mux) { |
| 5028 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 5029 | unsigned int wcap = get_wcaps(codec, 0x07); |
| 5030 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5031 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 5032 | if (wcap != AC_WID_AUD_IN) { |
| 5033 | spec->adc_nids = alc262_adc_nids_alt; |
| 5034 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); |
| 5035 | spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; |
| 5036 | spec->num_mixers++; |
| 5037 | } else { |
| 5038 | spec->adc_nids = alc262_adc_nids; |
| 5039 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); |
| 5040 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; |
| 5041 | spec->num_mixers++; |
| 5042 | } |
| 5043 | } |
| 5044 | |
| 5045 | codec->patch_ops = alc_patch_ops; |
| 5046 | if (board_config == ALC262_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 5047 | spec->init_hook = alc262_auto_init; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5048 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5049 | return 0; |
| 5050 | } |
| 5051 | |
| 5052 | |
| 5053 | /* |
| 5054 | * ALC861 channel source setting (2/6 channel selection for 3-stack) |
| 5055 | */ |
| 5056 | |
| 5057 | /* |
| 5058 | * set the path ways for 2 channel output |
| 5059 | * need to set the codec line out and mic 1 pin widgets to inputs |
| 5060 | */ |
| 5061 | static struct hda_verb alc861_threestack_ch2_init[] = { |
| 5062 | /* set pin widget 1Ah (line in) for input */ |
| 5063 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 5064 | /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ |
| 5065 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 5066 | |
| 5067 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
| 5068 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic |
| 5069 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in |
| 5070 | { } /* end */ |
| 5071 | }; |
| 5072 | /* |
| 5073 | * 6ch mode |
| 5074 | * need to set the codec line out and mic 1 pin widgets to outputs |
| 5075 | */ |
| 5076 | static struct hda_verb alc861_threestack_ch6_init[] = { |
| 5077 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ |
| 5078 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5079 | /* set pin widget 18h (mic1) for output (CLFE)*/ |
| 5080 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5081 | |
| 5082 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5083 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5084 | |
| 5085 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 5086 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic |
| 5087 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in |
| 5088 | { } /* end */ |
| 5089 | }; |
| 5090 | |
| 5091 | static struct hda_channel_mode alc861_threestack_modes[2] = { |
| 5092 | { 2, alc861_threestack_ch2_init }, |
| 5093 | { 6, alc861_threestack_ch6_init }, |
| 5094 | }; |
| 5095 | |
| 5096 | /* patch-ALC861 */ |
| 5097 | |
| 5098 | static struct snd_kcontrol_new alc861_base_mixer[] = { |
| 5099 | /* output mixer control */ |
| 5100 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 5101 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 5102 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 5103 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 5104 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), |
| 5105 | |
| 5106 | /*Input mixer control */ |
| 5107 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 5108 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 5109 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 5110 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 5111 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 5112 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 5113 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 5114 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 5115 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 5116 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 5117 | |
| 5118 | /* Capture mixer control */ |
| 5119 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 5120 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 5121 | { |
| 5122 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5123 | .name = "Capture Source", |
| 5124 | .count = 1, |
| 5125 | .info = alc_mux_enum_info, |
| 5126 | .get = alc_mux_enum_get, |
| 5127 | .put = alc_mux_enum_put, |
| 5128 | }, |
| 5129 | { } /* end */ |
| 5130 | }; |
| 5131 | |
| 5132 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { |
| 5133 | /* output mixer control */ |
| 5134 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 5135 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 5136 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 5137 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 5138 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ |
| 5139 | |
| 5140 | /* Input mixer control */ |
| 5141 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 5142 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 5143 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 5144 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 5145 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 5146 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 5147 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 5148 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 5149 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 5150 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 5151 | |
| 5152 | /* Capture mixer control */ |
| 5153 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 5154 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 5155 | { |
| 5156 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5157 | .name = "Capture Source", |
| 5158 | .count = 1, |
| 5159 | .info = alc_mux_enum_info, |
| 5160 | .get = alc_mux_enum_get, |
| 5161 | .put = alc_mux_enum_put, |
| 5162 | }, |
| 5163 | { |
| 5164 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5165 | .name = "Channel Mode", |
| 5166 | .info = alc_ch_mode_info, |
| 5167 | .get = alc_ch_mode_get, |
| 5168 | .put = alc_ch_mode_put, |
| 5169 | .private_value = ARRAY_SIZE(alc861_threestack_modes), |
| 5170 | }, |
| 5171 | { } /* end */ |
| 5172 | }; |
| 5173 | |
| 5174 | /* |
| 5175 | * generic initialization of ADC, input mixers and output mixers |
| 5176 | */ |
| 5177 | static struct hda_verb alc861_base_init_verbs[] = { |
| 5178 | /* |
| 5179 | * Unmute ADC0 and set the default input to mic-in |
| 5180 | */ |
| 5181 | /* port-A for surround (rear panel) */ |
| 5182 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5183 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5184 | /* port-B for mic-in (rear panel) with vref */ |
| 5185 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 5186 | /* port-C for line-in (rear panel) */ |
| 5187 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 5188 | /* port-D for Front */ |
| 5189 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5190 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5191 | /* port-E for HP out (front panel) */ |
| 5192 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 5193 | /* route front PCM to HP */ |
| 5194 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 5195 | /* port-F for mic-in (front panel) with vref */ |
| 5196 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 5197 | /* port-G for CLFE (rear panel) */ |
| 5198 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5199 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5200 | /* port-H for side (rear panel) */ |
| 5201 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5202 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5203 | /* CD-in */ |
| 5204 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 5205 | /* route front mic to ADC1*/ |
| 5206 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5207 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5208 | |
| 5209 | /* Unmute DAC0~3 & spdif out*/ |
| 5210 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5211 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5212 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5213 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5214 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5215 | |
| 5216 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 5217 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5218 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5219 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5220 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5221 | |
| 5222 | /* Unmute Stereo Mixer 15 */ |
| 5223 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5224 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5225 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5226 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 5227 | |
| 5228 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5229 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5230 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5231 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5232 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5233 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5234 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5235 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5236 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 5237 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5238 | |
| 5239 | { } |
| 5240 | }; |
| 5241 | |
| 5242 | static struct hda_verb alc861_threestack_init_verbs[] = { |
| 5243 | /* |
| 5244 | * Unmute ADC0 and set the default input to mic-in |
| 5245 | */ |
| 5246 | /* port-A for surround (rear panel) */ |
| 5247 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 5248 | /* port-B for mic-in (rear panel) with vref */ |
| 5249 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 5250 | /* port-C for line-in (rear panel) */ |
| 5251 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 5252 | /* port-D for Front */ |
| 5253 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 5254 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 5255 | /* port-E for HP out (front panel) */ |
| 5256 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 5257 | /* route front PCM to HP */ |
| 5258 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 5259 | /* port-F for mic-in (front panel) with vref */ |
| 5260 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 5261 | /* port-G for CLFE (rear panel) */ |
| 5262 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 5263 | /* port-H for side (rear panel) */ |
| 5264 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 5265 | /* CD-in */ |
| 5266 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 5267 | /* route front mic to ADC1*/ |
| 5268 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5269 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5270 | /* Unmute DAC0~3 & spdif out*/ |
| 5271 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5272 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5273 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5274 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5275 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5276 | |
| 5277 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 5278 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5279 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5280 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5281 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5282 | |
| 5283 | /* Unmute Stereo Mixer 15 */ |
| 5284 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5285 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5286 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5287 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 5288 | |
| 5289 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5290 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5291 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5292 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5293 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5294 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5295 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5296 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5297 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 5298 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5299 | { } |
| 5300 | }; |
| 5301 | /* |
| 5302 | * generic initialization of ADC, input mixers and output mixers |
| 5303 | */ |
| 5304 | static struct hda_verb alc861_auto_init_verbs[] = { |
| 5305 | /* |
| 5306 | * Unmute ADC0 and set the default input to mic-in |
| 5307 | */ |
| 5308 | // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5309 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5310 | |
| 5311 | /* Unmute DAC0~3 & spdif out*/ |
| 5312 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 5313 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 5314 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 5315 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 5316 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 5317 | |
| 5318 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 5319 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5320 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5321 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5322 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5323 | |
| 5324 | /* Unmute Stereo Mixer 15 */ |
| 5325 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5326 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5327 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5328 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, |
| 5329 | |
| 5330 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5331 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5332 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5333 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5334 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5335 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5336 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5337 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5338 | |
| 5339 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 5340 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5341 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5342 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5343 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 5344 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5345 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5346 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5347 | |
| 5348 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 |
| 5349 | |
| 5350 | { } |
| 5351 | }; |
| 5352 | |
| 5353 | /* pcm configuration: identiacal with ALC880 */ |
| 5354 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback |
| 5355 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture |
| 5356 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback |
| 5357 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture |
| 5358 | |
| 5359 | |
| 5360 | #define ALC861_DIGOUT_NID 0x07 |
| 5361 | |
| 5362 | static struct hda_channel_mode alc861_8ch_modes[1] = { |
| 5363 | { 8, NULL } |
| 5364 | }; |
| 5365 | |
| 5366 | static hda_nid_t alc861_dac_nids[4] = { |
| 5367 | /* front, surround, clfe, side */ |
| 5368 | 0x03, 0x06, 0x05, 0x04 |
| 5369 | }; |
| 5370 | |
| 5371 | static hda_nid_t alc861_adc_nids[1] = { |
| 5372 | /* ADC0-2 */ |
| 5373 | 0x08, |
| 5374 | }; |
| 5375 | |
| 5376 | static struct hda_input_mux alc861_capture_source = { |
| 5377 | .num_items = 5, |
| 5378 | .items = { |
| 5379 | { "Mic", 0x0 }, |
| 5380 | { "Front Mic", 0x3 }, |
| 5381 | { "Line", 0x1 }, |
| 5382 | { "CD", 0x4 }, |
| 5383 | { "Mixer", 0x5 }, |
| 5384 | }, |
| 5385 | }; |
| 5386 | |
| 5387 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 5388 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 5389 | { |
| 5390 | int i; |
| 5391 | hda_nid_t nid; |
| 5392 | |
| 5393 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 5394 | for (i = 0; i < cfg->line_outs; i++) { |
| 5395 | nid = cfg->line_out_pins[i]; |
| 5396 | if (nid) { |
| 5397 | if (i >= ARRAY_SIZE(alc861_dac_nids)) |
| 5398 | continue; |
| 5399 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; |
| 5400 | } |
| 5401 | } |
| 5402 | spec->multiout.num_dacs = cfg->line_outs; |
| 5403 | return 0; |
| 5404 | } |
| 5405 | |
| 5406 | /* add playback controls from the parsed DAC table */ |
| 5407 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 5408 | const struct auto_pin_cfg *cfg) |
| 5409 | { |
| 5410 | char name[32]; |
| 5411 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 5412 | hda_nid_t nid; |
| 5413 | int i, idx, err; |
| 5414 | |
| 5415 | for (i = 0; i < cfg->line_outs; i++) { |
| 5416 | nid = spec->multiout.dac_nids[i]; |
| 5417 | if (! nid) |
| 5418 | continue; |
| 5419 | if (nid == 0x05) { |
| 5420 | /* Center/LFE */ |
| 5421 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 5422 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 5423 | return err; |
| 5424 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 5425 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 5426 | return err; |
| 5427 | } else { |
| 5428 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) |
| 5429 | if (nid == alc861_dac_nids[idx]) |
| 5430 | break; |
| 5431 | sprintf(name, "%s Playback Switch", chname[idx]); |
| 5432 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 5433 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 5434 | return err; |
| 5435 | } |
| 5436 | } |
| 5437 | return 0; |
| 5438 | } |
| 5439 | |
| 5440 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) |
| 5441 | { |
| 5442 | int err; |
| 5443 | hda_nid_t nid; |
| 5444 | |
| 5445 | if (! pin) |
| 5446 | return 0; |
| 5447 | |
| 5448 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { |
| 5449 | nid = 0x03; |
| 5450 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 5451 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 5452 | return err; |
| 5453 | spec->multiout.hp_nid = nid; |
| 5454 | } |
| 5455 | return 0; |
| 5456 | } |
| 5457 | |
| 5458 | /* create playback/capture controls for input pins */ |
| 5459 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 5460 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5461 | struct hda_input_mux *imux = &spec->private_imux; |
| 5462 | int i, err, idx, idx1; |
| 5463 | |
| 5464 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 5465 | switch(cfg->input_pins[i]) { |
| 5466 | case 0x0c: |
| 5467 | idx1 = 1; |
| 5468 | idx = 2; // Line In |
| 5469 | break; |
| 5470 | case 0x0f: |
| 5471 | idx1 = 2; |
| 5472 | idx = 2; // Line In |
| 5473 | break; |
| 5474 | case 0x0d: |
| 5475 | idx1 = 0; |
| 5476 | idx = 1; // Mic In |
| 5477 | break; |
| 5478 | case 0x10: |
| 5479 | idx1 = 3; |
| 5480 | idx = 1; // Mic In |
| 5481 | break; |
| 5482 | case 0x11: |
| 5483 | idx1 = 4; |
| 5484 | idx = 0; // CD |
| 5485 | break; |
| 5486 | default: |
| 5487 | continue; |
| 5488 | } |
| 5489 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 5490 | err = new_analog_input(spec, cfg->input_pins[i], |
| 5491 | auto_pin_cfg_labels[i], idx, 0x15); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5492 | if (err < 0) |
| 5493 | return err; |
| 5494 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 5495 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5496 | imux->items[imux->num_items].index = idx1; |
| 5497 | imux->num_items++; |
| 5498 | } |
| 5499 | return 0; |
| 5500 | } |
| 5501 | |
| 5502 | static struct snd_kcontrol_new alc861_capture_mixer[] = { |
| 5503 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 5504 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 5505 | |
| 5506 | { |
| 5507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5508 | /* The multiple "Capture Source" controls confuse alsamixer |
| 5509 | * So call somewhat different.. |
| 5510 | *FIXME: the controls appear in the "playback" view! |
| 5511 | */ |
| 5512 | /* .name = "Capture Source", */ |
| 5513 | .name = "Input Source", |
| 5514 | .count = 1, |
| 5515 | .info = alc_mux_enum_info, |
| 5516 | .get = alc_mux_enum_get, |
| 5517 | .put = alc_mux_enum_put, |
| 5518 | }, |
| 5519 | { } /* end */ |
| 5520 | }; |
| 5521 | |
| 5522 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, |
| 5523 | int pin_type, int dac_idx) |
| 5524 | { |
| 5525 | /* set as output */ |
| 5526 | |
| 5527 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 5528 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 5529 | |
| 5530 | } |
| 5531 | |
| 5532 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
| 5533 | { |
| 5534 | struct alc_spec *spec = codec->spec; |
| 5535 | int i; |
| 5536 | |
| 5537 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 5538 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 5539 | if (nid) |
| 5540 | alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); |
| 5541 | } |
| 5542 | } |
| 5543 | |
| 5544 | static void alc861_auto_init_hp_out(struct hda_codec *codec) |
| 5545 | { |
| 5546 | struct alc_spec *spec = codec->spec; |
| 5547 | hda_nid_t pin; |
| 5548 | |
| 5549 | pin = spec->autocfg.hp_pin; |
| 5550 | if (pin) /* connect to front */ |
| 5551 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); |
| 5552 | } |
| 5553 | |
| 5554 | static void alc861_auto_init_analog_input(struct hda_codec *codec) |
| 5555 | { |
| 5556 | struct alc_spec *spec = codec->spec; |
| 5557 | int i; |
| 5558 | |
| 5559 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 5560 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 5561 | if ((nid>=0x0c) && (nid <=0x11)) { |
| 5562 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5563 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 5564 | } |
| 5565 | } |
| 5566 | } |
| 5567 | |
| 5568 | /* parse the BIOS configuration and set up the alc_spec */ |
| 5569 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 5570 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 5571 | { |
| 5572 | struct alc_spec *spec = codec->spec; |
| 5573 | int err; |
| 5574 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
| 5575 | |
| 5576 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 5577 | alc861_ignore)) < 0) |
| 5578 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5579 | if (! spec->autocfg.line_outs) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5580 | return 0; /* can't find valid BIOS pin config */ |
| 5581 | |
| 5582 | if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 5583 | (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 5584 | (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || |
| 5585 | (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 5586 | return err; |
| 5587 | |
| 5588 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 5589 | |
| 5590 | if (spec->autocfg.dig_out_pin) |
| 5591 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; |
| 5592 | |
| 5593 | if (spec->kctl_alloc) |
| 5594 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 5595 | |
| 5596 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; |
| 5597 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 5598 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5599 | spec->input_mux = &spec->private_imux; |
| 5600 | |
| 5601 | spec->adc_nids = alc861_adc_nids; |
| 5602 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
| 5603 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; |
| 5604 | spec->num_mixers++; |
| 5605 | |
| 5606 | return 1; |
| 5607 | } |
| 5608 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 5609 | /* additional initialization for auto-configuration model */ |
| 5610 | static void alc861_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5611 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5612 | alc861_auto_init_multi_out(codec); |
| 5613 | alc861_auto_init_hp_out(codec); |
| 5614 | alc861_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5615 | } |
| 5616 | |
| 5617 | |
| 5618 | /* |
| 5619 | * configuration and preset |
| 5620 | */ |
| 5621 | static struct hda_board_config alc861_cfg_tbl[] = { |
| 5622 | { .modelname = "3stack", .config = ALC861_3ST }, |
| 5623 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, |
| 5624 | { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, |
| 5625 | { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, |
| 5626 | { .modelname = "auto", .config = ALC861_AUTO }, |
| 5627 | {} |
| 5628 | }; |
| 5629 | |
| 5630 | static struct alc_config_preset alc861_presets[] = { |
| 5631 | [ALC861_3ST] = { |
| 5632 | .mixers = { alc861_3ST_mixer }, |
| 5633 | .init_verbs = { alc861_threestack_init_verbs }, |
| 5634 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 5635 | .dac_nids = alc861_dac_nids, |
| 5636 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 5637 | .channel_mode = alc861_threestack_modes, |
| 5638 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 5639 | .adc_nids = alc861_adc_nids, |
| 5640 | .input_mux = &alc861_capture_source, |
| 5641 | }, |
| 5642 | [ALC861_3ST_DIG] = { |
| 5643 | .mixers = { alc861_base_mixer }, |
| 5644 | .init_verbs = { alc861_threestack_init_verbs }, |
| 5645 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 5646 | .dac_nids = alc861_dac_nids, |
| 5647 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 5648 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 5649 | .channel_mode = alc861_threestack_modes, |
| 5650 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 5651 | .adc_nids = alc861_adc_nids, |
| 5652 | .input_mux = &alc861_capture_source, |
| 5653 | }, |
| 5654 | [ALC861_6ST_DIG] = { |
| 5655 | .mixers = { alc861_base_mixer }, |
| 5656 | .init_verbs = { alc861_base_init_verbs }, |
| 5657 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 5658 | .dac_nids = alc861_dac_nids, |
| 5659 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 5660 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), |
| 5661 | .channel_mode = alc861_8ch_modes, |
| 5662 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 5663 | .adc_nids = alc861_adc_nids, |
| 5664 | .input_mux = &alc861_capture_source, |
| 5665 | }, |
| 5666 | }; |
| 5667 | |
| 5668 | |
| 5669 | static int patch_alc861(struct hda_codec *codec) |
| 5670 | { |
| 5671 | struct alc_spec *spec; |
| 5672 | int board_config; |
| 5673 | int err; |
| 5674 | |
| 5675 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 5676 | if (spec == NULL) |
| 5677 | return -ENOMEM; |
| 5678 | |
| 5679 | codec->spec = spec; |
| 5680 | |
| 5681 | board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); |
| 5682 | if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { |
| 5683 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); |
| 5684 | board_config = ALC861_AUTO; |
| 5685 | } |
| 5686 | |
| 5687 | if (board_config == ALC861_AUTO) { |
| 5688 | /* automatic parse from the BIOS config */ |
| 5689 | err = alc861_parse_auto_config(codec); |
| 5690 | if (err < 0) { |
| 5691 | alc_free(codec); |
| 5692 | return err; |
| 5693 | } else if (! err) { |
| 5694 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); |
| 5695 | board_config = ALC861_3ST_DIG; |
| 5696 | } |
| 5697 | } |
| 5698 | |
| 5699 | if (board_config != ALC861_AUTO) |
| 5700 | setup_preset(spec, &alc861_presets[board_config]); |
| 5701 | |
| 5702 | spec->stream_name_analog = "ALC861 Analog"; |
| 5703 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
| 5704 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
| 5705 | |
| 5706 | spec->stream_name_digital = "ALC861 Digital"; |
| 5707 | spec->stream_digital_playback = &alc861_pcm_digital_playback; |
| 5708 | spec->stream_digital_capture = &alc861_pcm_digital_capture; |
| 5709 | |
| 5710 | codec->patch_ops = alc_patch_ops; |
| 5711 | if (board_config == ALC861_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 5712 | spec->init_hook = alc861_auto_init; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5713 | |
| 5714 | return 0; |
| 5715 | } |
| 5716 | |
| 5717 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5718 | * patch entries |
| 5719 | */ |
| 5720 | struct hda_codec_preset snd_hda_preset_realtek[] = { |
| 5721 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5722 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5723 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
| 5724 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5725 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
| 5726 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
| 5727 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5728 | {} /* terminator */ |
| 5729 | }; |