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