Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for ALC 260/880/882 codecs |
| 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <sound/driver.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/pci.h> |
| 31 | #include <sound/core.h> |
| 32 | #include "hda_codec.h" |
| 33 | #include "hda_local.h" |
| 34 | |
| 35 | |
| 36 | /* ALC880 board config type */ |
| 37 | enum { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | ALC880_3ST, |
| 39 | ALC880_3ST_DIG, |
| 40 | ALC880_5ST, |
| 41 | ALC880_5ST_DIG, |
| 42 | ALC880_W810, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 43 | ALC880_Z71V, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 44 | ALC880_6ST, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 45 | ALC880_6ST_DIG, |
| 46 | ALC880_F1734, |
| 47 | ALC880_ASUS, |
| 48 | ALC880_ASUS_DIG, |
| 49 | ALC880_ASUS_W1V, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 50 | ALC880_ASUS_DIG2, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 51 | ALC880_UNIWILL_DIG, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 52 | ALC880_CLEVO, |
| 53 | ALC880_TCL_S700, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 54 | ALC880_LG, |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 55 | ALC880_LG_LW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 56 | #ifdef CONFIG_SND_DEBUG |
| 57 | ALC880_TEST, |
| 58 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 59 | ALC880_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 60 | ALC880_MODEL_LAST /* last tag */ |
| 61 | }; |
| 62 | |
| 63 | /* ALC260 models */ |
| 64 | enum { |
| 65 | ALC260_BASIC, |
| 66 | ALC260_HP, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 67 | ALC260_HP_3013, |
| 68 | ALC260_FUJITSU_S702X, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 69 | ALC260_ACER, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 70 | #ifdef CONFIG_SND_DEBUG |
| 71 | ALC260_TEST, |
| 72 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 73 | ALC260_AUTO, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 74 | ALC260_MODEL_LAST /* last tag */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 77 | /* ALC262 models */ |
| 78 | enum { |
| 79 | ALC262_BASIC, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 80 | ALC262_FUJITSU, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 81 | ALC262_HP_BPC, |
Takashi Iwai | 304dcaa | 2006-07-25 14:51:16 +0200 | [diff] [blame] | 82 | ALC262_BENQ_ED8, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 83 | ALC262_AUTO, |
| 84 | ALC262_MODEL_LAST /* last tag */ |
| 85 | }; |
| 86 | |
| 87 | /* ALC861 models */ |
| 88 | enum { |
| 89 | ALC861_3ST, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 90 | ALC660_3ST, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 91 | ALC861_3ST_DIG, |
| 92 | ALC861_6ST_DIG, |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 93 | ALC861_UNIWILL_M31, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 94 | ALC861_AUTO, |
| 95 | ALC861_MODEL_LAST, |
| 96 | }; |
| 97 | |
| 98 | /* ALC882 models */ |
| 99 | enum { |
| 100 | ALC882_3ST_DIG, |
| 101 | ALC882_6ST_DIG, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 102 | ALC882_ARIMA, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 103 | ALC882_AUTO, |
| 104 | ALC882_MODEL_LAST, |
| 105 | }; |
| 106 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 107 | /* ALC883 models */ |
| 108 | enum { |
| 109 | ALC883_3ST_2ch_DIG, |
| 110 | ALC883_3ST_6ch_DIG, |
| 111 | ALC883_3ST_6ch, |
| 112 | ALC883_6ST_DIG, |
| 113 | ALC888_DEMO_BOARD, |
Vladimir Avdonin | bab282b | 2006-08-22 13:31:58 +0200 | [diff] [blame] | 114 | ALC883_ACER, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 115 | ALC883_AUTO, |
| 116 | ALC883_MODEL_LAST, |
| 117 | }; |
| 118 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 119 | /* for GPIO Poll */ |
| 120 | #define GPIO_MASK 0x03 |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | struct alc_spec { |
| 123 | /* codec parameterization */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 124 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | unsigned int num_mixers; |
| 126 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 127 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 128 | * don't forget NULL |
| 129 | * termination! |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 130 | */ |
| 131 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 133 | char *stream_name_analog; /* analog PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | struct hda_pcm_stream *stream_analog_playback; |
| 135 | struct hda_pcm_stream *stream_analog_capture; |
| 136 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 137 | char *stream_name_digital; /* digital PCM stream */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | struct hda_pcm_stream *stream_digital_playback; |
| 139 | struct hda_pcm_stream *stream_digital_capture; |
| 140 | |
| 141 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 142 | struct hda_multi_out multiout; /* playback set-up |
| 143 | * max_channels, dacs must be set |
| 144 | * dig_out_nid and hp_nid are optional |
| 145 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | /* capture */ |
| 148 | unsigned int num_adc_nids; |
| 149 | hda_nid_t *adc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 150 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 153 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | const struct hda_input_mux *input_mux; |
| 155 | unsigned int cur_mux[3]; |
| 156 | |
| 157 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 158 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 160 | int need_dac_fix; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 163 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 164 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 165 | /* dynamic controls, init_verbs and input_mux */ |
| 166 | struct auto_pin_cfg autocfg; |
| 167 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 168 | struct snd_kcontrol_new *kctl_alloc; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 169 | struct hda_input_mux private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 170 | hda_nid_t private_dac_nids[5]; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 171 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 172 | /* hooks */ |
| 173 | void (*init_hook)(struct hda_codec *codec); |
| 174 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
| 175 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 176 | /* for pin sensing */ |
| 177 | unsigned int sense_updated: 1; |
| 178 | unsigned int jack_present: 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | /* |
| 182 | * configuration template - to be copied to the spec instance |
| 183 | */ |
| 184 | struct alc_config_preset { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 185 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
| 186 | * with spec |
| 187 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 188 | const struct hda_verb *init_verbs[5]; |
| 189 | unsigned int num_dacs; |
| 190 | hda_nid_t *dac_nids; |
| 191 | hda_nid_t dig_out_nid; /* optional */ |
| 192 | hda_nid_t hp_nid; /* optional */ |
| 193 | unsigned int num_adc_nids; |
| 194 | hda_nid_t *adc_nids; |
| 195 | hda_nid_t dig_in_nid; |
| 196 | unsigned int num_channel_mode; |
| 197 | const struct hda_channel_mode *channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 198 | int need_dac_fix; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 199 | unsigned int num_mux_defs; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 200 | const struct hda_input_mux *input_mux; |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 201 | void (*unsol_event)(struct hda_codec *, unsigned int); |
| 202 | void (*init_hook)(struct hda_codec *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
| 206 | /* |
| 207 | * input MUX handling |
| 208 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 209 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 210 | struct snd_ctl_elem_info *uinfo) |
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; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 214 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 215 | if (mux_idx >= spec->num_mux_defs) |
| 216 | mux_idx = 0; |
| 217 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 220 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 221 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
| 223 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 224 | struct alc_spec *spec = codec->spec; |
| 225 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 226 | |
| 227 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 228 | return 0; |
| 229 | } |
| 230 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 231 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 232 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
| 234 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 235 | struct alc_spec *spec = codec->spec; |
| 236 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 237 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 238 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 239 | spec->adc_nids[adc_idx], |
| 240 | &spec->cur_mux[adc_idx]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | /* |
| 245 | * channel mode setting |
| 246 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 247 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 248 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | { |
| 250 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 251 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 252 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 253 | spec->num_channel_mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 256 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 257 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | { |
| 259 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 260 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 261 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 262 | spec->num_channel_mode, |
| 263 | spec->multiout.max_channels); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 266 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 267 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
| 269 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 270 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 271 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 272 | spec->num_channel_mode, |
| 273 | &spec->multiout.max_channels); |
Takashi Iwai | bd2033f | 2006-10-10 19:49:31 +0200 | [diff] [blame] | 274 | if (err >= 0 && spec->need_dac_fix) |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 275 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
| 276 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | /* |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 280 | * Control the mode of pin widget settings via the mixer. "pc" is used |
| 281 | * instead of "%" to avoid consequences of accidently treating the % as |
| 282 | * being part of a format specifier. Maximum allowed length of a value is |
| 283 | * 63 characters plus NULL terminator. |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 284 | * |
| 285 | * Note: some retasking pin complexes seem to ignore requests for input |
| 286 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these |
| 287 | * are requested. Therefore order this list so that this behaviour will not |
| 288 | * cause problems when mixer clients move through the enum sequentially. |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 289 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
| 290 | * March 2006. |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 291 | */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 292 | static char *alc_pin_mode_names[] = { |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 293 | "Mic 50pc bias", "Mic 80pc bias", |
| 294 | "Line in", "Line out", "Headphone out", |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 295 | }; |
| 296 | static unsigned char alc_pin_mode_values[] = { |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 297 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 298 | }; |
| 299 | /* The control can present all 5 options, or it can limit the options based |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 300 | * in the pin being assumed to be exclusively an input or an output pin. In |
| 301 | * addition, "input" pins may or may not process the mic bias option |
| 302 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to |
| 303 | * accept requests for bias as of chip versions up to March 2006) and/or |
| 304 | * wiring in the computer. |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 305 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 306 | #define ALC_PIN_DIR_IN 0x00 |
| 307 | #define ALC_PIN_DIR_OUT 0x01 |
| 308 | #define ALC_PIN_DIR_INOUT 0x02 |
| 309 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 |
| 310 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 311 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 312 | /* Info about the pin modes supported by the different pin direction modes. |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 313 | * For each direction the minimum and maximum values are given. |
| 314 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 315 | static signed char alc_pin_mode_dir_info[5][2] = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 316 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
| 317 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ |
| 318 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 319 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
| 320 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 321 | }; |
| 322 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) |
| 323 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) |
| 324 | #define alc_pin_mode_n_items(_dir) \ |
| 325 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) |
| 326 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 327 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
| 328 | struct snd_ctl_elem_info *uinfo) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 329 | { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 330 | unsigned int item_num = uinfo->value.enumerated.item; |
| 331 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| 332 | |
| 333 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 334 | uinfo->count = 1; |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 335 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
| 336 | |
| 337 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) |
| 338 | item_num = alc_pin_mode_min(dir); |
| 339 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 340 | return 0; |
| 341 | } |
| 342 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 343 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
| 344 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 345 | { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 346 | unsigned int i; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 347 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 348 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 349 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 350 | long *valp = ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 351 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
| 352 | AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 353 | 0x00); |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 354 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 355 | /* Find enumerated value for current pinctl setting */ |
| 356 | i = alc_pin_mode_min(dir); |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 357 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 358 | i++; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 359 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 363 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
| 364 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 365 | { |
| 366 | signed int change; |
| 367 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 368 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 369 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
| 370 | long val = *ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 371 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
| 372 | AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 373 | 0x00); |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 374 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 375 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 376 | val = alc_pin_mode_min(dir); |
| 377 | |
| 378 | change = pinctl != alc_pin_mode_values[val]; |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 379 | if (change) { |
| 380 | /* Set pin mode to that requested */ |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 381 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 382 | alc_pin_mode_values[val]); |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 383 | |
| 384 | /* Also enable the retasking pin's input/output as required |
| 385 | * for the requested pin mode. Enum values of 2 or less are |
| 386 | * input modes. |
| 387 | * |
| 388 | * Dynamically switching the input/output buffers probably |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 389 | * reduces noise slightly (particularly on input) so we'll |
| 390 | * do it. However, having both input and output buffers |
| 391 | * enabled simultaneously doesn't seem to be problematic if |
| 392 | * this turns out to be necessary in the future. |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 393 | */ |
| 394 | if (val <= 2) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 395 | snd_hda_codec_write(codec, nid, 0, |
| 396 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 397 | AMP_OUT_MUTE); |
| 398 | snd_hda_codec_write(codec, nid, 0, |
| 399 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 400 | AMP_IN_UNMUTE(0)); |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 401 | } else { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 402 | snd_hda_codec_write(codec, nid, 0, |
| 403 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 404 | AMP_IN_MUTE(0)); |
| 405 | snd_hda_codec_write(codec, nid, 0, |
| 406 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 407 | AMP_OUT_UNMUTE); |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 408 | } |
| 409 | } |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 410 | return change; |
| 411 | } |
| 412 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 413 | #define ALC_PIN_MODE(xname, nid, dir) \ |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 414 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 415 | .info = alc_pin_mode_info, \ |
| 416 | .get = alc_pin_mode_get, \ |
| 417 | .put = alc_pin_mode_put, \ |
| 418 | .private_value = nid | (dir<<16) } |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 419 | |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 420 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
| 421 | * together using a mask with more than one bit set. This control is |
| 422 | * currently used only by the ALC260 test model. At this stage they are not |
| 423 | * needed for any "production" models. |
| 424 | */ |
| 425 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 426 | static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, |
| 427 | struct snd_ctl_elem_info *uinfo) |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 428 | { |
| 429 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 430 | uinfo->count = 1; |
| 431 | uinfo->value.integer.min = 0; |
| 432 | uinfo->value.integer.max = 1; |
| 433 | return 0; |
| 434 | } |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 435 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
| 436 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 437 | { |
| 438 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 439 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 440 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 441 | long *valp = ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 442 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
| 443 | AC_VERB_GET_GPIO_DATA, 0x00); |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 444 | |
| 445 | *valp = (val & mask) != 0; |
| 446 | return 0; |
| 447 | } |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 448 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
| 449 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 450 | { |
| 451 | signed int change; |
| 452 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 453 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 454 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 455 | long val = *ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 456 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
| 457 | AC_VERB_GET_GPIO_DATA, |
| 458 | 0x00); |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 459 | |
| 460 | /* Set/unset the masked GPIO bit(s) as needed */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 461 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
| 462 | if (val == 0) |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 463 | gpio_data &= ~mask; |
| 464 | else |
| 465 | gpio_data |= mask; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 466 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data); |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 467 | |
| 468 | return change; |
| 469 | } |
| 470 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ |
| 471 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 472 | .info = alc_gpio_data_info, \ |
| 473 | .get = alc_gpio_data_get, \ |
| 474 | .put = alc_gpio_data_put, \ |
| 475 | .private_value = nid | (mask<<16) } |
| 476 | #endif /* CONFIG_SND_DEBUG */ |
| 477 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 478 | /* A switch control to allow the enabling of the digital IO pins on the |
| 479 | * ALC260. This is incredibly simplistic; the intention of this control is |
| 480 | * to provide something in the test model allowing digital outputs to be |
| 481 | * identified if present. If models are found which can utilise these |
| 482 | * outputs a more complete mixer control can be devised for those models if |
| 483 | * necessary. |
| 484 | */ |
| 485 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 486 | static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, |
| 487 | struct snd_ctl_elem_info *uinfo) |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 488 | { |
| 489 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 490 | uinfo->count = 1; |
| 491 | uinfo->value.integer.min = 0; |
| 492 | uinfo->value.integer.max = 1; |
| 493 | return 0; |
| 494 | } |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 495 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
| 496 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 497 | { |
| 498 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 499 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 500 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 501 | long *valp = ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 502 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
| 503 | AC_VERB_GET_DIGI_CONVERT, 0x00); |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 504 | |
| 505 | *valp = (val & mask) != 0; |
| 506 | return 0; |
| 507 | } |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 508 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
| 509 | struct snd_ctl_elem_value *ucontrol) |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 510 | { |
| 511 | signed int change; |
| 512 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 513 | hda_nid_t nid = kcontrol->private_value & 0xffff; |
| 514 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; |
| 515 | long val = *ucontrol->value.integer.value; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 516 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
| 517 | AC_VERB_GET_DIGI_CONVERT, |
| 518 | 0x00); |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 519 | |
| 520 | /* Set/unset the masked control bit(s) as needed */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 521 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 522 | if (val==0) |
| 523 | ctrl_data &= ~mask; |
| 524 | else |
| 525 | ctrl_data |= mask; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 526 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
| 527 | ctrl_data); |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 528 | |
| 529 | return change; |
| 530 | } |
| 531 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ |
| 532 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 533 | .info = alc_spdif_ctrl_info, \ |
| 534 | .get = alc_spdif_ctrl_get, \ |
| 535 | .put = alc_spdif_ctrl_put, \ |
| 536 | .private_value = nid | (mask<<16) } |
| 537 | #endif /* CONFIG_SND_DEBUG */ |
| 538 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 539 | /* |
| 540 | * set up from the preset table |
| 541 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 542 | static void setup_preset(struct alc_spec *spec, |
| 543 | const struct alc_config_preset *preset) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 544 | { |
| 545 | int i; |
| 546 | |
| 547 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
| 548 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 549 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
| 550 | i++) |
| 551 | spec->init_verbs[spec->num_init_verbs++] = |
| 552 | preset->init_verbs[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 553 | |
| 554 | spec->channel_mode = preset->channel_mode; |
| 555 | spec->num_channel_mode = preset->num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 556 | spec->need_dac_fix = preset->need_dac_fix; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 557 | |
| 558 | spec->multiout.max_channels = spec->channel_mode[0].channels; |
| 559 | |
| 560 | spec->multiout.num_dacs = preset->num_dacs; |
| 561 | spec->multiout.dac_nids = preset->dac_nids; |
| 562 | spec->multiout.dig_out_nid = preset->dig_out_nid; |
| 563 | spec->multiout.hp_nid = preset->hp_nid; |
| 564 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 565 | spec->num_mux_defs = preset->num_mux_defs; |
| 566 | if (! spec->num_mux_defs) |
| 567 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 568 | spec->input_mux = preset->input_mux; |
| 569 | |
| 570 | spec->num_adc_nids = preset->num_adc_nids; |
| 571 | spec->adc_nids = preset->adc_nids; |
| 572 | spec->dig_in_nid = preset->dig_in_nid; |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 573 | |
| 574 | spec->unsol_event = preset->unsol_event; |
| 575 | spec->init_hook = preset->init_hook; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 576 | } |
| 577 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 578 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 579 | * ALC880 3-stack model |
| 580 | * |
| 581 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 582 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
| 583 | * F-Mic = 0x1b, HP = 0x19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | */ |
| 585 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 586 | static hda_nid_t alc880_dac_nids[4] = { |
| 587 | /* front, rear, clfe, rear_surr */ |
| 588 | 0x02, 0x05, 0x04, 0x03 |
| 589 | }; |
| 590 | |
| 591 | static hda_nid_t alc880_adc_nids[3] = { |
| 592 | /* ADC0-2 */ |
| 593 | 0x07, 0x08, 0x09, |
| 594 | }; |
| 595 | |
| 596 | /* The datasheet says the node 0x07 is connected from inputs, |
| 597 | * but it shows zero connection in the real implementation on some devices. |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 598 | * Note: this is a 915GAV bug, fixed on 915GLV |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 600 | static hda_nid_t alc880_adc_nids_alt[2] = { |
| 601 | /* ADC1-2 */ |
| 602 | 0x08, 0x09, |
| 603 | }; |
| 604 | |
| 605 | #define ALC880_DIGOUT_NID 0x06 |
| 606 | #define ALC880_DIGIN_NID 0x0a |
| 607 | |
| 608 | static struct hda_input_mux alc880_capture_source = { |
| 609 | .num_items = 4, |
| 610 | .items = { |
| 611 | { "Mic", 0x0 }, |
| 612 | { "Front Mic", 0x3 }, |
| 613 | { "Line", 0x2 }, |
| 614 | { "CD", 0x4 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 616 | }; |
| 617 | |
| 618 | /* channel source setting (2/6 channel selection for 3-stack) */ |
| 619 | /* 2ch mode */ |
| 620 | static struct hda_verb alc880_threestack_ch2_init[] = { |
| 621 | /* set line-in to input, mute it */ |
| 622 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 623 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 624 | /* set mic-in to input vref 80%, mute it */ |
| 625 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 626 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | { } /* end */ |
| 628 | }; |
| 629 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 630 | /* 6ch mode */ |
| 631 | static struct hda_verb alc880_threestack_ch6_init[] = { |
| 632 | /* set line-in to output, unmute it */ |
| 633 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 634 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 635 | /* set mic-in to output, unmute it */ |
| 636 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 637 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 638 | { } /* end */ |
| 639 | }; |
| 640 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 641 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 642 | { 2, alc880_threestack_ch2_init }, |
| 643 | { 6, alc880_threestack_ch6_init }, |
| 644 | }; |
| 645 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 646 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 647 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 648 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 649 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 650 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 651 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 652 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 653 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 654 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 656 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 657 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 658 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 659 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 660 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 661 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 662 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 663 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 664 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 666 | { |
| 667 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 668 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 669 | .info = alc_ch_mode_info, |
| 670 | .get = alc_ch_mode_get, |
| 671 | .put = alc_ch_mode_put, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 672 | }, |
| 673 | { } /* end */ |
| 674 | }; |
| 675 | |
| 676 | /* capture mixer elements */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 677 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 678 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 679 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 680 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 681 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 682 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 683 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 684 | { |
| 685 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 686 | /* The multiple "Capture Source" controls confuse alsamixer |
| 687 | * So call somewhat different.. |
| 688 | * FIXME: the controls appear in the "playback" view! |
| 689 | */ |
| 690 | /* .name = "Capture Source", */ |
| 691 | .name = "Input Source", |
| 692 | .count = 3, |
| 693 | .info = alc_mux_enum_info, |
| 694 | .get = alc_mux_enum_get, |
| 695 | .put = alc_mux_enum_put, |
| 696 | }, |
| 697 | { } /* end */ |
| 698 | }; |
| 699 | |
| 700 | /* capture mixer elements (in case NID 0x07 not available) */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 701 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 702 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 703 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 704 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 705 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | { |
| 707 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 708 | /* The multiple "Capture Source" controls confuse alsamixer |
| 709 | * So call somewhat different.. |
| 710 | * FIXME: the controls appear in the "playback" view! |
| 711 | */ |
| 712 | /* .name = "Capture Source", */ |
| 713 | .name = "Input Source", |
| 714 | .count = 2, |
| 715 | .info = alc_mux_enum_info, |
| 716 | .get = alc_mux_enum_get, |
| 717 | .put = alc_mux_enum_put, |
| 718 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | { } /* end */ |
| 720 | }; |
| 721 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 722 | |
| 723 | |
| 724 | /* |
| 725 | * ALC880 5-stack model |
| 726 | * |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 727 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
| 728 | * Side = 0x02 (0xd) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 729 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
| 730 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 |
| 731 | */ |
| 732 | |
| 733 | /* additional mixers to alc880_three_stack_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 734 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 735 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 736 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | { } /* end */ |
| 738 | }; |
| 739 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 740 | /* channel source setting (6/8 channel selection for 5-stack) */ |
| 741 | /* 6ch mode */ |
| 742 | static struct hda_verb alc880_fivestack_ch6_init[] = { |
| 743 | /* set line-in to input, mute it */ |
| 744 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 745 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 746 | { } /* end */ |
| 747 | }; |
| 748 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 749 | /* 8ch mode */ |
| 750 | static struct hda_verb alc880_fivestack_ch8_init[] = { |
| 751 | /* set line-in to output, unmute it */ |
| 752 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 753 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 754 | { } /* end */ |
| 755 | }; |
| 756 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 757 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 758 | { 6, alc880_fivestack_ch6_init }, |
| 759 | { 8, alc880_fivestack_ch8_init }, |
| 760 | }; |
| 761 | |
| 762 | |
| 763 | /* |
| 764 | * ALC880 6-stack model |
| 765 | * |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 766 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
| 767 | * Side = 0x05 (0x0f) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 768 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
| 769 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b |
| 770 | */ |
| 771 | |
| 772 | static hda_nid_t alc880_6st_dac_nids[4] = { |
| 773 | /* front, rear, clfe, rear_surr */ |
| 774 | 0x02, 0x03, 0x04, 0x05 |
| 775 | }; |
| 776 | |
| 777 | static struct hda_input_mux alc880_6stack_capture_source = { |
| 778 | .num_items = 4, |
| 779 | .items = { |
| 780 | { "Mic", 0x0 }, |
| 781 | { "Front Mic", 0x1 }, |
| 782 | { "Line", 0x2 }, |
| 783 | { "CD", 0x4 }, |
| 784 | }, |
| 785 | }; |
| 786 | |
| 787 | /* fixed 8-channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 788 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 789 | { 8, NULL }, |
| 790 | }; |
| 791 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 792 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 793 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 794 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 795 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 796 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 797 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 798 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 799 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 800 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 801 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 802 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 803 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 804 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 805 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 806 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 807 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 808 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 809 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 810 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 811 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 812 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 813 | { |
| 814 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 815 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 816 | .info = alc_ch_mode_info, |
| 817 | .get = alc_ch_mode_get, |
| 818 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 819 | }, |
| 820 | { } /* end */ |
| 821 | }; |
| 822 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 823 | |
| 824 | /* |
| 825 | * ALC880 W810 model |
| 826 | * |
| 827 | * W810 has rear IO for: |
| 828 | * Front (DAC 02) |
| 829 | * Surround (DAC 03) |
| 830 | * Center/LFE (DAC 04) |
| 831 | * Digital out (06) |
| 832 | * |
| 833 | * The system also has a pair of internal speakers, and a headphone jack. |
| 834 | * These are both connected to Line2 on the codec, hence to DAC 02. |
| 835 | * |
| 836 | * There is a variable resistor to control the speaker or headphone |
| 837 | * volume. This is a hardware-only device without a software API. |
| 838 | * |
| 839 | * Plugging headphones in will disable the internal speakers. This is |
| 840 | * implemented in hardware, not via the driver using jack sense. In |
| 841 | * a similar fashion, plugging into the rear socket marked "front" will |
| 842 | * disable both the speakers and headphones. |
| 843 | * |
| 844 | * For input, there's a microphone jack, and an "audio in" jack. |
| 845 | * These may not do anything useful with this driver yet, because I |
| 846 | * haven't setup any initialization verbs for these yet... |
| 847 | */ |
| 848 | |
| 849 | static hda_nid_t alc880_w810_dac_nids[3] = { |
| 850 | /* front, rear/surround, clfe */ |
| 851 | 0x02, 0x03, 0x04 |
| 852 | }; |
| 853 | |
| 854 | /* fixed 6 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 855 | static struct hda_channel_mode alc880_w810_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 856 | { 6, NULL } |
| 857 | }; |
| 858 | |
| 859 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 860 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 861 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 862 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 863 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 864 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 865 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 866 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 867 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 868 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 869 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 870 | { } /* end */ |
| 871 | }; |
| 872 | |
| 873 | |
| 874 | /* |
| 875 | * Z710V model |
| 876 | * |
| 877 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 878 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
| 879 | * Line = 0x1a |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 880 | */ |
| 881 | |
| 882 | static hda_nid_t alc880_z71v_dac_nids[1] = { |
| 883 | 0x02 |
| 884 | }; |
| 885 | #define ALC880_Z71V_HP_DAC 0x03 |
| 886 | |
| 887 | /* fixed 2 channels */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 888 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 889 | { 2, NULL } |
| 890 | }; |
| 891 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 892 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 893 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 894 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 895 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 896 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 897 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 898 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 899 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 900 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 901 | { } /* end */ |
| 902 | }; |
| 903 | |
| 904 | |
| 905 | /* FIXME! */ |
| 906 | /* |
| 907 | * ALC880 F1734 model |
| 908 | * |
| 909 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) |
| 910 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 |
| 911 | */ |
| 912 | |
| 913 | static hda_nid_t alc880_f1734_dac_nids[1] = { |
| 914 | 0x03 |
| 915 | }; |
| 916 | #define ALC880_F1734_HP_DAC 0x02 |
| 917 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 918 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 919 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 920 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 921 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 922 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 923 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 924 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 925 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 926 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 927 | { } /* end */ |
| 928 | }; |
| 929 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 930 | |
| 931 | /* FIXME! */ |
| 932 | /* |
| 933 | * ALC880 ASUS model |
| 934 | * |
| 935 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 936 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 937 | * Mic = 0x18, Line = 0x1a |
| 938 | */ |
| 939 | |
| 940 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ |
| 941 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ |
| 942 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 943 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 944 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 945 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 946 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 947 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 948 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 949 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 950 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 951 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 952 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 953 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 954 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 955 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 956 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 957 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 958 | { |
| 959 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 960 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 961 | .info = alc_ch_mode_info, |
| 962 | .get = alc_ch_mode_get, |
| 963 | .put = alc_ch_mode_put, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 964 | }, |
| 965 | { } /* end */ |
| 966 | }; |
| 967 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 968 | /* FIXME! */ |
| 969 | /* |
| 970 | * ALC880 ASUS W1V model |
| 971 | * |
| 972 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) |
| 973 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, |
| 974 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b |
| 975 | */ |
| 976 | |
| 977 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 978 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 979 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
| 980 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 981 | { } /* end */ |
| 982 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 983 | |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 984 | /* additional mixers to alc880_asus_mixer */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 985 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 986 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 987 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 988 | { } /* end */ |
| 989 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 990 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 991 | /* TCL S700 */ |
| 992 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { |
| 993 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 994 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 995 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 996 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), |
| 997 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), |
| 998 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), |
| 999 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), |
| 1000 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 1001 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 1002 | { |
| 1003 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1004 | /* The multiple "Capture Source" controls confuse alsamixer |
| 1005 | * So call somewhat different.. |
| 1006 | * FIXME: the controls appear in the "playback" view! |
| 1007 | */ |
| 1008 | /* .name = "Capture Source", */ |
| 1009 | .name = "Input Source", |
| 1010 | .count = 1, |
| 1011 | .info = alc_mux_enum_info, |
| 1012 | .get = alc_mux_enum_get, |
| 1013 | .put = alc_mux_enum_put, |
| 1014 | }, |
| 1015 | { } /* end */ |
| 1016 | }; |
| 1017 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1019 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | */ |
| 1021 | static int alc_build_controls(struct hda_codec *codec) |
| 1022 | { |
| 1023 | struct alc_spec *spec = codec->spec; |
| 1024 | int err; |
| 1025 | int i; |
| 1026 | |
| 1027 | for (i = 0; i < spec->num_mixers; i++) { |
| 1028 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1029 | if (err < 0) |
| 1030 | return err; |
| 1031 | } |
| 1032 | |
| 1033 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1034 | err = snd_hda_create_spdif_out_ctls(codec, |
| 1035 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | if (err < 0) |
| 1037 | return err; |
| 1038 | } |
| 1039 | if (spec->dig_in_nid) { |
| 1040 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1041 | if (err < 0) |
| 1042 | return err; |
| 1043 | } |
| 1044 | return 0; |
| 1045 | } |
| 1046 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | /* |
| 1049 | * initialize the codec volumes, etc |
| 1050 | */ |
| 1051 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1052 | /* |
| 1053 | * generic initialization of ADC, input mixers and output mixers |
| 1054 | */ |
| 1055 | static struct hda_verb alc880_volume_init_verbs[] = { |
| 1056 | /* |
| 1057 | * Unmute ADC0-2 and set the default input to mic-in |
| 1058 | */ |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1059 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1060 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1061 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1062 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 1063 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1064 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1066 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 1067 | * mixer widget |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1068 | * Note: PASD motherboards uses the Line In 2 as the input for front |
| 1069 | * panel mic (mic 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1071 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1072 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1073 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1074 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 1075 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 1076 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1078 | /* |
| 1079 | * Set up output mixers (0x0c - 0x0f) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1081 | /* set vol=0 to output mixers */ |
| 1082 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1083 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1084 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1085 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1086 | /* set up input amps for analog loopback */ |
| 1087 | /* Amp Indices: DAC = 0, mixer = 1 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1088 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1089 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1090 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1091 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1092 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1093 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1094 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1095 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | |
| 1097 | { } |
| 1098 | }; |
| 1099 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1100 | /* |
| 1101 | * 3-stack pin configuration: |
| 1102 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b |
| 1103 | */ |
| 1104 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { |
| 1105 | /* |
| 1106 | * preset connection lists of input pins |
| 1107 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 1108 | */ |
| 1109 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
| 1110 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1111 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ |
| 1112 | |
| 1113 | /* |
| 1114 | * Set pin mode and muting |
| 1115 | */ |
| 1116 | /* set front pin widgets 0x14 for output */ |
| 1117 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1118 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1119 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 1120 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1121 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1122 | /* Mic2 (as headphone out) for HP output */ |
| 1123 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1124 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1125 | /* Line In pin widget for input */ |
| 1126 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1127 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1128 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 1129 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1130 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1131 | /* CD pin widget for input */ |
| 1132 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1133 | |
| 1134 | { } |
| 1135 | }; |
| 1136 | |
| 1137 | /* |
| 1138 | * 5-stack pin configuration: |
| 1139 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, |
| 1140 | * line-in/side = 0x1a, f-mic = 0x1b |
| 1141 | */ |
| 1142 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { |
| 1143 | /* |
| 1144 | * preset connection lists of input pins |
| 1145 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
| 1146 | */ |
| 1147 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1148 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ |
| 1149 | |
| 1150 | /* |
| 1151 | * Set pin mode and muting |
| 1152 | */ |
| 1153 | /* set pin widgets 0x14-0x17 for output */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1154 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1155 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1156 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1157 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1158 | /* unmute pins for output (no gain on this amp) */ |
| 1159 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1160 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1161 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1162 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1165 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1166 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1167 | /* Mic2 (as headphone out) for HP output */ |
| 1168 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1169 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1170 | /* Line In pin widget for input */ |
| 1171 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1172 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1173 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
| 1174 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1175 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1176 | /* CD pin widget for input */ |
| 1177 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | |
| 1179 | { } |
| 1180 | }; |
| 1181 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1182 | /* |
| 1183 | * W810 pin configuration: |
| 1184 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b |
| 1185 | */ |
| 1186 | static struct hda_verb alc880_pin_w810_init_verbs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | /* hphone/speaker input selector: front DAC */ |
| 1188 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1189 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1190 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1191 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1192 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1193 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1194 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1195 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1196 | |
| 1197 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1198 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | { } |
| 1201 | }; |
| 1202 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1203 | /* |
| 1204 | * Z71V pin configuration: |
| 1205 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) |
| 1206 | */ |
| 1207 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1208 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1209 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 1210 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1211 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1212 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1213 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1214 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1215 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1216 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 1217 | |
| 1218 | { } |
| 1219 | }; |
| 1220 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1221 | /* |
| 1222 | * 6-stack pin configuration: |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1223 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
| 1224 | * f-mic = 0x19, line = 0x1a, HP = 0x1b |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1225 | */ |
| 1226 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { |
| 1227 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
| 1228 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1229 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1230 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1231 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1232 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1233 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1234 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1235 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1236 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1237 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1238 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1239 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1240 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1241 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1242 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1243 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1244 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1245 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1246 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1247 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1248 | { } |
| 1249 | }; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1250 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1251 | /* FIXME! */ |
| 1252 | /* |
| 1253 | * F1734 pin configuration: |
| 1254 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 |
| 1255 | */ |
| 1256 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { |
| 1257 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 1258 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1259 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1260 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1261 | |
| 1262 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1263 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1264 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1265 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1266 | |
| 1267 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1268 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1269 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1270 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1271 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1272 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1273 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1274 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1275 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1276 | |
| 1277 | { } |
| 1278 | }; |
| 1279 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1280 | /* FIXME! */ |
| 1281 | /* |
| 1282 | * ASUS pin configuration: |
| 1283 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a |
| 1284 | */ |
| 1285 | static struct hda_verb alc880_pin_asus_init_verbs[] = { |
| 1286 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 1287 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1288 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1289 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1290 | |
| 1291 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1292 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1293 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1294 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1295 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1296 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1297 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1298 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1299 | |
| 1300 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1301 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1302 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1303 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1304 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1305 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1306 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1307 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1308 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1309 | |
| 1310 | { } |
| 1311 | }; |
| 1312 | |
| 1313 | /* Enable GPIO mask and set output */ |
| 1314 | static struct hda_verb alc880_gpio1_init_verbs[] = { |
| 1315 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 1316 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 1317 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1318 | |
| 1319 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1320 | }; |
| 1321 | |
| 1322 | /* Enable GPIO mask and set output */ |
| 1323 | static struct hda_verb alc880_gpio2_init_verbs[] = { |
| 1324 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 1325 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 1326 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1327 | |
| 1328 | { } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1329 | }; |
| 1330 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1331 | /* Clevo m520g init */ |
| 1332 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { |
| 1333 | /* headphone output */ |
| 1334 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1335 | /* line-out */ |
| 1336 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1337 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1338 | /* Line-in */ |
| 1339 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1340 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1341 | /* CD */ |
| 1342 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1343 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1344 | /* Mic1 (rear panel) */ |
| 1345 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1346 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1347 | /* Mic2 (front panel) */ |
| 1348 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1349 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1350 | /* headphone */ |
| 1351 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1352 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1353 | /* change to EAPD mode */ |
| 1354 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1355 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| 1356 | |
| 1357 | { } |
| 1358 | }; |
| 1359 | |
| 1360 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 1361 | /* change to EAPD mode */ |
| 1362 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1363 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| 1364 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1365 | /* Headphone output */ |
| 1366 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1367 | /* Front output*/ |
| 1368 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1369 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1370 | |
| 1371 | /* Line In pin widget for input */ |
| 1372 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1373 | /* CD pin widget for input */ |
| 1374 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1375 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 1376 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1377 | |
| 1378 | /* change to EAPD mode */ |
| 1379 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 1380 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, |
| 1381 | |
| 1382 | { } |
| 1383 | }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1384 | |
| 1385 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1386 | * LG m1 express dual |
| 1387 | * |
| 1388 | * Pin assignment: |
| 1389 | * Rear Line-In/Out (blue): 0x14 |
| 1390 | * Build-in Mic-In: 0x15 |
| 1391 | * Speaker-out: 0x17 |
| 1392 | * HP-Out (green): 0x1b |
| 1393 | * Mic-In/Out (red): 0x19 |
| 1394 | * SPDIF-Out: 0x1e |
| 1395 | */ |
| 1396 | |
| 1397 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ |
| 1398 | static hda_nid_t alc880_lg_dac_nids[3] = { |
| 1399 | 0x05, 0x02, 0x03 |
| 1400 | }; |
| 1401 | |
| 1402 | /* seems analog CD is not working */ |
| 1403 | static struct hda_input_mux alc880_lg_capture_source = { |
| 1404 | .num_items = 3, |
| 1405 | .items = { |
| 1406 | { "Mic", 0x1 }, |
| 1407 | { "Line", 0x5 }, |
| 1408 | { "Internal Mic", 0x6 }, |
| 1409 | }, |
| 1410 | }; |
| 1411 | |
| 1412 | /* 2,4,6 channel modes */ |
| 1413 | static struct hda_verb alc880_lg_ch2_init[] = { |
| 1414 | /* set line-in and mic-in to input */ |
| 1415 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1416 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1417 | { } |
| 1418 | }; |
| 1419 | |
| 1420 | static struct hda_verb alc880_lg_ch4_init[] = { |
| 1421 | /* set line-in to out and mic-in to input */ |
| 1422 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1423 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1424 | { } |
| 1425 | }; |
| 1426 | |
| 1427 | static struct hda_verb alc880_lg_ch6_init[] = { |
| 1428 | /* set line-in and mic-in to output */ |
| 1429 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1430 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
| 1431 | { } |
| 1432 | }; |
| 1433 | |
| 1434 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { |
| 1435 | { 2, alc880_lg_ch2_init }, |
| 1436 | { 4, alc880_lg_ch4_init }, |
| 1437 | { 6, alc880_lg_ch6_init }, |
| 1438 | }; |
| 1439 | |
| 1440 | static struct snd_kcontrol_new alc880_lg_mixer[] = { |
| 1441 | /* FIXME: it's not really "master" but front channels */ |
| 1442 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| 1443 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), |
| 1444 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1445 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1446 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1447 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), |
| 1448 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), |
| 1449 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), |
| 1450 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 1451 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 1452 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), |
| 1453 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), |
| 1454 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), |
| 1455 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), |
| 1456 | { |
| 1457 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1458 | .name = "Channel Mode", |
| 1459 | .info = alc_ch_mode_info, |
| 1460 | .get = alc_ch_mode_get, |
| 1461 | .put = alc_ch_mode_put, |
| 1462 | }, |
| 1463 | { } /* end */ |
| 1464 | }; |
| 1465 | |
| 1466 | static struct hda_verb alc880_lg_init_verbs[] = { |
| 1467 | /* set capture source to mic-in */ |
| 1468 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1469 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1470 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1471 | /* mute all amp mixer inputs */ |
| 1472 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, |
| 1473 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, |
| 1474 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, |
| 1475 | /* line-in to input */ |
| 1476 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1477 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1478 | /* built-in mic */ |
| 1479 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1480 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1481 | /* speaker-out */ |
| 1482 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1483 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1484 | /* mic-in to input */ |
| 1485 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1486 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1487 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1488 | /* HP-out */ |
| 1489 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1490 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1491 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1492 | /* jack sense */ |
| 1493 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, |
| 1494 | { } |
| 1495 | }; |
| 1496 | |
| 1497 | /* toggle speaker-output according to the hp-jack state */ |
| 1498 | static void alc880_lg_automute(struct hda_codec *codec) |
| 1499 | { |
| 1500 | unsigned int present; |
| 1501 | |
| 1502 | present = snd_hda_codec_read(codec, 0x1b, 0, |
| 1503 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1504 | snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, |
| 1505 | 0x80, present ? 0x80 : 0); |
| 1506 | snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, |
| 1507 | 0x80, present ? 0x80 : 0); |
| 1508 | } |
| 1509 | |
| 1510 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1511 | { |
| 1512 | /* Looks like the unsol event is incompatible with the standard |
| 1513 | * definition. 4bit tag is placed at 28 bit! |
| 1514 | */ |
| 1515 | if ((res >> 28) == 0x01) |
| 1516 | alc880_lg_automute(codec); |
| 1517 | } |
| 1518 | |
| 1519 | /* |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 1520 | * LG LW20 |
| 1521 | * |
| 1522 | * Pin assignment: |
| 1523 | * Speaker-out: 0x14 |
| 1524 | * Mic-In: 0x18 |
| 1525 | * Built-in Mic-In: 0x19 (?) |
| 1526 | * HP-Out: 0x1b |
| 1527 | * SPDIF-Out: 0x1e |
| 1528 | */ |
| 1529 | |
| 1530 | /* seems analog CD is not working */ |
| 1531 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
| 1532 | .num_items = 2, |
| 1533 | .items = { |
| 1534 | { "Mic", 0x0 }, |
| 1535 | { "Internal Mic", 0x1 }, |
| 1536 | }, |
| 1537 | }; |
| 1538 | |
| 1539 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
| 1540 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1541 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), |
| 1542 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 1543 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 1544 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 1545 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 1546 | { } /* end */ |
| 1547 | }; |
| 1548 | |
| 1549 | static struct hda_verb alc880_lg_lw_init_verbs[] = { |
| 1550 | /* set capture source to mic-in */ |
| 1551 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1552 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1553 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1554 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, |
| 1555 | /* speaker-out */ |
| 1556 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1557 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1558 | /* HP-out */ |
| 1559 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1560 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1561 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1562 | /* mic-in to input */ |
| 1563 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1564 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1565 | /* built-in mic */ |
| 1566 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1567 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1568 | /* jack sense */ |
| 1569 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, |
| 1570 | { } |
| 1571 | }; |
| 1572 | |
| 1573 | /* toggle speaker-output according to the hp-jack state */ |
| 1574 | static void alc880_lg_lw_automute(struct hda_codec *codec) |
| 1575 | { |
| 1576 | unsigned int present; |
| 1577 | |
| 1578 | present = snd_hda_codec_read(codec, 0x1b, 0, |
| 1579 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1580 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
| 1581 | 0x80, present ? 0x80 : 0); |
| 1582 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
| 1583 | 0x80, present ? 0x80 : 0); |
| 1584 | } |
| 1585 | |
| 1586 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1587 | { |
| 1588 | /* Looks like the unsol event is incompatible with the standard |
| 1589 | * definition. 4bit tag is placed at 28 bit! |
| 1590 | */ |
| 1591 | if ((res >> 28) == 0x01) |
| 1592 | alc880_lg_lw_automute(codec); |
| 1593 | } |
| 1594 | |
| 1595 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1596 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1597 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | static int alc_init(struct hda_codec *codec) |
| 1600 | { |
| 1601 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1602 | unsigned int i; |
| 1603 | |
| 1604 | for (i = 0; i < spec->num_init_verbs; i++) |
| 1605 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1606 | |
| 1607 | if (spec->init_hook) |
| 1608 | spec->init_hook(codec); |
| 1609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | return 0; |
| 1611 | } |
| 1612 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1613 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1614 | { |
| 1615 | struct alc_spec *spec = codec->spec; |
| 1616 | |
| 1617 | if (spec->unsol_event) |
| 1618 | spec->unsol_event(codec, res); |
| 1619 | } |
| 1620 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | #ifdef CONFIG_PM |
| 1622 | /* |
| 1623 | * resume |
| 1624 | */ |
| 1625 | static int alc_resume(struct hda_codec *codec) |
| 1626 | { |
| 1627 | struct alc_spec *spec = codec->spec; |
| 1628 | int i; |
| 1629 | |
| 1630 | alc_init(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1631 | for (i = 0; i < spec->num_mixers; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | if (spec->multiout.dig_out_nid) |
| 1634 | snd_hda_resume_spdif_out(codec); |
| 1635 | if (spec->dig_in_nid) |
| 1636 | snd_hda_resume_spdif_in(codec); |
| 1637 | |
| 1638 | return 0; |
| 1639 | } |
| 1640 | #endif |
| 1641 | |
| 1642 | /* |
| 1643 | * Analog playback callbacks |
| 1644 | */ |
| 1645 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1646 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1647 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | { |
| 1649 | struct alc_spec *spec = codec->spec; |
| 1650 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 1651 | } |
| 1652 | |
| 1653 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1654 | struct hda_codec *codec, |
| 1655 | unsigned int stream_tag, |
| 1656 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1657 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | { |
| 1659 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1660 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1661 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1665 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1666 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | { |
| 1668 | struct alc_spec *spec = codec->spec; |
| 1669 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1670 | } |
| 1671 | |
| 1672 | /* |
| 1673 | * Digital out |
| 1674 | */ |
| 1675 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1676 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1677 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | { |
| 1679 | struct alc_spec *spec = codec->spec; |
| 1680 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1681 | } |
| 1682 | |
| 1683 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1684 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1685 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | { |
| 1687 | struct alc_spec *spec = codec->spec; |
| 1688 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1689 | } |
| 1690 | |
| 1691 | /* |
| 1692 | * Analog capture |
| 1693 | */ |
| 1694 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1695 | struct hda_codec *codec, |
| 1696 | unsigned int stream_tag, |
| 1697 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1698 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | { |
| 1700 | struct alc_spec *spec = codec->spec; |
| 1701 | |
| 1702 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1703 | stream_tag, 0, format); |
| 1704 | return 0; |
| 1705 | } |
| 1706 | |
| 1707 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1708 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1709 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | { |
| 1711 | struct alc_spec *spec = codec->spec; |
| 1712 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1713 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1714 | 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | return 0; |
| 1716 | } |
| 1717 | |
| 1718 | |
| 1719 | /* |
| 1720 | */ |
| 1721 | static struct hda_pcm_stream alc880_pcm_analog_playback = { |
| 1722 | .substreams = 1, |
| 1723 | .channels_min = 2, |
| 1724 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1725 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | .ops = { |
| 1727 | .open = alc880_playback_pcm_open, |
| 1728 | .prepare = alc880_playback_pcm_prepare, |
| 1729 | .cleanup = alc880_playback_pcm_cleanup |
| 1730 | }, |
| 1731 | }; |
| 1732 | |
| 1733 | static struct hda_pcm_stream alc880_pcm_analog_capture = { |
| 1734 | .substreams = 2, |
| 1735 | .channels_min = 2, |
| 1736 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1737 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | .ops = { |
| 1739 | .prepare = alc880_capture_pcm_prepare, |
| 1740 | .cleanup = alc880_capture_pcm_cleanup |
| 1741 | }, |
| 1742 | }; |
| 1743 | |
| 1744 | static struct hda_pcm_stream alc880_pcm_digital_playback = { |
| 1745 | .substreams = 1, |
| 1746 | .channels_min = 2, |
| 1747 | .channels_max = 2, |
| 1748 | /* NID is set in alc_build_pcms */ |
| 1749 | .ops = { |
| 1750 | .open = alc880_dig_playback_pcm_open, |
| 1751 | .close = alc880_dig_playback_pcm_close |
| 1752 | }, |
| 1753 | }; |
| 1754 | |
| 1755 | static struct hda_pcm_stream alc880_pcm_digital_capture = { |
| 1756 | .substreams = 1, |
| 1757 | .channels_min = 2, |
| 1758 | .channels_max = 2, |
| 1759 | /* NID is set in alc_build_pcms */ |
| 1760 | }; |
| 1761 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1762 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
| 1763 | static struct hda_pcm_stream alc_pcm_null_playback = { |
| 1764 | .substreams = 0, |
| 1765 | .channels_min = 0, |
| 1766 | .channels_max = 0, |
| 1767 | }; |
| 1768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | static int alc_build_pcms(struct hda_codec *codec) |
| 1770 | { |
| 1771 | struct alc_spec *spec = codec->spec; |
| 1772 | struct hda_pcm *info = spec->pcm_rec; |
| 1773 | int i; |
| 1774 | |
| 1775 | codec->num_pcms = 1; |
| 1776 | codec->pcm_info = info; |
| 1777 | |
| 1778 | info->name = spec->stream_name_analog; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1779 | if (spec->stream_analog_playback) { |
| 1780 | snd_assert(spec->multiout.dac_nids, return -EINVAL); |
| 1781 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
| 1782 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 1783 | } |
| 1784 | if (spec->stream_analog_capture) { |
| 1785 | snd_assert(spec->adc_nids, return -EINVAL); |
| 1786 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| 1787 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1788 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1790 | if (spec->channel_mode) { |
| 1791 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 1792 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 1793 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 1794 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 1795 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1796 | } |
| 1797 | } |
| 1798 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 1799 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 1801 | codec->num_pcms = 2; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 1802 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | info->name = spec->stream_name_digital; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1804 | if (spec->multiout.dig_out_nid && |
| 1805 | spec->stream_digital_playback) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1806 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
| 1807 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 1808 | } |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1809 | if (spec->dig_in_nid && |
| 1810 | spec->stream_digital_capture) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1811 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
| 1812 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 1813 | } |
| 1814 | } |
| 1815 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 1816 | /* If the use of more than one ADC is requested for the current |
| 1817 | * model, configure a second analog capture-only PCM. |
| 1818 | */ |
| 1819 | /* Additional Analaog capture for index #2 */ |
| 1820 | if (spec->num_adc_nids > 1 && spec->stream_analog_capture && |
| 1821 | spec->adc_nids) { |
| 1822 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 1823 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 1824 | info->name = spec->stream_name_analog; |
| 1825 | /* No playback stream for second PCM */ |
| 1826 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; |
| 1827 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 1828 | if (spec->stream_analog_capture) { |
| 1829 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
| 1830 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; |
| 1831 | } |
| 1832 | } |
| 1833 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1834 | return 0; |
| 1835 | } |
| 1836 | |
| 1837 | static void alc_free(struct hda_codec *codec) |
| 1838 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1839 | struct alc_spec *spec = codec->spec; |
| 1840 | unsigned int i; |
| 1841 | |
| 1842 | if (! spec) |
| 1843 | return; |
| 1844 | |
| 1845 | if (spec->kctl_alloc) { |
| 1846 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1847 | kfree(spec->kctl_alloc[i].name); |
| 1848 | kfree(spec->kctl_alloc); |
| 1849 | } |
| 1850 | kfree(spec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1851 | } |
| 1852 | |
| 1853 | /* |
| 1854 | */ |
| 1855 | static struct hda_codec_ops alc_patch_ops = { |
| 1856 | .build_controls = alc_build_controls, |
| 1857 | .build_pcms = alc_build_pcms, |
| 1858 | .init = alc_init, |
| 1859 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1860 | .unsol_event = alc_unsol_event, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1861 | #ifdef CONFIG_PM |
| 1862 | .resume = alc_resume, |
| 1863 | #endif |
| 1864 | }; |
| 1865 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1866 | |
| 1867 | /* |
| 1868 | * Test configuration for debugging |
| 1869 | * |
| 1870 | * Almost all inputs/outputs are enabled. I/O pins can be configured via |
| 1871 | * enum controls. |
| 1872 | */ |
| 1873 | #ifdef CONFIG_SND_DEBUG |
| 1874 | static hda_nid_t alc880_test_dac_nids[4] = { |
| 1875 | 0x02, 0x03, 0x04, 0x05 |
| 1876 | }; |
| 1877 | |
| 1878 | static struct hda_input_mux alc880_test_capture_source = { |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1879 | .num_items = 7, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1880 | .items = { |
| 1881 | { "In-1", 0x0 }, |
| 1882 | { "In-2", 0x1 }, |
| 1883 | { "In-3", 0x2 }, |
| 1884 | { "In-4", 0x3 }, |
| 1885 | { "CD", 0x4 }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1886 | { "Front", 0x5 }, |
| 1887 | { "Surround", 0x6 }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1888 | }, |
| 1889 | }; |
| 1890 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 1891 | static struct hda_channel_mode alc880_test_modes[4] = { |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1892 | { 2, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1893 | { 4, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1894 | { 6, NULL }, |
Takashi Iwai | fd2c326 | 2005-05-13 17:18:42 +0200 | [diff] [blame] | 1895 | { 8, NULL }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1896 | }; |
| 1897 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1898 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
| 1899 | struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1900 | { |
| 1901 | static char *texts[] = { |
| 1902 | "N/A", "Line Out", "HP Out", |
| 1903 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" |
| 1904 | }; |
| 1905 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1906 | uinfo->count = 1; |
| 1907 | uinfo->value.enumerated.items = 8; |
| 1908 | if (uinfo->value.enumerated.item >= 8) |
| 1909 | uinfo->value.enumerated.item = 7; |
| 1910 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1911 | return 0; |
| 1912 | } |
| 1913 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1914 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
| 1915 | struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1916 | { |
| 1917 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1918 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1919 | unsigned int pin_ctl, item = 0; |
| 1920 | |
| 1921 | pin_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1922 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1923 | if (pin_ctl & AC_PINCTL_OUT_EN) { |
| 1924 | if (pin_ctl & AC_PINCTL_HP_EN) |
| 1925 | item = 2; |
| 1926 | else |
| 1927 | item = 1; |
| 1928 | } else if (pin_ctl & AC_PINCTL_IN_EN) { |
| 1929 | switch (pin_ctl & AC_PINCTL_VREFEN) { |
| 1930 | case AC_PINCTL_VREF_HIZ: item = 3; break; |
| 1931 | case AC_PINCTL_VREF_50: item = 4; break; |
| 1932 | case AC_PINCTL_VREF_GRD: item = 5; break; |
| 1933 | case AC_PINCTL_VREF_80: item = 6; break; |
| 1934 | case AC_PINCTL_VREF_100: item = 7; break; |
| 1935 | } |
| 1936 | } |
| 1937 | ucontrol->value.enumerated.item[0] = item; |
| 1938 | return 0; |
| 1939 | } |
| 1940 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1941 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
| 1942 | struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1943 | { |
| 1944 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1945 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1946 | static unsigned int ctls[] = { |
| 1947 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, |
| 1948 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, |
| 1949 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, |
| 1950 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, |
| 1951 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, |
| 1952 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, |
| 1953 | }; |
| 1954 | unsigned int old_ctl, new_ctl; |
| 1955 | |
| 1956 | old_ctl = snd_hda_codec_read(codec, nid, 0, |
| 1957 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1958 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; |
| 1959 | if (old_ctl != new_ctl) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1960 | snd_hda_codec_write(codec, nid, 0, |
| 1961 | AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1962 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1963 | (ucontrol->value.enumerated.item[0] >= 3 ? |
| 1964 | 0xb080 : 0xb000)); |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1965 | return 1; |
| 1966 | } |
| 1967 | return 0; |
| 1968 | } |
| 1969 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1970 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
| 1971 | struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1972 | { |
| 1973 | static char *texts[] = { |
| 1974 | "Front", "Surround", "CLFE", "Side" |
| 1975 | }; |
| 1976 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1977 | uinfo->count = 1; |
| 1978 | uinfo->value.enumerated.items = 4; |
| 1979 | if (uinfo->value.enumerated.item >= 4) |
| 1980 | uinfo->value.enumerated.item = 3; |
| 1981 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1982 | return 0; |
| 1983 | } |
| 1984 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1985 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
| 1986 | struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1987 | { |
| 1988 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1989 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 1990 | unsigned int sel; |
| 1991 | |
| 1992 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1993 | ucontrol->value.enumerated.item[0] = sel & 3; |
| 1994 | return 0; |
| 1995 | } |
| 1996 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1997 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
| 1998 | struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 1999 | { |
| 2000 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2001 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; |
| 2002 | unsigned int sel; |
| 2003 | |
| 2004 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; |
| 2005 | if (ucontrol->value.enumerated.item[0] != sel) { |
| 2006 | sel = ucontrol->value.enumerated.item[0] & 3; |
| 2007 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); |
| 2008 | return 1; |
| 2009 | } |
| 2010 | return 0; |
| 2011 | } |
| 2012 | |
| 2013 | #define PIN_CTL_TEST(xname,nid) { \ |
| 2014 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2015 | .name = xname, \ |
| 2016 | .info = alc_test_pin_ctl_info, \ |
| 2017 | .get = alc_test_pin_ctl_get, \ |
| 2018 | .put = alc_test_pin_ctl_put, \ |
| 2019 | .private_value = nid \ |
| 2020 | } |
| 2021 | |
| 2022 | #define PIN_SRC_TEST(xname,nid) { \ |
| 2023 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2024 | .name = xname, \ |
| 2025 | .info = alc_test_pin_src_info, \ |
| 2026 | .get = alc_test_pin_src_get, \ |
| 2027 | .put = alc_test_pin_src_put, \ |
| 2028 | .private_value = nid \ |
| 2029 | } |
| 2030 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2031 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2032 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 2033 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| 2034 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
| 2035 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2036 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 2037 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| 2038 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), |
| 2039 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2040 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
| 2041 | PIN_CTL_TEST("Surround Pin Mode", 0x15), |
| 2042 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), |
| 2043 | PIN_CTL_TEST("Side Pin Mode", 0x17), |
| 2044 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), |
| 2045 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), |
| 2046 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), |
| 2047 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), |
| 2048 | PIN_SRC_TEST("In-1 Pin Source", 0x18), |
| 2049 | PIN_SRC_TEST("In-2 Pin Source", 0x19), |
| 2050 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), |
| 2051 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), |
| 2052 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 2053 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 2054 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 2055 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 2056 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), |
| 2057 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), |
| 2058 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), |
| 2059 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), |
| 2060 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), |
| 2061 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2062 | { |
| 2063 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2064 | .name = "Channel Mode", |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2065 | .info = alc_ch_mode_info, |
| 2066 | .get = alc_ch_mode_get, |
| 2067 | .put = alc_ch_mode_put, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2068 | }, |
| 2069 | { } /* end */ |
| 2070 | }; |
| 2071 | |
| 2072 | static struct hda_verb alc880_test_init_verbs[] = { |
| 2073 | /* Unmute inputs of 0x0c - 0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2074 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2075 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2076 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2077 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2078 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2079 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2080 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2081 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2082 | /* Vol output for 0x0c-0x0f */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2083 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2084 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2085 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2086 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2087 | /* Set output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2088 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2089 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2090 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2091 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2092 | /* Unmute output pins 0x14-0x17 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2093 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2094 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2095 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2096 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2097 | /* Set input pins 0x18-0x1c */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2098 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2099 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2100 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2101 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2102 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2103 | /* Mute input pins 0x18-0x1b */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2104 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2105 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2106 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2107 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2108 | /* ADC set up */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2109 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2110 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2111 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2112 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2113 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 2114 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 2115 | /* Analog input/passthru */ |
| 2116 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2117 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2118 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2119 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2120 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2121 | { } |
| 2122 | }; |
| 2123 | #endif |
| 2124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | /* |
| 2126 | */ |
| 2127 | |
| 2128 | static struct hda_board_config alc880_cfg_tbl[] = { |
| 2129 | /* Back 3 jack, front 2 jack */ |
| 2130 | { .modelname = "3stack", .config = ALC880_3ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2131 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, |
| 2132 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, |
| 2133 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, |
| 2134 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, |
| 2135 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, |
| 2136 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, |
| 2137 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, |
| 2138 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, |
| 2139 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, |
| 2140 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, |
| 2141 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, |
| 2142 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, |
| 2143 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, |
| 2144 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, |
| 2145 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, |
| 2146 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, |
| 2147 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, |
| 2148 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, |
Tobin Davis | 2aaeee8 | 2006-08-21 19:01:12 +0200 | [diff] [blame] | 2149 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST }, |
| 2150 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2151 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, |
Tobin Davis | 2aaeee8 | 2006-08-21 19:01:12 +0200 | [diff] [blame] | 2152 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2153 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, |
| 2154 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, |
| 2155 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, |
| 2156 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, |
| 2157 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, |
| 2158 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, |
| 2159 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, |
| 2160 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, |
| 2161 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, |
| 2162 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, |
| 2163 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, |
| 2164 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, |
| 2165 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2166 | /* TCL S700 */ |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 2167 | { .modelname = "tcl", .config = ALC880_TCL_S700 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2168 | { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | |
| 2170 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2171 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2172 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, |
Davide Libenzi | 0ca2161 | 2005-09-05 11:56:47 +0200 | [diff] [blame] | 2173 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2174 | |
| 2175 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ |
| 2176 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2177 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, |
Jaroslav Kysela | 5a47fe3 | 2005-08-15 20:01:40 +0200 | [diff] [blame] | 2178 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, |
Takashi Iwai | 5a053d0 | 2006-07-25 14:51:15 +0200 | [diff] [blame] | 2179 | |
| 2180 | /* Clevo laptops */ |
| 2181 | { .modelname = "clevo", .config = ALC880_CLEVO }, |
| 2182 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, |
| 2183 | .config = ALC880_CLEVO }, /* Clevo m520G NB */ |
| 2184 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660, |
| 2185 | .config = ALC880_CLEVO }, /* Clevo m665n */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | |
| 2187 | /* 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] | 2188 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, |
| 2189 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, |
| 2190 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | |
| 2192 | /* Back 5 jack, front 2 jack */ |
| 2193 | { .modelname = "5stack", .config = ALC880_5ST }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2194 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, |
| 2195 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, |
| 2196 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, |
| 2197 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2198 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | |
| 2200 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ |
| 2201 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2202 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, |
| 2203 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, |
| 2204 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, |
| 2205 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, |
| 2206 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, |
| 2207 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, |
| 2208 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, |
| 2209 | { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2210 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, |
Takashi Iwai | ede3531 | 2006-03-13 14:21:16 +0100 | [diff] [blame] | 2211 | { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, |
| 2212 | .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */ |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 2213 | /* { .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] | 2214 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2215 | /* note subvendor = 0 below */ |
| 2216 | /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | |
| 2218 | { .modelname = "w810", .config = ALC880_W810 }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2219 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 2221 | { .modelname = "z71v", .config = ALC880_Z71V }, |
Takashi Iwai | 7291548 | 2005-05-12 16:49:45 +0200 | [diff] [blame] | 2222 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, |
Takashi Iwai | dfc0ff6 | 2005-05-12 14:31:49 +0200 | [diff] [blame] | 2223 | |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2224 | { .modelname = "6stack", .config = ALC880_6ST }, |
Takashi Iwai | 7632c7b | 2005-12-07 18:25:47 +0100 | [diff] [blame] | 2225 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2226 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, |
Takashi Iwai | 7a318a7 | 2005-06-28 14:16:21 +0200 | [diff] [blame] | 2227 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ |
Arnaud Patard | bae2bdb | 2006-01-27 12:05:02 +0100 | [diff] [blame] | 2228 | { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */ |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2229 | |
| 2230 | { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2231 | { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, |
| 2232 | { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, |
| 2233 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, |
| 2234 | { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2235 | { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, |
| 2236 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, |
| 2237 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, |
| 2238 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, |
Takashi Iwai | 041dec0 | 2005-12-23 12:27:52 +0100 | [diff] [blame] | 2239 | { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ |
Takashi Iwai | a12606c | 2006-03-15 18:24:43 +0100 | [diff] [blame] | 2240 | { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */ |
Takashi Iwai | 531213a | 2006-04-18 13:46:08 +0200 | [diff] [blame] | 2241 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2242 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2243 | { .modelname = "asus", .config = ALC880_ASUS }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2244 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, |
| 2245 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, |
| 2246 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, |
| 2247 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 8648811 | 2005-09-09 13:56:32 +0200 | [diff] [blame] | 2248 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2249 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, |
Danny Tholen | f5a5ffa | 2006-08-08 18:59:07 +0200 | [diff] [blame] | 2250 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2251 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, |
| 2252 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, |
| 2253 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, |
| 2254 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 2255 | { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2256 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 2257 | { .modelname = "asus-dig", .config = ALC880_ASUS_DIG }, |
Takashi Iwai | 84f3430 | 2006-03-21 19:12:53 +0100 | [diff] [blame] | 2258 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */ |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 2259 | { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2260 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2261 | |
| 2262 | { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, |
| 2263 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, |
| 2264 | |
| 2265 | { .modelname = "F1734", .config = ALC880_F1734 }, |
| 2266 | { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2267 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2268 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2269 | { .modelname = "lg", .config = ALC880_LG }, |
| 2270 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG }, |
Takashi Iwai | 886da86 | 2006-05-02 18:17:57 +0200 | [diff] [blame] | 2271 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2272 | |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 2273 | { .modelname = "lg-lw", .config = ALC880_LG_LW }, |
| 2274 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW }, |
Takashi Iwai | cd417d4 | 2006-09-06 16:03:11 +0200 | [diff] [blame] | 2275 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW }, |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 2276 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2277 | #ifdef CONFIG_SND_DEBUG |
| 2278 | { .modelname = "test", .config = ALC880_TEST }, |
| 2279 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2280 | { .modelname = "auto", .config = ALC880_AUTO }, |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | {} |
| 2283 | }; |
| 2284 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2285 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2286 | * ALC880 codec presets |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2287 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2288 | static struct alc_config_preset alc880_presets[] = { |
| 2289 | [ALC880_3ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2290 | .mixers = { alc880_three_stack_mixer }, |
| 2291 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2292 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2293 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2294 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2295 | .channel_mode = alc880_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2296 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2297 | .input_mux = &alc880_capture_source, |
| 2298 | }, |
| 2299 | [ALC880_3ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2300 | .mixers = { alc880_three_stack_mixer }, |
| 2301 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2302 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2303 | .dac_nids = alc880_dac_nids, |
| 2304 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2305 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2306 | .channel_mode = alc880_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2307 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2308 | .input_mux = &alc880_capture_source, |
| 2309 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2310 | [ALC880_TCL_S700] = { |
| 2311 | .mixers = { alc880_tcl_s700_mixer }, |
| 2312 | .init_verbs = { alc880_volume_init_verbs, |
| 2313 | alc880_pin_tcl_S700_init_verbs, |
| 2314 | alc880_gpio2_init_verbs }, |
| 2315 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2316 | .dac_nids = alc880_dac_nids, |
| 2317 | .hp_nid = 0x03, |
| 2318 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2319 | .channel_mode = alc880_2_jack_modes, |
| 2320 | .input_mux = &alc880_capture_source, |
| 2321 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2322 | [ALC880_5ST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2323 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, |
| 2324 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2325 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2326 | .dac_nids = alc880_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2327 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 2328 | .channel_mode = alc880_fivestack_modes, |
| 2329 | .input_mux = &alc880_capture_source, |
| 2330 | }, |
| 2331 | [ALC880_5ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2332 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, |
| 2333 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2334 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2335 | .dac_nids = alc880_dac_nids, |
| 2336 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2337 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
| 2338 | .channel_mode = alc880_fivestack_modes, |
| 2339 | .input_mux = &alc880_capture_source, |
| 2340 | }, |
Takashi Iwai | b6482d4 | 2005-06-27 15:32:43 +0200 | [diff] [blame] | 2341 | [ALC880_6ST] = { |
| 2342 | .mixers = { alc880_six_stack_mixer }, |
| 2343 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
| 2344 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 2345 | .dac_nids = alc880_6st_dac_nids, |
| 2346 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 2347 | .channel_mode = alc880_sixstack_modes, |
| 2348 | .input_mux = &alc880_6stack_capture_source, |
| 2349 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2350 | [ALC880_6ST_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2351 | .mixers = { alc880_six_stack_mixer }, |
| 2352 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2353 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
| 2354 | .dac_nids = alc880_6st_dac_nids, |
| 2355 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2356 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
| 2357 | .channel_mode = alc880_sixstack_modes, |
| 2358 | .input_mux = &alc880_6stack_capture_source, |
| 2359 | }, |
| 2360 | [ALC880_W810] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2361 | .mixers = { alc880_w810_base_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2362 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, |
| 2363 | alc880_gpio2_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2364 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
| 2365 | .dac_nids = alc880_w810_dac_nids, |
| 2366 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2367 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
| 2368 | .channel_mode = alc880_w810_modes, |
| 2369 | .input_mux = &alc880_capture_source, |
| 2370 | }, |
| 2371 | [ALC880_Z71V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2372 | .mixers = { alc880_z71v_mixer }, |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2373 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2374 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
| 2375 | .dac_nids = alc880_z71v_dac_nids, |
| 2376 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2377 | .hp_nid = 0x03, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2378 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2379 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2380 | .input_mux = &alc880_capture_source, |
| 2381 | }, |
| 2382 | [ALC880_F1734] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2383 | .mixers = { alc880_f1734_mixer }, |
| 2384 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, |
| 2385 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
| 2386 | .dac_nids = alc880_f1734_dac_nids, |
| 2387 | .hp_nid = 0x02, |
| 2388 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2389 | .channel_mode = alc880_2_jack_modes, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2390 | .input_mux = &alc880_capture_source, |
| 2391 | }, |
| 2392 | [ALC880_ASUS] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2393 | .mixers = { alc880_asus_mixer }, |
| 2394 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2395 | alc880_gpio1_init_verbs }, |
| 2396 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2397 | .dac_nids = alc880_asus_dac_nids, |
| 2398 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2399 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2400 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2401 | .input_mux = &alc880_capture_source, |
| 2402 | }, |
| 2403 | [ALC880_ASUS_DIG] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2404 | .mixers = { alc880_asus_mixer }, |
| 2405 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2406 | alc880_gpio1_init_verbs }, |
| 2407 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2408 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2409 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2410 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2411 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2412 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2413 | .input_mux = &alc880_capture_source, |
| 2414 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2415 | [ALC880_ASUS_DIG2] = { |
| 2416 | .mixers = { alc880_asus_mixer }, |
| 2417 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2418 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
| 2419 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2420 | .dac_nids = alc880_asus_dac_nids, |
| 2421 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2422 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2423 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2424 | .need_dac_fix = 1, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2425 | .input_mux = &alc880_capture_source, |
| 2426 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2427 | [ALC880_ASUS_W1V] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2428 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
| 2429 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, |
| 2430 | alc880_gpio1_init_verbs }, |
| 2431 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2432 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2433 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2434 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2435 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2436 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2437 | .input_mux = &alc880_capture_source, |
| 2438 | }, |
| 2439 | [ALC880_UNIWILL_DIG] = { |
Takashi Iwai | 3c10a9d | 2005-08-23 20:02:27 +0200 | [diff] [blame] | 2440 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2441 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, |
| 2442 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
| 2443 | .dac_nids = alc880_asus_dac_nids, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2444 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2445 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
| 2446 | .channel_mode = alc880_asus_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2447 | .need_dac_fix = 1, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2448 | .input_mux = &alc880_capture_source, |
| 2449 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2450 | [ALC880_CLEVO] = { |
| 2451 | .mixers = { alc880_three_stack_mixer }, |
| 2452 | .init_verbs = { alc880_volume_init_verbs, |
| 2453 | alc880_pin_clevo_init_verbs }, |
| 2454 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
| 2455 | .dac_nids = alc880_dac_nids, |
| 2456 | .hp_nid = 0x03, |
| 2457 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
| 2458 | .channel_mode = alc880_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2459 | .need_dac_fix = 1, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2460 | .input_mux = &alc880_capture_source, |
| 2461 | }, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2462 | [ALC880_LG] = { |
| 2463 | .mixers = { alc880_lg_mixer }, |
| 2464 | .init_verbs = { alc880_volume_init_verbs, |
| 2465 | alc880_lg_init_verbs }, |
| 2466 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), |
| 2467 | .dac_nids = alc880_lg_dac_nids, |
| 2468 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2469 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), |
| 2470 | .channel_mode = alc880_lg_ch_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 2471 | .need_dac_fix = 1, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2472 | .input_mux = &alc880_lg_capture_source, |
| 2473 | .unsol_event = alc880_lg_unsol_event, |
| 2474 | .init_hook = alc880_lg_automute, |
| 2475 | }, |
Takashi Iwai | d681518 | 2006-03-23 16:06:23 +0100 | [diff] [blame] | 2476 | [ALC880_LG_LW] = { |
| 2477 | .mixers = { alc880_lg_lw_mixer }, |
| 2478 | .init_verbs = { alc880_volume_init_verbs, |
| 2479 | alc880_lg_lw_init_verbs }, |
| 2480 | .num_dacs = 1, |
| 2481 | .dac_nids = alc880_dac_nids, |
| 2482 | .dig_out_nid = ALC880_DIGOUT_NID, |
| 2483 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
| 2484 | .channel_mode = alc880_2_jack_modes, |
| 2485 | .input_mux = &alc880_lg_lw_capture_source, |
| 2486 | .unsol_event = alc880_lg_lw_unsol_event, |
| 2487 | .init_hook = alc880_lg_lw_automute, |
| 2488 | }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2489 | #ifdef CONFIG_SND_DEBUG |
| 2490 | [ALC880_TEST] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2491 | .mixers = { alc880_test_mixer }, |
| 2492 | .init_verbs = { alc880_test_init_verbs }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2493 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
| 2494 | .dac_nids = alc880_test_dac_nids, |
| 2495 | .dig_out_nid = ALC880_DIGOUT_NID, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2496 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
| 2497 | .channel_mode = alc880_test_modes, |
| 2498 | .input_mux = &alc880_test_capture_source, |
| 2499 | }, |
| 2500 | #endif |
| 2501 | }; |
| 2502 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2503 | /* |
| 2504 | * Automatic parse of I/O pins from the BIOS configuration |
| 2505 | */ |
| 2506 | |
| 2507 | #define NUM_CONTROL_ALLOC 32 |
| 2508 | #define NUM_VERB_ALLOC 32 |
| 2509 | |
| 2510 | enum { |
| 2511 | ALC_CTL_WIDGET_VOL, |
| 2512 | ALC_CTL_WIDGET_MUTE, |
| 2513 | ALC_CTL_BIND_MUTE, |
| 2514 | }; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2515 | static struct snd_kcontrol_new alc880_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2516 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2517 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2518 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2519 | }; |
| 2520 | |
| 2521 | /* add dynamic controls */ |
| 2522 | static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) |
| 2523 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2524 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2525 | |
| 2526 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2527 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2528 | |
| 2529 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2530 | if (! knew) |
| 2531 | return -ENOMEM; |
| 2532 | if (spec->kctl_alloc) { |
| 2533 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2534 | kfree(spec->kctl_alloc); |
| 2535 | } |
| 2536 | spec->kctl_alloc = knew; |
| 2537 | spec->num_kctl_alloc = num; |
| 2538 | } |
| 2539 | |
| 2540 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2541 | *knew = alc880_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2542 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2543 | if (! knew->name) |
| 2544 | return -ENOMEM; |
| 2545 | knew->private_value = val; |
| 2546 | spec->num_kctl_used++; |
| 2547 | return 0; |
| 2548 | } |
| 2549 | |
| 2550 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
| 2551 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
| 2552 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
| 2553 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) |
| 2554 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) |
| 2555 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) |
| 2556 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) |
| 2557 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) |
| 2558 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) |
| 2559 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) |
| 2560 | #define ALC880_PIN_CD_NID 0x1c |
| 2561 | |
| 2562 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2563 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 2564 | { |
| 2565 | hda_nid_t nid; |
| 2566 | int assigned[4]; |
| 2567 | int i, j; |
| 2568 | |
| 2569 | memset(assigned, 0, sizeof(assigned)); |
Takashi Iwai | b0af0de | 2005-06-21 14:49:19 +0200 | [diff] [blame] | 2570 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2571 | |
| 2572 | /* check the pins hardwired to audio widget */ |
| 2573 | for (i = 0; i < cfg->line_outs; i++) { |
| 2574 | nid = cfg->line_out_pins[i]; |
| 2575 | if (alc880_is_fixed_pin(nid)) { |
| 2576 | int idx = alc880_fixed_pin_idx(nid); |
Libin Yang | 5014f19 | 2005-11-23 15:48:36 +0100 | [diff] [blame] | 2577 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2578 | assigned[idx] = 1; |
| 2579 | } |
| 2580 | } |
| 2581 | /* left pins can be connect to any audio widget */ |
| 2582 | for (i = 0; i < cfg->line_outs; i++) { |
| 2583 | nid = cfg->line_out_pins[i]; |
| 2584 | if (alc880_is_fixed_pin(nid)) |
| 2585 | continue; |
| 2586 | /* search for an empty channel */ |
| 2587 | for (j = 0; j < cfg->line_outs; j++) { |
| 2588 | if (! assigned[j]) { |
| 2589 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); |
| 2590 | assigned[j] = 1; |
| 2591 | break; |
| 2592 | } |
| 2593 | } |
| 2594 | } |
| 2595 | spec->multiout.num_dacs = cfg->line_outs; |
| 2596 | return 0; |
| 2597 | } |
| 2598 | |
| 2599 | /* add playback controls from the parsed DAC table */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2600 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 2601 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2602 | { |
| 2603 | char name[32]; |
| 2604 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2605 | hda_nid_t nid; |
| 2606 | int i, err; |
| 2607 | |
| 2608 | for (i = 0; i < cfg->line_outs; i++) { |
| 2609 | if (! spec->multiout.dac_nids[i]) |
| 2610 | continue; |
| 2611 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
| 2612 | if (i == 2) { |
| 2613 | /* Center/LFE */ |
| 2614 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", |
| 2615 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 2616 | return err; |
| 2617 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", |
| 2618 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 2619 | return err; |
| 2620 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 2621 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) |
| 2622 | return err; |
| 2623 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 2624 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) |
| 2625 | return err; |
| 2626 | } else { |
| 2627 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2628 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
| 2629 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2630 | return err; |
| 2631 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2632 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 2633 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2634 | return err; |
| 2635 | } |
| 2636 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2637 | return 0; |
| 2638 | } |
| 2639 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2640 | /* add playback controls for speaker and HP outputs */ |
| 2641 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, |
| 2642 | const char *pfx) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2643 | { |
| 2644 | hda_nid_t nid; |
| 2645 | int err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2646 | char name[32]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2647 | |
| 2648 | if (! pin) |
| 2649 | return 0; |
| 2650 | |
| 2651 | if (alc880_is_fixed_pin(pin)) { |
| 2652 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2653 | /* specify the DAC as the extra output */ |
| 2654 | if (! spec->multiout.hp_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2655 | spec->multiout.hp_nid = nid; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2656 | else |
| 2657 | spec->multiout.extra_out_nid[0] = nid; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2658 | /* control HP volume/switch on the output mixer amp */ |
| 2659 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2660 | sprintf(name, "%s Playback Volume", pfx); |
| 2661 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2662 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2663 | return err; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2664 | sprintf(name, "%s Playback Switch", pfx); |
| 2665 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2666 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2667 | return err; |
| 2668 | } else if (alc880_is_multi_pin(pin)) { |
| 2669 | /* set manual connection */ |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2670 | /* we have only a switch on HP-out PIN */ |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2671 | sprintf(name, "%s Playback Switch", pfx); |
| 2672 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2673 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) |
| 2674 | return err; |
| 2675 | } |
| 2676 | return 0; |
| 2677 | } |
| 2678 | |
| 2679 | /* create input playback/capture controls for the given pin */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2680 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, |
| 2681 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2682 | { |
| 2683 | char name[32]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2684 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2685 | |
| 2686 | sprintf(name, "%s Playback Volume", ctlname); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2687 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2688 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2689 | return err; |
| 2690 | sprintf(name, "%s Playback Switch", ctlname); |
| 2691 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2692 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2693 | return err; |
| 2694 | return 0; |
| 2695 | } |
| 2696 | |
| 2697 | /* create playback/capture controls for input pins */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2698 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 2699 | const struct auto_pin_cfg *cfg) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2700 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2701 | struct hda_input_mux *imux = &spec->private_imux; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2702 | int i, err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2703 | |
| 2704 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2705 | if (alc880_is_input_pin(cfg->input_pins[i])) { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2706 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2707 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2708 | auto_pin_cfg_labels[i], |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2709 | idx, 0x0b); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2710 | if (err < 0) |
| 2711 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2712 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2713 | imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); |
| 2714 | imux->num_items++; |
| 2715 | } |
| 2716 | } |
| 2717 | return 0; |
| 2718 | } |
| 2719 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2720 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2721 | hda_nid_t nid, int pin_type, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2722 | int dac_idx) |
| 2723 | { |
| 2724 | /* set as output */ |
| 2725 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2726 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2727 | /* need the manual connection? */ |
| 2728 | if (alc880_is_multi_pin(nid)) { |
| 2729 | struct alc_spec *spec = codec->spec; |
| 2730 | int idx = alc880_multi_pin_idx(nid); |
| 2731 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, |
| 2732 | AC_VERB_SET_CONNECT_SEL, |
| 2733 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); |
| 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
| 2738 | { |
| 2739 | struct alc_spec *spec = codec->spec; |
| 2740 | int i; |
| 2741 | |
| 2742 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2743 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2744 | alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2745 | } |
| 2746 | } |
| 2747 | |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2748 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2749 | { |
| 2750 | struct alc_spec *spec = codec->spec; |
| 2751 | hda_nid_t pin; |
| 2752 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2753 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2754 | if (pin) /* connect to front */ |
| 2755 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2756 | pin = spec->autocfg.hp_pins[0]; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2757 | if (pin) /* connect to front */ |
| 2758 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2759 | } |
| 2760 | |
| 2761 | static void alc880_auto_init_analog_input(struct hda_codec *codec) |
| 2762 | { |
| 2763 | struct alc_spec *spec = codec->spec; |
| 2764 | int i; |
| 2765 | |
| 2766 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2767 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2768 | if (alc880_is_input_pin(nid)) { |
| 2769 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2770 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2771 | if (nid != ALC880_PIN_CD_NID) |
| 2772 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2773 | AMP_OUT_MUTE); |
| 2774 | } |
| 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2779 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2780 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 2781 | { |
| 2782 | struct alc_spec *spec = codec->spec; |
| 2783 | int err; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2784 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2785 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2786 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 2787 | alc880_ignore)) < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2788 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2789 | if (! spec->autocfg.line_outs) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2790 | return 0; /* can't find valid BIOS pin config */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2791 | |
| 2792 | if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 2793 | (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2794 | (err = alc880_auto_create_extra_out(spec, |
| 2795 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2796 | "Speaker")) < 0 || |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2797 | (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2798 | "Headphone")) < 0 || |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2799 | (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2800 | return err; |
| 2801 | |
| 2802 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2803 | |
| 2804 | if (spec->autocfg.dig_out_pin) |
| 2805 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
| 2806 | if (spec->autocfg.dig_in_pin) |
| 2807 | spec->dig_in_nid = ALC880_DIGIN_NID; |
| 2808 | |
| 2809 | if (spec->kctl_alloc) |
| 2810 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2811 | |
| 2812 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; |
| 2813 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2814 | spec->num_mux_defs = 1; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2815 | spec->input_mux = &spec->private_imux; |
| 2816 | |
| 2817 | return 1; |
| 2818 | } |
| 2819 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2820 | /* additional initialization for auto-configuration model */ |
| 2821 | static void alc880_auto_init(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2822 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2823 | alc880_auto_init_multi_out(codec); |
Takashi Iwai | 8d88bc3 | 2005-11-17 11:09:23 +0100 | [diff] [blame] | 2824 | alc880_auto_init_extra_out(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2825 | alc880_auto_init_analog_input(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2826 | } |
| 2827 | |
| 2828 | /* |
| 2829 | * OK, here we have finally the patch for ALC880 |
| 2830 | */ |
| 2831 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | static int patch_alc880(struct hda_codec *codec) |
| 2833 | { |
| 2834 | struct alc_spec *spec; |
| 2835 | int board_config; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2836 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2837 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 2838 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2839 | if (spec == NULL) |
| 2840 | return -ENOMEM; |
| 2841 | |
| 2842 | codec->spec = spec; |
| 2843 | |
| 2844 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2845 | if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2846 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
| 2847 | "trying auto-probe from BIOS...\n"); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2848 | board_config = ALC880_AUTO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2849 | } |
| 2850 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2851 | if (board_config == ALC880_AUTO) { |
| 2852 | /* automatic parse from the BIOS config */ |
| 2853 | err = alc880_parse_auto_config(codec); |
| 2854 | if (err < 0) { |
| 2855 | alc_free(codec); |
| 2856 | return err; |
| 2857 | } else if (! err) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2858 | printk(KERN_INFO |
| 2859 | "hda_codec: Cannot set up configuration " |
| 2860 | "from BIOS. Using 3-stack mode...\n"); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2861 | board_config = ALC880_3ST; |
| 2862 | } |
| 2863 | } |
| 2864 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2865 | if (board_config != ALC880_AUTO) |
| 2866 | setup_preset(spec, &alc880_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2867 | |
| 2868 | spec->stream_name_analog = "ALC880 Analog"; |
| 2869 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
| 2870 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
| 2871 | |
| 2872 | spec->stream_name_digital = "ALC880 Digital"; |
| 2873 | spec->stream_digital_playback = &alc880_pcm_digital_playback; |
| 2874 | spec->stream_digital_capture = &alc880_pcm_digital_capture; |
| 2875 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2876 | if (! spec->adc_nids && spec->input_mux) { |
| 2877 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 54d1740 | 2005-11-21 16:33:22 +0100 | [diff] [blame] | 2878 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2879 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 2880 | if (wcap != AC_WID_AUD_IN) { |
| 2881 | spec->adc_nids = alc880_adc_nids_alt; |
| 2882 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
| 2883 | spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; |
| 2884 | spec->num_mixers++; |
| 2885 | } else { |
| 2886 | spec->adc_nids = alc880_adc_nids; |
| 2887 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
| 2888 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; |
| 2889 | spec->num_mixers++; |
| 2890 | } |
| 2891 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2892 | |
| 2893 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2894 | if (board_config == ALC880_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2895 | spec->init_hook = alc880_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | |
| 2897 | return 0; |
| 2898 | } |
| 2899 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2900 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | /* |
| 2902 | * ALC260 support |
| 2903 | */ |
| 2904 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2905 | static hda_nid_t alc260_dac_nids[1] = { |
| 2906 | /* front */ |
| 2907 | 0x02, |
| 2908 | }; |
| 2909 | |
| 2910 | static hda_nid_t alc260_adc_nids[1] = { |
| 2911 | /* ADC0 */ |
| 2912 | 0x04, |
| 2913 | }; |
| 2914 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2915 | static hda_nid_t alc260_adc_nids_alt[1] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2916 | /* ADC1 */ |
| 2917 | 0x05, |
| 2918 | }; |
| 2919 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2920 | static hda_nid_t alc260_hp_adc_nids[2] = { |
| 2921 | /* ADC1, 0 */ |
| 2922 | 0x05, 0x04 |
| 2923 | }; |
| 2924 | |
Jonathan Woithe | d57fdac | 2006-02-28 11:38:35 +0100 | [diff] [blame] | 2925 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
| 2926 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. |
| 2927 | */ |
| 2928 | static hda_nid_t alc260_dual_adc_nids[2] = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2929 | /* ADC0, ADC1 */ |
| 2930 | 0x04, 0x05 |
| 2931 | }; |
| 2932 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2933 | #define ALC260_DIGOUT_NID 0x03 |
| 2934 | #define ALC260_DIGIN_NID 0x06 |
| 2935 | |
| 2936 | static struct hda_input_mux alc260_capture_source = { |
| 2937 | .num_items = 4, |
| 2938 | .items = { |
| 2939 | { "Mic", 0x0 }, |
| 2940 | { "Front Mic", 0x1 }, |
| 2941 | { "Line", 0x2 }, |
| 2942 | { "CD", 0x4 }, |
| 2943 | }, |
| 2944 | }; |
| 2945 | |
Jonathan Woithe | 17e7aec | 2006-02-28 11:35:18 +0100 | [diff] [blame] | 2946 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2947 | * headphone jack and the internal CD lines since these are the only pins at |
| 2948 | * which audio can appear. For flexibility, also allow the option of |
| 2949 | * recording the mixer output on the second ADC (ADC0 doesn't have a |
| 2950 | * connection to the mixer output). |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2951 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2952 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
| 2953 | { |
| 2954 | .num_items = 3, |
| 2955 | .items = { |
| 2956 | { "Mic/Line", 0x0 }, |
| 2957 | { "CD", 0x4 }, |
| 2958 | { "Headphone", 0x2 }, |
| 2959 | }, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2960 | }, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2961 | { |
| 2962 | .num_items = 4, |
| 2963 | .items = { |
| 2964 | { "Mic/Line", 0x0 }, |
| 2965 | { "CD", 0x4 }, |
| 2966 | { "Headphone", 0x2 }, |
| 2967 | { "Mixer", 0x5 }, |
| 2968 | }, |
| 2969 | }, |
| 2970 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 2971 | }; |
| 2972 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2973 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
| 2974 | * the Fujitsu S702x, but jacks are marked differently. |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2975 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 2976 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
| 2977 | { |
| 2978 | .num_items = 4, |
| 2979 | .items = { |
| 2980 | { "Mic", 0x0 }, |
| 2981 | { "Line", 0x2 }, |
| 2982 | { "CD", 0x4 }, |
| 2983 | { "Headphone", 0x5 }, |
| 2984 | }, |
| 2985 | }, |
| 2986 | { |
| 2987 | .num_items = 5, |
| 2988 | .items = { |
| 2989 | { "Mic", 0x0 }, |
| 2990 | { "Line", 0x2 }, |
| 2991 | { "CD", 0x4 }, |
| 2992 | { "Headphone", 0x6 }, |
| 2993 | { "Mixer", 0x5 }, |
| 2994 | }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 2995 | }, |
| 2996 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2997 | /* |
| 2998 | * This is just place-holder, so there's something for alc_build_pcms to look |
| 2999 | * at when it calculates the maximum number of channels. ALC260 has no mixer |
| 3000 | * element which allows changing the channel mode, so the verb list is |
| 3001 | * never used. |
| 3002 | */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 3003 | static struct hda_channel_mode alc260_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3004 | { 2, NULL }, |
| 3005 | }; |
| 3006 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3007 | |
| 3008 | /* Mixer combinations |
| 3009 | * |
| 3010 | * basic: base_output + input + pc_beep + capture |
| 3011 | * HP: base_output + input + capture_alt |
| 3012 | * HP_3013: hp_3013 + input + capture |
| 3013 | * fujitsu: fujitsu + capture |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3014 | * acer: acer + capture |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3015 | */ |
| 3016 | |
| 3017 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3018 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3019 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3020 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 3021 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
| 3022 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 3023 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
| 3024 | { } /* end */ |
| 3025 | }; |
| 3026 | |
| 3027 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3028 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 3029 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 3030 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 3031 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 3032 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 3033 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 3034 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), |
| 3035 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | { } /* end */ |
| 3037 | }; |
| 3038 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3039 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { |
| 3040 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3041 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3042 | { } /* end */ |
| 3043 | }; |
| 3044 | |
| 3045 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
| 3046 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 3047 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 3048 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), |
| 3049 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), |
| 3050 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 3051 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 3052 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 3053 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3054 | { } /* end */ |
| 3055 | }; |
| 3056 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3057 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
| 3058 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
| 3059 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3060 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3061 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3062 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3063 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3064 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 3065 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 3066 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 3067 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3068 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3069 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3070 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3071 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 3072 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3073 | { } /* end */ |
| 3074 | }; |
| 3075 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3076 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
| 3077 | * versions of the ALC260 don't act on requests to enable mic bias from NID |
| 3078 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 |
| 3079 | * datasheet doesn't mention this restriction. At this stage it's not clear |
| 3080 | * whether this behaviour is intentional or is a hardware bug in chip |
| 3081 | * revisions available in early 2006. Therefore for now allow the |
| 3082 | * "Headphone Jack Mode" control to span all choices, but if it turns out |
| 3083 | * that the lack of mic bias for this NID is intentional we could change the |
| 3084 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 3085 | * |
| 3086 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 |
| 3087 | * don't appear to make the mic bias available from the "line" jack, even |
| 3088 | * though the NID used for this jack (0x14) can supply it. The theory is |
| 3089 | * that perhaps Acer have included blocking capacitors between the ALC260 |
| 3090 | * and the output jack. If this turns out to be the case for all such |
| 3091 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT |
| 3092 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 3093 | */ |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3094 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
| 3095 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 3096 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3097 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3098 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 3099 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 3100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), |
| 3101 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), |
| 3102 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), |
| 3103 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 3104 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 3105 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
| 3106 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3107 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3108 | { } /* end */ |
| 3109 | }; |
| 3110 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3111 | /* capture mixer elements */ |
| 3112 | static struct snd_kcontrol_new alc260_capture_mixer[] = { |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3113 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
| 3114 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3115 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
| 3116 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3117 | { |
| 3118 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3119 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3120 | * So call somewhat different.. |
| 3121 | * FIXME: the controls appear in the "playback" view! |
| 3122 | */ |
| 3123 | /* .name = "Capture Source", */ |
| 3124 | .name = "Input Source", |
| 3125 | .count = 2, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3126 | .info = alc_mux_enum_info, |
| 3127 | .get = alc_mux_enum_get, |
| 3128 | .put = alc_mux_enum_put, |
| 3129 | }, |
| 3130 | { } /* end */ |
| 3131 | }; |
| 3132 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3133 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { |
| 3134 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 3135 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 3136 | { |
| 3137 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3138 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3139 | * So call somewhat different.. |
| 3140 | * FIXME: the controls appear in the "playback" view! |
| 3141 | */ |
| 3142 | /* .name = "Capture Source", */ |
| 3143 | .name = "Input Source", |
| 3144 | .count = 1, |
| 3145 | .info = alc_mux_enum_info, |
| 3146 | .get = alc_mux_enum_get, |
| 3147 | .put = alc_mux_enum_put, |
| 3148 | }, |
| 3149 | { } /* end */ |
| 3150 | }; |
| 3151 | |
| 3152 | /* |
| 3153 | * initialization verbs |
| 3154 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3155 | static struct hda_verb alc260_init_verbs[] = { |
| 3156 | /* Line In pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3157 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3158 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3159 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3160 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3161 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3162 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3163 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3164 | /* LINE-2 is used for line-out in rear */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3165 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | /* select line-out */ |
Jonathan Woithe | fd56f2d | 2006-01-24 10:35:46 +0100 | [diff] [blame] | 3167 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3168 | /* LINE-OUT pin */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3169 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | /* enable HP */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3171 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | /* enable Mono */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3173 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3174 | /* mute capture amp left and right */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3175 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | /* set connection select to line in (default select for this ADC) */ |
| 3177 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3178 | /* mute capture amp left and right */ |
| 3179 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3180 | /* set connection select to line in (default select for this ADC) */ |
| 3181 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3182 | /* set vol=0 Line-Out mixer amp left and right */ |
| 3183 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3184 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3185 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3186 | /* set vol=0 HP mixer amp left and right */ |
| 3187 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3188 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3189 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3190 | /* set vol=0 Mono mixer amp left and right */ |
| 3191 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3192 | /* unmute pin widget amp left and right (no gain on this amp) */ |
| 3193 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3194 | /* unmute LINE-2 out pin */ |
| 3195 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3196 | /* 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] | 3197 | /* mute CD */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3198 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3199 | /* mute Line In */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3200 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3201 | /* mute Mic */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3202 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3203 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 3204 | /* mute Front out path */ |
| 3205 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3206 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3207 | /* mute Headphone out path */ |
| 3208 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3209 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3210 | /* mute Mono out path */ |
| 3211 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3212 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3213 | { } |
| 3214 | }; |
| 3215 | |
Takashi Iwai | 474167d | 2006-05-17 17:17:43 +0200 | [diff] [blame] | 3216 | #if 0 /* should be identical with alc260_init_verbs? */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3217 | static struct hda_verb alc260_hp_init_verbs[] = { |
| 3218 | /* Headphone and output */ |
| 3219 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 3220 | /* mono output */ |
| 3221 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3222 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 3223 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3224 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 3225 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3226 | /* Line In pin widget for input */ |
| 3227 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3228 | /* Line-2 pin widget for output */ |
| 3229 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3230 | /* CD pin widget for input */ |
| 3231 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3232 | /* unmute amp left and right */ |
| 3233 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 3234 | /* set connection select to line in (default select for this ADC) */ |
| 3235 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 3236 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 3237 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3238 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3239 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3240 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 3241 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3242 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3243 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3244 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 3245 | /* unmute CD */ |
| 3246 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 3247 | /* unmute Line In */ |
| 3248 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 3249 | /* unmute Mic */ |
| 3250 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3251 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 3252 | /* Unmute Front out path */ |
| 3253 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3254 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3255 | /* Unmute Headphone out path */ |
| 3256 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3257 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3258 | /* Unmute Mono out path */ |
| 3259 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3260 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3261 | { } |
| 3262 | }; |
Takashi Iwai | 474167d | 2006-05-17 17:17:43 +0200 | [diff] [blame] | 3263 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3264 | |
| 3265 | static struct hda_verb alc260_hp_3013_init_verbs[] = { |
| 3266 | /* Line out and output */ |
| 3267 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3268 | /* mono output */ |
| 3269 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3270 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
| 3271 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3272 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
| 3273 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 3274 | /* Line In pin widget for input */ |
| 3275 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3276 | /* Headphone pin widget for output */ |
| 3277 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 3278 | /* CD pin widget for input */ |
| 3279 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 3280 | /* unmute amp left and right */ |
| 3281 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, |
| 3282 | /* set connection select to line in (default select for this ADC) */ |
| 3283 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 3284 | /* unmute Line-Out mixer amp left and right (volume = 0) */ |
| 3285 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3286 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3287 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3288 | /* unmute HP mixer amp left and right (volume = 0) */ |
| 3289 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 3290 | /* mute pin widget amp left and right (no gain on this amp) */ |
| 3291 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 3292 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
| 3293 | /* unmute CD */ |
| 3294 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 3295 | /* unmute Line In */ |
| 3296 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 3297 | /* unmute Mic */ |
| 3298 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3299 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
| 3300 | /* Unmute Front out path */ |
| 3301 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3302 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3303 | /* Unmute Headphone out path */ |
| 3304 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3305 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3306 | /* Unmute Mono out path */ |
| 3307 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 3308 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, |
| 3309 | { } |
| 3310 | }; |
| 3311 | |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3312 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3313 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
| 3314 | * audio = 0x16, internal speaker = 0x10. |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3315 | */ |
| 3316 | static struct hda_verb alc260_fujitsu_init_verbs[] = { |
| 3317 | /* Disable all GPIOs */ |
| 3318 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, |
| 3319 | /* Internal speaker is connected to headphone pin */ |
| 3320 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3321 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ |
| 3322 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3323 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
| 3324 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3325 | /* Ensure all other unused pins are disabled and muted. */ |
| 3326 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3327 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3328 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3329 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3330 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3331 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3332 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3333 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3334 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3335 | /* Disable digital (SPDIF) pins */ |
| 3336 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3337 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3338 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3339 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
| 3340 | * when acting as an output. |
| 3341 | */ |
| 3342 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3343 | |
| 3344 | /* Start with output sum widgets muted and their output gains at min */ |
Takashi Iwai | 8b33a5a | 2006-02-09 11:57:01 +0100 | [diff] [blame] | 3345 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3346 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3347 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3348 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3349 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3350 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3351 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3352 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3353 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3354 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3355 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
| 3356 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3357 | /* Unmute Line1 pin widget output buffer since it starts as an output. |
| 3358 | * If the pin mode is changed by the user the pin mode control will |
| 3359 | * take care of enabling the pin's input/output buffers as needed. |
| 3360 | * Therefore there's no need to enable the input buffer at this |
| 3361 | * stage. |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3362 | */ |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3363 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3364 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
| 3365 | * mixer ctrl) |
| 3366 | */ |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3367 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3368 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3369 | /* Mute capture amp left and right */ |
| 3370 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3371 | /* Set ADC connection select to match default mixer setting - line |
| 3372 | * in (on mic1 pin) |
| 3373 | */ |
| 3374 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3375 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3376 | /* Do the same for the second ADC: mute capture input amp and |
| 3377 | * set ADC connection to line in (on mic1 pin) |
| 3378 | */ |
| 3379 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3380 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 3381 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3382 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3383 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3384 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3385 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3386 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3387 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3388 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3389 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3390 | {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] | 3391 | |
| 3392 | { } |
Jonathan Woithe | a9430dd | 2005-09-16 19:12:48 +0200 | [diff] [blame] | 3393 | }; |
| 3394 | |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3395 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
| 3396 | * similar laptops (adapted from Fujitsu init verbs). |
| 3397 | */ |
| 3398 | static struct hda_verb alc260_acer_init_verbs[] = { |
| 3399 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and |
| 3400 | * the headphone jack. Turn this on and rely on the standard mute |
| 3401 | * methods whenever the user wants to turn these outputs off. |
| 3402 | */ |
| 3403 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 3404 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 3405 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 3406 | /* Internal speaker/Headphone jack is connected to Line-out pin */ |
| 3407 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3408 | /* Internal microphone/Mic jack is connected to Mic1 pin */ |
| 3409 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
| 3410 | /* Line In jack is connected to Line1 pin */ |
| 3411 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3412 | /* Ensure all other unused pins are disabled and muted. */ |
| 3413 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3414 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3415 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3416 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3417 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3418 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3419 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 3420 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3421 | /* Disable digital (SPDIF) pins */ |
| 3422 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3423 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3424 | |
| 3425 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
| 3426 | * bus when acting as outputs. |
| 3427 | */ |
| 3428 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3429 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3430 | |
| 3431 | /* Start with output sum widgets muted and their output gains at min */ |
| 3432 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3433 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3434 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3435 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3436 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3437 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3438 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3439 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3440 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3441 | |
| 3442 | /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ |
| 3443 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3444 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
| 3445 | * inputs. If the pin mode is changed by the user the pin mode control |
| 3446 | * will take care of enabling the pin's input/output buffers as needed. |
| 3447 | * Therefore there's no need to enable the input buffer at this |
| 3448 | * stage. |
| 3449 | */ |
| 3450 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3451 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3452 | |
| 3453 | /* Mute capture amp left and right */ |
| 3454 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3455 | /* Set ADC connection select to match default mixer setting - mic |
| 3456 | * (on mic1 pin) |
| 3457 | */ |
| 3458 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3459 | |
| 3460 | /* Do similar with the second ADC: mute capture input amp and |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3461 | * set ADC connection to mic to match ALSA's default state. |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3462 | */ |
| 3463 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3464 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3465 | |
| 3466 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3467 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3468 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3469 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3470 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3471 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3472 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3473 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3474 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 3475 | |
| 3476 | { } |
| 3477 | }; |
| 3478 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3479 | /* Test configuration for debugging, modelled after the ALC880 test |
| 3480 | * configuration. |
| 3481 | */ |
| 3482 | #ifdef CONFIG_SND_DEBUG |
| 3483 | static hda_nid_t alc260_test_dac_nids[1] = { |
| 3484 | 0x02, |
| 3485 | }; |
| 3486 | static hda_nid_t alc260_test_adc_nids[2] = { |
| 3487 | 0x04, 0x05, |
| 3488 | }; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3489 | /* For testing the ALC260, each input MUX needs its own definition since |
| 3490 | * the signal assignments are different. This assumes that the first ADC |
| 3491 | * is NID 0x04. |
Jonathan Woithe | 17e7aec | 2006-02-28 11:35:18 +0100 | [diff] [blame] | 3492 | */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3493 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
| 3494 | { |
| 3495 | .num_items = 7, |
| 3496 | .items = { |
| 3497 | { "MIC1 pin", 0x0 }, |
| 3498 | { "MIC2 pin", 0x1 }, |
| 3499 | { "LINE1 pin", 0x2 }, |
| 3500 | { "LINE2 pin", 0x3 }, |
| 3501 | { "CD pin", 0x4 }, |
| 3502 | { "LINE-OUT pin", 0x5 }, |
| 3503 | { "HP-OUT pin", 0x6 }, |
| 3504 | }, |
| 3505 | }, |
| 3506 | { |
| 3507 | .num_items = 8, |
| 3508 | .items = { |
| 3509 | { "MIC1 pin", 0x0 }, |
| 3510 | { "MIC2 pin", 0x1 }, |
| 3511 | { "LINE1 pin", 0x2 }, |
| 3512 | { "LINE2 pin", 0x3 }, |
| 3513 | { "CD pin", 0x4 }, |
| 3514 | { "Mixer", 0x5 }, |
| 3515 | { "LINE-OUT pin", 0x6 }, |
| 3516 | { "HP-OUT pin", 0x7 }, |
| 3517 | }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3518 | }, |
| 3519 | }; |
| 3520 | static struct snd_kcontrol_new alc260_test_mixer[] = { |
| 3521 | /* Output driver widgets */ |
| 3522 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 3523 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
| 3524 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
| 3525 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), |
| 3526 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
| 3527 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), |
| 3528 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3529 | /* Modes for retasking pin widgets |
| 3530 | * Note: the ALC260 doesn't seem to act on requests to enable mic |
| 3531 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't |
| 3532 | * mention this restriction. At this stage it's not clear whether |
| 3533 | * this behaviour is intentional or is a hardware bug in chip |
| 3534 | * revisions available at least up until early 2006. Therefore for |
| 3535 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all |
| 3536 | * choices, but if it turns out that the lack of mic bias for these |
| 3537 | * NIDs is intentional we could change their modes from |
| 3538 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. |
| 3539 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3540 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
| 3541 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), |
| 3542 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), |
| 3543 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), |
| 3544 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), |
| 3545 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), |
| 3546 | |
| 3547 | /* Loopback mixer controls */ |
| 3548 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), |
| 3549 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), |
| 3550 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), |
| 3551 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), |
| 3552 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), |
| 3553 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), |
| 3554 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), |
| 3555 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), |
| 3556 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
| 3557 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
| 3558 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
| 3559 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), |
| 3560 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), |
| 3561 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), |
| 3562 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), |
| 3563 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 3564 | |
| 3565 | /* Controls for GPIO pins, assuming they are configured as outputs */ |
| 3566 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), |
| 3567 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), |
| 3568 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), |
| 3569 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), |
| 3570 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 3571 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
| 3572 | * is ambigious as to which NID is which; testing on laptops which |
| 3573 | * make this output available should provide clarification. |
| 3574 | */ |
| 3575 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), |
| 3576 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), |
| 3577 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3578 | { } /* end */ |
| 3579 | }; |
| 3580 | static struct hda_verb alc260_test_init_verbs[] = { |
Jonathan Woithe | 5c8f858 | 2006-02-28 11:43:27 +0100 | [diff] [blame] | 3581 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
| 3582 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, |
| 3583 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 3584 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, |
| 3585 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3586 | /* Enable retasking pins as output, initially without power amp */ |
| 3587 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3588 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3589 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3590 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3591 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3592 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3593 | |
Jonathan Woithe | 92621f1 | 2006-02-28 11:47:47 +0100 | [diff] [blame] | 3594 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 3595 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 3596 | * payload also sets the generation to 0, output to be in "consumer" |
| 3597 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 3598 | * control. |
| 3599 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3600 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3601 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 3602 | |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3603 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3604 | * OUT1 sum bus when acting as an output. |
| 3605 | */ |
| 3606 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3607 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3608 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3609 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3610 | |
| 3611 | /* Start with output sum widgets muted and their output gains at min */ |
| 3612 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3613 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3614 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3615 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3616 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3617 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3618 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3619 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3620 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3621 | |
Jonathan Woithe | cdcd926 | 2006-02-28 11:36:42 +0100 | [diff] [blame] | 3622 | /* Unmute retasking pin widget output buffers since the default |
| 3623 | * state appears to be output. As the pin mode is changed by the |
| 3624 | * user the pin mode control will take care of enabling the pin's |
| 3625 | * input/output buffers as needed. |
| 3626 | */ |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3627 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3628 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3629 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3630 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3631 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3632 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3633 | /* Also unmute the mono-out pin widget */ |
| 3634 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3635 | |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3636 | /* Mute capture amp left and right */ |
| 3637 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3638 | /* Set ADC connection select to match default mixer setting (mic1 |
| 3639 | * pin) |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3640 | */ |
| 3641 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3642 | |
| 3643 | /* Do the same for the second ADC: mute capture input amp and |
Jonathan Woithe | f7ace40 | 2006-02-28 11:46:14 +0100 | [diff] [blame] | 3644 | * set ADC connection to mic1 pin |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3645 | */ |
| 3646 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3647 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3648 | |
| 3649 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 3650 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 3651 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 3652 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 3653 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 3654 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 3655 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 3656 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 3657 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 3658 | |
| 3659 | { } |
| 3660 | }; |
| 3661 | #endif |
| 3662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3663 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
| 3664 | .substreams = 1, |
| 3665 | .channels_min = 2, |
| 3666 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3667 | }; |
| 3668 | |
| 3669 | static struct hda_pcm_stream alc260_pcm_analog_capture = { |
| 3670 | .substreams = 1, |
| 3671 | .channels_min = 2, |
| 3672 | .channels_max = 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3673 | }; |
| 3674 | |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 3675 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
| 3676 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture |
| 3677 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3678 | /* |
| 3679 | * for BIOS auto-configuration |
| 3680 | */ |
| 3681 | |
| 3682 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
| 3683 | const char *pfx) |
| 3684 | { |
| 3685 | hda_nid_t nid_vol; |
| 3686 | unsigned long vol_val, sw_val; |
| 3687 | char name[32]; |
| 3688 | int err; |
| 3689 | |
| 3690 | if (nid >= 0x0f && nid < 0x11) { |
| 3691 | nid_vol = nid - 0x7; |
| 3692 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 3693 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3694 | } else if (nid == 0x11) { |
| 3695 | nid_vol = nid - 0x7; |
| 3696 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); |
| 3697 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
| 3698 | } else if (nid >= 0x12 && nid <= 0x15) { |
| 3699 | nid_vol = 0x08; |
| 3700 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); |
| 3701 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3702 | } else |
| 3703 | return 0; /* N/A */ |
| 3704 | |
| 3705 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3706 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) |
| 3707 | return err; |
| 3708 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
| 3709 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) |
| 3710 | return err; |
| 3711 | return 1; |
| 3712 | } |
| 3713 | |
| 3714 | /* add playback controls from the parsed DAC table */ |
| 3715 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 3716 | const struct auto_pin_cfg *cfg) |
| 3717 | { |
| 3718 | hda_nid_t nid; |
| 3719 | int err; |
| 3720 | |
| 3721 | spec->multiout.num_dacs = 1; |
| 3722 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 3723 | spec->multiout.dac_nids[0] = 0x02; |
| 3724 | |
| 3725 | nid = cfg->line_out_pins[0]; |
| 3726 | if (nid) { |
| 3727 | err = alc260_add_playback_controls(spec, nid, "Front"); |
| 3728 | if (err < 0) |
| 3729 | return err; |
| 3730 | } |
| 3731 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3732 | nid = cfg->speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3733 | if (nid) { |
| 3734 | err = alc260_add_playback_controls(spec, nid, "Speaker"); |
| 3735 | if (err < 0) |
| 3736 | return err; |
| 3737 | } |
| 3738 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3739 | nid = cfg->hp_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3740 | if (nid) { |
| 3741 | err = alc260_add_playback_controls(spec, nid, "Headphone"); |
| 3742 | if (err < 0) |
| 3743 | return err; |
| 3744 | } |
| 3745 | return 0; |
| 3746 | } |
| 3747 | |
| 3748 | /* create playback/capture controls for input pins */ |
| 3749 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 3750 | const struct auto_pin_cfg *cfg) |
| 3751 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3752 | struct hda_input_mux *imux = &spec->private_imux; |
| 3753 | int i, err, idx; |
| 3754 | |
| 3755 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 3756 | if (cfg->input_pins[i] >= 0x12) { |
| 3757 | idx = cfg->input_pins[i] - 0x12; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3758 | err = new_analog_input(spec, cfg->input_pins[i], |
| 3759 | auto_pin_cfg_labels[i], idx, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3760 | if (err < 0) |
| 3761 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3762 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3763 | imux->items[imux->num_items].index = idx; |
| 3764 | imux->num_items++; |
| 3765 | } |
| 3766 | if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ |
| 3767 | idx = cfg->input_pins[i] - 0x09; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3768 | err = new_analog_input(spec, cfg->input_pins[i], |
| 3769 | auto_pin_cfg_labels[i], idx, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3770 | if (err < 0) |
| 3771 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3772 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3773 | imux->items[imux->num_items].index = idx; |
| 3774 | imux->num_items++; |
| 3775 | } |
| 3776 | } |
| 3777 | return 0; |
| 3778 | } |
| 3779 | |
| 3780 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3781 | hda_nid_t nid, int pin_type, |
| 3782 | int sel_idx) |
| 3783 | { |
| 3784 | /* set as output */ |
| 3785 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 3786 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 3787 | /* need the manual connection? */ |
| 3788 | if (nid >= 0x12) { |
| 3789 | int idx = nid - 0x12; |
| 3790 | snd_hda_codec_write(codec, idx + 0x0b, 0, |
| 3791 | AC_VERB_SET_CONNECT_SEL, sel_idx); |
| 3792 | |
| 3793 | } |
| 3794 | } |
| 3795 | |
| 3796 | static void alc260_auto_init_multi_out(struct hda_codec *codec) |
| 3797 | { |
| 3798 | struct alc_spec *spec = codec->spec; |
| 3799 | hda_nid_t nid; |
| 3800 | |
| 3801 | nid = spec->autocfg.line_out_pins[0]; |
| 3802 | if (nid) |
| 3803 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3804 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3805 | nid = spec->autocfg.speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3806 | if (nid) |
| 3807 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3808 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3809 | nid = spec->autocfg.hp_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3810 | if (nid) |
| 3811 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); |
| 3812 | } |
| 3813 | |
| 3814 | #define ALC260_PIN_CD_NID 0x16 |
| 3815 | static void alc260_auto_init_analog_input(struct hda_codec *codec) |
| 3816 | { |
| 3817 | struct alc_spec *spec = codec->spec; |
| 3818 | int i; |
| 3819 | |
| 3820 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 3821 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 3822 | if (nid >= 0x12) { |
| 3823 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3824 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 3825 | if (nid != ALC260_PIN_CD_NID) |
| 3826 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3827 | AMP_OUT_MUTE); |
| 3828 | } |
| 3829 | } |
| 3830 | } |
| 3831 | |
| 3832 | /* |
| 3833 | * generic initialization of ADC, input mixers and output mixers |
| 3834 | */ |
| 3835 | static struct hda_verb alc260_volume_init_verbs[] = { |
| 3836 | /* |
| 3837 | * Unmute ADC0-1 and set the default input to mic-in |
| 3838 | */ |
| 3839 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3840 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3841 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 3842 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3843 | |
| 3844 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3845 | * mixer widget |
| 3846 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 3847 | * mic (mic 2) |
| 3848 | */ |
| 3849 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 3850 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3851 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3852 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3853 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3854 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 3855 | |
| 3856 | /* |
| 3857 | * Set up output mixers (0x08 - 0x0a) |
| 3858 | */ |
| 3859 | /* set vol=0 to output mixers */ |
| 3860 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3861 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3862 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3863 | /* set up input amps for analog loopback */ |
| 3864 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 3865 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3866 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3867 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3868 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3869 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3870 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3871 | |
| 3872 | { } |
| 3873 | }; |
| 3874 | |
| 3875 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 3876 | { |
| 3877 | struct alc_spec *spec = codec->spec; |
| 3878 | unsigned int wcap; |
| 3879 | int err; |
| 3880 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
| 3881 | |
| 3882 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 3883 | alc260_ignore)) < 0) |
| 3884 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3885 | if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) |
| 3886 | return err; |
| 3887 | if (! spec->kctl_alloc) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3888 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3889 | if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3890 | return err; |
| 3891 | |
| 3892 | spec->multiout.max_channels = 2; |
| 3893 | |
| 3894 | if (spec->autocfg.dig_out_pin) |
| 3895 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; |
| 3896 | if (spec->kctl_alloc) |
| 3897 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 3898 | |
| 3899 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; |
| 3900 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 3901 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3902 | spec->input_mux = &spec->private_imux; |
| 3903 | |
| 3904 | /* check whether NID 0x04 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3905 | wcap = get_wcaps(codec, 0x04); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3906 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 3907 | if (wcap != AC_WID_AUD_IN) { |
| 3908 | spec->adc_nids = alc260_adc_nids_alt; |
| 3909 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); |
| 3910 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3911 | } else { |
| 3912 | spec->adc_nids = alc260_adc_nids; |
| 3913 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); |
| 3914 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3915 | } |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 3916 | spec->num_mixers++; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3917 | |
| 3918 | return 1; |
| 3919 | } |
| 3920 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 3921 | /* additional initialization for auto-configuration model */ |
| 3922 | static void alc260_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3923 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3924 | alc260_auto_init_multi_out(codec); |
| 3925 | alc260_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3926 | } |
| 3927 | |
| 3928 | /* |
| 3929 | * ALC260 configurations |
| 3930 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3931 | static struct hda_board_config alc260_cfg_tbl[] = { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3932 | { .modelname = "basic", .config = ALC260_BASIC }, |
Takashi Iwai | b14e77e | 2006-01-11 18:10:50 +0100 | [diff] [blame] | 3933 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, |
| 3934 | .config = ALC260_BASIC }, /* Sony VAIO */ |
Takashi Iwai | 3206b9c | 2006-05-10 16:33:11 +0200 | [diff] [blame] | 3935 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc, |
| 3936 | .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */ |
Kenneth Crudup | 5e1b151 | 2006-04-28 13:03:48 +0200 | [diff] [blame] | 3937 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd, |
| 3938 | .config = ALC260_BASIC }, /* Sony VAIO */ |
Takashi Iwai | c1fc804 | 2006-03-06 14:17:31 +0100 | [diff] [blame] | 3939 | { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729, |
| 3940 | .config = ALC260_BASIC }, /* CTL Travel Master U553W */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3941 | { .modelname = "hp", .config = ALC260_HP }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 3942 | { .modelname = "hp-3013", .config = ALC260_HP_3013 }, |
Takashi Iwai | 25b6c43 | 2006-08-08 13:01:14 +0200 | [diff] [blame] | 3943 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3944 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, |
Takashi Iwai | 766a6c3 | 2006-05-26 14:58:29 +0200 | [diff] [blame] | 3945 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3946 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, |
| 3947 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, |
| 3948 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, |
| 3949 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, |
| 3950 | { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, |
| 3951 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 3952 | { .modelname = "acer", .config = ALC260_ACER }, |
| 3953 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 3954 | #ifdef CONFIG_SND_DEBUG |
| 3955 | { .modelname = "test", .config = ALC260_TEST }, |
| 3956 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3957 | { .modelname = "auto", .config = ALC260_AUTO }, |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 3958 | {} |
| 3959 | }; |
| 3960 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3961 | static struct alc_config_preset alc260_presets[] = { |
| 3962 | [ALC260_BASIC] = { |
| 3963 | .mixers = { alc260_base_output_mixer, |
| 3964 | alc260_input_mixer, |
| 3965 | alc260_pc_beep_mixer, |
| 3966 | alc260_capture_mixer }, |
| 3967 | .init_verbs = { alc260_init_verbs }, |
| 3968 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3969 | .dac_nids = alc260_dac_nids, |
| 3970 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), |
| 3971 | .adc_nids = alc260_adc_nids, |
| 3972 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3973 | .channel_mode = alc260_modes, |
| 3974 | .input_mux = &alc260_capture_source, |
| 3975 | }, |
| 3976 | [ALC260_HP] = { |
| 3977 | .mixers = { alc260_base_output_mixer, |
| 3978 | alc260_input_mixer, |
| 3979 | alc260_capture_alt_mixer }, |
Takashi Iwai | 474167d | 2006-05-17 17:17:43 +0200 | [diff] [blame] | 3980 | .init_verbs = { alc260_init_verbs }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3981 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3982 | .dac_nids = alc260_dac_nids, |
| 3983 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 3984 | .adc_nids = alc260_hp_adc_nids, |
| 3985 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3986 | .channel_mode = alc260_modes, |
| 3987 | .input_mux = &alc260_capture_source, |
| 3988 | }, |
| 3989 | [ALC260_HP_3013] = { |
| 3990 | .mixers = { alc260_hp_3013_mixer, |
| 3991 | alc260_input_mixer, |
| 3992 | alc260_capture_alt_mixer }, |
| 3993 | .init_verbs = { alc260_hp_3013_init_verbs }, |
| 3994 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 3995 | .dac_nids = alc260_dac_nids, |
| 3996 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), |
| 3997 | .adc_nids = alc260_hp_adc_nids, |
| 3998 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 3999 | .channel_mode = alc260_modes, |
| 4000 | .input_mux = &alc260_capture_source, |
| 4001 | }, |
| 4002 | [ALC260_FUJITSU_S702X] = { |
| 4003 | .mixers = { alc260_fujitsu_mixer, |
| 4004 | alc260_capture_mixer }, |
| 4005 | .init_verbs = { alc260_fujitsu_init_verbs }, |
| 4006 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 4007 | .dac_nids = alc260_dac_nids, |
Jonathan Woithe | d57fdac | 2006-02-28 11:38:35 +0100 | [diff] [blame] | 4008 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
| 4009 | .adc_nids = alc260_dual_adc_nids, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4010 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 4011 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 4012 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
| 4013 | .input_mux = alc260_fujitsu_capture_sources, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4014 | }, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 4015 | [ALC260_ACER] = { |
| 4016 | .mixers = { alc260_acer_mixer, |
| 4017 | alc260_capture_mixer }, |
| 4018 | .init_verbs = { alc260_acer_init_verbs }, |
| 4019 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
| 4020 | .dac_nids = alc260_dac_nids, |
| 4021 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
| 4022 | .adc_nids = alc260_dual_adc_nids, |
| 4023 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 4024 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 4025 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
| 4026 | .input_mux = alc260_acer_capture_sources, |
Jonathan Woithe | 0bfc90e | 2006-02-28 11:45:11 +0100 | [diff] [blame] | 4027 | }, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 4028 | #ifdef CONFIG_SND_DEBUG |
| 4029 | [ALC260_TEST] = { |
| 4030 | .mixers = { alc260_test_mixer, |
| 4031 | alc260_capture_mixer }, |
| 4032 | .init_verbs = { alc260_test_init_verbs }, |
| 4033 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), |
| 4034 | .dac_nids = alc260_test_dac_nids, |
| 4035 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), |
| 4036 | .adc_nids = alc260_test_adc_nids, |
| 4037 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
| 4038 | .channel_mode = alc260_modes, |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 4039 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
| 4040 | .input_mux = alc260_test_capture_sources, |
Jonathan Woithe | 7cf51e4 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 4041 | }, |
| 4042 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4043 | }; |
| 4044 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4045 | static int patch_alc260(struct hda_codec *codec) |
| 4046 | { |
| 4047 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4048 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4050 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4051 | if (spec == NULL) |
| 4052 | return -ENOMEM; |
| 4053 | |
| 4054 | codec->spec = spec; |
| 4055 | |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4056 | board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); |
| 4057 | if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4058 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
| 4059 | "trying auto-probe from BIOS...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4060 | board_config = ALC260_AUTO; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4061 | } |
| 4062 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4063 | if (board_config == ALC260_AUTO) { |
| 4064 | /* automatic parse from the BIOS config */ |
| 4065 | err = alc260_parse_auto_config(codec); |
| 4066 | if (err < 0) { |
| 4067 | alc_free(codec); |
| 4068 | return err; |
| 4069 | } else if (! err) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4070 | printk(KERN_INFO |
| 4071 | "hda_codec: Cannot set up configuration " |
| 4072 | "from BIOS. Using base mode...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4073 | board_config = ALC260_BASIC; |
| 4074 | } |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4075 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4076 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4077 | if (board_config != ALC260_AUTO) |
| 4078 | setup_preset(spec, &alc260_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | |
| 4080 | spec->stream_name_analog = "ALC260 Analog"; |
| 4081 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
| 4082 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
| 4083 | |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 4084 | spec->stream_name_digital = "ALC260 Digital"; |
| 4085 | spec->stream_digital_playback = &alc260_pcm_digital_playback; |
| 4086 | spec->stream_digital_capture = &alc260_pcm_digital_capture; |
| 4087 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4089 | if (board_config == ALC260_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4090 | spec->init_hook = alc260_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4091 | |
| 4092 | return 0; |
| 4093 | } |
| 4094 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4095 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | /* |
| 4097 | * ALC882 support |
| 4098 | * |
| 4099 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 4100 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4101 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4102 | * 6-channel independent captures. |
| 4103 | * |
| 4104 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4105 | * driver yet). |
| 4106 | */ |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4107 | #define ALC882_DIGOUT_NID 0x06 |
| 4108 | #define ALC882_DIGIN_NID 0x0a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4109 | |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 4110 | static struct hda_channel_mode alc882_ch_modes[1] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4111 | { 8, NULL } |
| 4112 | }; |
| 4113 | |
| 4114 | static hda_nid_t alc882_dac_nids[4] = { |
| 4115 | /* front, rear, clfe, rear_surr */ |
| 4116 | 0x02, 0x03, 0x04, 0x05 |
| 4117 | }; |
| 4118 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4119 | /* identical with ALC880 */ |
| 4120 | #define alc882_adc_nids alc880_adc_nids |
| 4121 | #define alc882_adc_nids_alt alc880_adc_nids_alt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4122 | |
| 4123 | /* input MUX */ |
| 4124 | /* FIXME: should be a matrix-type input source selection */ |
| 4125 | |
| 4126 | static struct hda_input_mux alc882_capture_source = { |
| 4127 | .num_items = 4, |
| 4128 | .items = { |
| 4129 | { "Mic", 0x0 }, |
| 4130 | { "Front Mic", 0x1 }, |
| 4131 | { "Line", 0x2 }, |
| 4132 | { "CD", 0x4 }, |
| 4133 | }, |
| 4134 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4135 | #define alc882_mux_enum_info alc_mux_enum_info |
| 4136 | #define alc882_mux_enum_get alc_mux_enum_get |
| 4137 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 4138 | 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] | 4139 | { |
| 4140 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4141 | struct alc_spec *spec = codec->spec; |
| 4142 | const struct hda_input_mux *imux = spec->input_mux; |
| 4143 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 4144 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; |
| 4145 | hda_nid_t nid = capture_mixers[adc_idx]; |
| 4146 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
| 4147 | unsigned int i, idx; |
| 4148 | |
| 4149 | idx = ucontrol->value.enumerated.item[0]; |
| 4150 | if (idx >= imux->num_items) |
| 4151 | idx = imux->num_items - 1; |
| 4152 | if (*cur_val == idx && ! codec->in_resume) |
| 4153 | return 0; |
| 4154 | for (i = 0; i < imux->num_items; i++) { |
| 4155 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; |
| 4156 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4157 | v | (imux->items[i].index << 8)); |
| 4158 | } |
| 4159 | *cur_val = idx; |
| 4160 | return 1; |
| 4161 | } |
| 4162 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4163 | /* |
| 4164 | * 6ch mode |
| 4165 | */ |
| 4166 | static struct hda_verb alc882_sixstack_ch6_init[] = { |
| 4167 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4168 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4169 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4170 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4171 | { } /* end */ |
| 4172 | }; |
| 4173 | |
| 4174 | /* |
| 4175 | * 8ch mode |
| 4176 | */ |
| 4177 | static struct hda_verb alc882_sixstack_ch8_init[] = { |
| 4178 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4179 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4180 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4181 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4182 | { } /* end */ |
| 4183 | }; |
| 4184 | |
| 4185 | static struct hda_channel_mode alc882_sixstack_modes[2] = { |
| 4186 | { 6, alc882_sixstack_ch6_init }, |
| 4187 | { 8, alc882_sixstack_ch8_init }, |
| 4188 | }; |
| 4189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
| 4191 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
| 4192 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 4193 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4194 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4195 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4196 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4197 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4198 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 4199 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4200 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 4201 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4202 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 4203 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4204 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 4205 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4206 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4207 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4208 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4209 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4210 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4211 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 4212 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 4213 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4214 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4215 | { } /* end */ |
| 4216 | }; |
| 4217 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4218 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
| 4219 | { |
| 4220 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4221 | .name = "Channel Mode", |
| 4222 | .info = alc_ch_mode_info, |
| 4223 | .get = alc_ch_mode_get, |
| 4224 | .put = alc_ch_mode_put, |
| 4225 | }, |
| 4226 | { } /* end */ |
| 4227 | }; |
| 4228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4229 | static struct hda_verb alc882_init_verbs[] = { |
| 4230 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4231 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4232 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4233 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4234 | /* Rear mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4235 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4236 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4237 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4238 | /* CLFE mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4239 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4240 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4241 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4242 | /* Side mixer */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4243 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4244 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4245 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4246 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4247 | /* Front Pin: output 0 (0x0c) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4248 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4249 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4250 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4251 | /* Rear Pin: output 1 (0x0d) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4252 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4253 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4254 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4255 | /* CLFE Pin: output 2 (0x0e) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4256 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4257 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4259 | /* Side Pin: output 3 (0x0f) */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4260 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4261 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4262 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4263 | /* Mic (rear) pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4264 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4265 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4266 | /* Front Mic pin: input vref at 80% */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 4267 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4268 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4269 | /* Line In pin: input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4270 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4271 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4272 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ |
| 4273 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4274 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4275 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4276 | /* CD pin widget for input */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4277 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4278 | |
| 4279 | /* FIXME: use matrix-type input source selection */ |
| 4280 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4281 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4282 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4283 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4284 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4285 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4286 | /* Input mixer2 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4287 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4288 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4289 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4290 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4291 | /* Input mixer3 */ |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4292 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4293 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 4294 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 4295 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 4296 | /* ADC1: mute amp left and right */ |
| 4297 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4298 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4299 | /* ADC2: mute amp left and right */ |
| 4300 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4301 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | 05acb86 | 2005-06-10 19:50:25 +0200 | [diff] [blame] | 4302 | /* ADC3: mute amp left and right */ |
| 4303 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
Takashi Iwai | 71fe7b8 | 2005-05-25 18:11:40 +0200 | [diff] [blame] | 4304 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4305 | |
| 4306 | { } |
| 4307 | }; |
| 4308 | |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 4309 | static struct hda_verb alc882_eapd_verbs[] = { |
| 4310 | /* change to EAPD mode */ |
| 4311 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 4312 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
| 4313 | { } |
| 4314 | }; |
| 4315 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4316 | /* |
| 4317 | * generic initialization of ADC, input mixers and output mixers |
| 4318 | */ |
| 4319 | static struct hda_verb alc882_auto_init_verbs[] = { |
| 4320 | /* |
| 4321 | * Unmute ADC0-2 and set the default input to mic-in |
| 4322 | */ |
| 4323 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4324 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4325 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4326 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4327 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4328 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4329 | |
| 4330 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 4331 | * mixer widget |
| 4332 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 4333 | * mic (mic 2) |
| 4334 | */ |
| 4335 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 4336 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4337 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4338 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4339 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4340 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4341 | |
| 4342 | /* |
| 4343 | * Set up output mixers (0x0c - 0x0f) |
| 4344 | */ |
| 4345 | /* set vol=0 to output mixers */ |
| 4346 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4347 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4348 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4349 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4350 | /* set up input amps for analog loopback */ |
| 4351 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 4352 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4353 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4354 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4355 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4356 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4357 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4358 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4359 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4360 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4361 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4362 | |
| 4363 | /* FIXME: use matrix-type input source selection */ |
| 4364 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4365 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 4366 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4367 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4368 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4369 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4370 | /* Input mixer2 */ |
| 4371 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4372 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4373 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4374 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4375 | /* Input mixer3 */ |
| 4376 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 4377 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 4378 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 4379 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 4380 | |
| 4381 | { } |
| 4382 | }; |
| 4383 | |
| 4384 | /* capture mixer elements */ |
| 4385 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { |
| 4386 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4387 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4388 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 4389 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 4390 | { |
| 4391 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4392 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4393 | * So call somewhat different.. |
| 4394 | * FIXME: the controls appear in the "playback" view! |
| 4395 | */ |
| 4396 | /* .name = "Capture Source", */ |
| 4397 | .name = "Input Source", |
| 4398 | .count = 2, |
| 4399 | .info = alc882_mux_enum_info, |
| 4400 | .get = alc882_mux_enum_get, |
| 4401 | .put = alc882_mux_enum_put, |
| 4402 | }, |
| 4403 | { } /* end */ |
| 4404 | }; |
| 4405 | |
| 4406 | static struct snd_kcontrol_new alc882_capture_mixer[] = { |
| 4407 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
| 4408 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
| 4409 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
| 4410 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
| 4411 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), |
| 4412 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), |
| 4413 | { |
| 4414 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4415 | /* The multiple "Capture Source" controls confuse alsamixer |
| 4416 | * So call somewhat different.. |
| 4417 | * FIXME: the controls appear in the "playback" view! |
| 4418 | */ |
| 4419 | /* .name = "Capture Source", */ |
| 4420 | .name = "Input Source", |
| 4421 | .count = 3, |
| 4422 | .info = alc882_mux_enum_info, |
| 4423 | .get = alc882_mux_enum_get, |
| 4424 | .put = alc882_mux_enum_put, |
| 4425 | }, |
| 4426 | { } /* end */ |
| 4427 | }; |
| 4428 | |
| 4429 | /* pcm configuration: identiacal with ALC880 */ |
| 4430 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback |
| 4431 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture |
| 4432 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback |
| 4433 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture |
| 4434 | |
| 4435 | /* |
| 4436 | * configuration and preset |
| 4437 | */ |
| 4438 | static struct hda_board_config alc882_cfg_tbl[] = { |
Takashi Iwai | 1494a92 | 2006-01-31 10:58:46 +0100 | [diff] [blame] | 4439 | { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, |
| 4440 | { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4441 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, |
| 4442 | .config = ALC882_6ST_DIG }, /* MSI */ |
| 4443 | { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, |
| 4444 | .config = ALC882_6ST_DIG }, /* Foxconn */ |
| 4445 | { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, |
| 4446 | .config = ALC882_6ST_DIG }, /* ECS to Intel*/ |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 4447 | { .modelname = "arima", .config = ALC882_ARIMA }, |
| 4448 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054, |
| 4449 | .config = ALC882_ARIMA }, /* Arima W820Di1 */ |
Takashi Iwai | 1494a92 | 2006-01-31 10:58:46 +0100 | [diff] [blame] | 4450 | { .modelname = "auto", .config = ALC882_AUTO }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4451 | {} |
| 4452 | }; |
| 4453 | |
| 4454 | static struct alc_config_preset alc882_presets[] = { |
| 4455 | [ALC882_3ST_DIG] = { |
| 4456 | .mixers = { alc882_base_mixer }, |
| 4457 | .init_verbs = { alc882_init_verbs }, |
| 4458 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 4459 | .dac_nids = alc882_dac_nids, |
| 4460 | .dig_out_nid = ALC882_DIGOUT_NID, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4461 | .dig_in_nid = ALC882_DIGIN_NID, |
| 4462 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), |
| 4463 | .channel_mode = alc882_ch_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 4464 | .need_dac_fix = 1, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4465 | .input_mux = &alc882_capture_source, |
| 4466 | }, |
| 4467 | [ALC882_6ST_DIG] = { |
| 4468 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, |
| 4469 | .init_verbs = { alc882_init_verbs }, |
| 4470 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 4471 | .dac_nids = alc882_dac_nids, |
| 4472 | .dig_out_nid = ALC882_DIGOUT_NID, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4473 | .dig_in_nid = ALC882_DIGIN_NID, |
| 4474 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), |
| 4475 | .channel_mode = alc882_sixstack_modes, |
| 4476 | .input_mux = &alc882_capture_source, |
| 4477 | }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 4478 | [ALC882_ARIMA] = { |
| 4479 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, |
| 4480 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, |
| 4481 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), |
| 4482 | .dac_nids = alc882_dac_nids, |
| 4483 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), |
| 4484 | .channel_mode = alc882_sixstack_modes, |
| 4485 | .input_mux = &alc882_capture_source, |
| 4486 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4487 | }; |
| 4488 | |
| 4489 | |
| 4490 | /* |
| 4491 | * BIOS auto configuration |
| 4492 | */ |
| 4493 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, |
| 4494 | hda_nid_t nid, int pin_type, |
| 4495 | int dac_idx) |
| 4496 | { |
| 4497 | /* set as output */ |
| 4498 | struct alc_spec *spec = codec->spec; |
| 4499 | int idx; |
| 4500 | |
| 4501 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
| 4502 | idx = 4; |
| 4503 | else |
| 4504 | idx = spec->multiout.dac_nids[dac_idx] - 2; |
| 4505 | |
| 4506 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 4507 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 4508 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
| 4509 | |
| 4510 | } |
| 4511 | |
| 4512 | static void alc882_auto_init_multi_out(struct hda_codec *codec) |
| 4513 | { |
| 4514 | struct alc_spec *spec = codec->spec; |
| 4515 | int i; |
| 4516 | |
| 4517 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4518 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4519 | if (nid) |
| 4520 | alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 4521 | } |
| 4522 | } |
| 4523 | |
| 4524 | static void alc882_auto_init_hp_out(struct hda_codec *codec) |
| 4525 | { |
| 4526 | struct alc_spec *spec = codec->spec; |
| 4527 | hda_nid_t pin; |
| 4528 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4529 | pin = spec->autocfg.hp_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4530 | if (pin) /* connect to front */ |
| 4531 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ |
| 4532 | } |
| 4533 | |
| 4534 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) |
| 4535 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID |
| 4536 | |
| 4537 | static void alc882_auto_init_analog_input(struct hda_codec *codec) |
| 4538 | { |
| 4539 | struct alc_spec *spec = codec->spec; |
| 4540 | int i; |
| 4541 | |
| 4542 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 4543 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 4544 | if (alc882_is_input_pin(nid)) { |
| 4545 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4546 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 4547 | if (nid != ALC882_PIN_CD_NID) |
| 4548 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4549 | AMP_OUT_MUTE); |
| 4550 | } |
| 4551 | } |
| 4552 | } |
| 4553 | |
| 4554 | /* almost identical with ALC880 parser... */ |
| 4555 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 4556 | { |
| 4557 | struct alc_spec *spec = codec->spec; |
| 4558 | int err = alc880_parse_auto_config(codec); |
| 4559 | |
| 4560 | if (err < 0) |
| 4561 | return err; |
Takashi Iwai | c5f2ea0 | 2005-12-06 18:54:31 +0100 | [diff] [blame] | 4562 | else if (err > 0) |
| 4563 | /* hack - override the init verbs */ |
| 4564 | spec->init_verbs[0] = alc882_auto_init_verbs; |
| 4565 | return err; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4566 | } |
| 4567 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4568 | /* additional initialization for auto-configuration model */ |
| 4569 | static void alc882_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4570 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4571 | alc882_auto_init_multi_out(codec); |
| 4572 | alc882_auto_init_hp_out(codec); |
| 4573 | alc882_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4574 | } |
| 4575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4576 | static int patch_alc882(struct hda_codec *codec) |
| 4577 | { |
| 4578 | struct alc_spec *spec; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4579 | int err, board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4580 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4581 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4582 | if (spec == NULL) |
| 4583 | return -ENOMEM; |
| 4584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4585 | codec->spec = spec; |
| 4586 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4587 | board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4588 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4589 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4590 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
| 4591 | "trying auto-probe from BIOS...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4592 | board_config = ALC882_AUTO; |
| 4593 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 4594 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4595 | if (board_config == ALC882_AUTO) { |
| 4596 | /* automatic parse from the BIOS config */ |
| 4597 | err = alc882_parse_auto_config(codec); |
| 4598 | if (err < 0) { |
| 4599 | alc_free(codec); |
| 4600 | return err; |
| 4601 | } else if (! err) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4602 | printk(KERN_INFO |
| 4603 | "hda_codec: Cannot set up configuration " |
| 4604 | "from BIOS. Using base mode...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4605 | board_config = ALC882_3ST_DIG; |
| 4606 | } |
| 4607 | } |
| 4608 | |
| 4609 | if (board_config != ALC882_AUTO) |
| 4610 | setup_preset(spec, &alc882_presets[board_config]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4611 | |
| 4612 | spec->stream_name_analog = "ALC882 Analog"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4613 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
| 4614 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4615 | |
| 4616 | spec->stream_name_digital = "ALC882 Digital"; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4617 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
| 4618 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4619 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4620 | if (! spec->adc_nids && spec->input_mux) { |
| 4621 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 4622 | unsigned int wcap = get_wcaps(codec, 0x07); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4623 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 4624 | if (wcap != AC_WID_AUD_IN) { |
| 4625 | spec->adc_nids = alc882_adc_nids_alt; |
| 4626 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); |
| 4627 | spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; |
| 4628 | spec->num_mixers++; |
| 4629 | } else { |
| 4630 | spec->adc_nids = alc882_adc_nids; |
| 4631 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); |
| 4632 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; |
| 4633 | spec->num_mixers++; |
| 4634 | } |
| 4635 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4636 | |
| 4637 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4638 | if (board_config == ALC882_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 4639 | spec->init_hook = alc882_auto_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4640 | |
| 4641 | return 0; |
| 4642 | } |
| 4643 | |
| 4644 | /* |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 4645 | * ALC883 support |
| 4646 | * |
| 4647 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible |
| 4648 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4649 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4650 | * 6-channel independent captures. |
| 4651 | * |
| 4652 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4653 | * driver yet). |
| 4654 | */ |
| 4655 | #define ALC883_DIGOUT_NID 0x06 |
| 4656 | #define ALC883_DIGIN_NID 0x0a |
| 4657 | |
| 4658 | static hda_nid_t alc883_dac_nids[4] = { |
| 4659 | /* front, rear, clfe, rear_surr */ |
| 4660 | 0x02, 0x04, 0x03, 0x05 |
| 4661 | }; |
| 4662 | |
| 4663 | static hda_nid_t alc883_adc_nids[2] = { |
| 4664 | /* ADC1-2 */ |
| 4665 | 0x08, 0x09, |
| 4666 | }; |
| 4667 | /* input MUX */ |
| 4668 | /* FIXME: should be a matrix-type input source selection */ |
| 4669 | |
| 4670 | static struct hda_input_mux alc883_capture_source = { |
| 4671 | .num_items = 4, |
| 4672 | .items = { |
| 4673 | { "Mic", 0x0 }, |
| 4674 | { "Front Mic", 0x1 }, |
| 4675 | { "Line", 0x2 }, |
| 4676 | { "CD", 0x4 }, |
| 4677 | }, |
| 4678 | }; |
| 4679 | #define alc883_mux_enum_info alc_mux_enum_info |
| 4680 | #define alc883_mux_enum_get alc_mux_enum_get |
| 4681 | |
| 4682 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 4683 | struct snd_ctl_elem_value *ucontrol) |
| 4684 | { |
| 4685 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4686 | struct alc_spec *spec = codec->spec; |
| 4687 | const struct hda_input_mux *imux = spec->input_mux; |
| 4688 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 4689 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; |
| 4690 | hda_nid_t nid = capture_mixers[adc_idx]; |
| 4691 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
| 4692 | unsigned int i, idx; |
| 4693 | |
| 4694 | idx = ucontrol->value.enumerated.item[0]; |
| 4695 | if (idx >= imux->num_items) |
| 4696 | idx = imux->num_items - 1; |
| 4697 | if (*cur_val == idx && ! codec->in_resume) |
| 4698 | return 0; |
| 4699 | for (i = 0; i < imux->num_items; i++) { |
| 4700 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; |
| 4701 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4702 | v | (imux->items[i].index << 8)); |
| 4703 | } |
| 4704 | *cur_val = idx; |
| 4705 | return 1; |
| 4706 | } |
| 4707 | /* |
| 4708 | * 2ch mode |
| 4709 | */ |
| 4710 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { |
| 4711 | { 2, NULL } |
| 4712 | }; |
| 4713 | |
| 4714 | /* |
| 4715 | * 2ch mode |
| 4716 | */ |
| 4717 | static struct hda_verb alc883_3ST_ch2_init[] = { |
| 4718 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 4719 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 4720 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 4721 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 4722 | { } /* end */ |
| 4723 | }; |
| 4724 | |
| 4725 | /* |
| 4726 | * 6ch mode |
| 4727 | */ |
| 4728 | static struct hda_verb alc883_3ST_ch6_init[] = { |
| 4729 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4730 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 4731 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, |
| 4732 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4733 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 4734 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 4735 | { } /* end */ |
| 4736 | }; |
| 4737 | |
| 4738 | static struct hda_channel_mode alc883_3ST_6ch_modes[2] = { |
| 4739 | { 2, alc883_3ST_ch2_init }, |
| 4740 | { 6, alc883_3ST_ch6_init }, |
| 4741 | }; |
| 4742 | |
| 4743 | /* |
| 4744 | * 6ch mode |
| 4745 | */ |
| 4746 | static struct hda_verb alc883_sixstack_ch6_init[] = { |
| 4747 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 4748 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4749 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4750 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4751 | { } /* end */ |
| 4752 | }; |
| 4753 | |
| 4754 | /* |
| 4755 | * 8ch mode |
| 4756 | */ |
| 4757 | static struct hda_verb alc883_sixstack_ch8_init[] = { |
| 4758 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4759 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4760 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4761 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 4762 | { } /* end */ |
| 4763 | }; |
| 4764 | |
| 4765 | static struct hda_channel_mode alc883_sixstack_modes[2] = { |
| 4766 | { 6, alc883_sixstack_ch6_init }, |
| 4767 | { 8, alc883_sixstack_ch8_init }, |
| 4768 | }; |
| 4769 | |
| 4770 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
| 4771 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
| 4772 | */ |
| 4773 | |
| 4774 | static struct snd_kcontrol_new alc883_base_mixer[] = { |
| 4775 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4776 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 4777 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| 4778 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| 4779 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 4780 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 4781 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 4782 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
| 4783 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
| 4784 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
| 4785 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 4786 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4787 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4788 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4789 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4790 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4791 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4792 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 4793 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 4794 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4795 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 4796 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4797 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4798 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 4799 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 4800 | { |
| 4801 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4802 | /* .name = "Capture Source", */ |
| 4803 | .name = "Input Source", |
| 4804 | .count = 2, |
| 4805 | .info = alc883_mux_enum_info, |
| 4806 | .get = alc883_mux_enum_get, |
| 4807 | .put = alc883_mux_enum_put, |
| 4808 | }, |
| 4809 | { } /* end */ |
| 4810 | }; |
| 4811 | |
| 4812 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
| 4813 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4814 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 4815 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 4816 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4817 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4818 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4819 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4820 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4821 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4822 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 4823 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 4824 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4825 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 4826 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4827 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4828 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 4829 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 4830 | { |
| 4831 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4832 | /* .name = "Capture Source", */ |
| 4833 | .name = "Input Source", |
| 4834 | .count = 2, |
| 4835 | .info = alc883_mux_enum_info, |
| 4836 | .get = alc883_mux_enum_get, |
| 4837 | .put = alc883_mux_enum_put, |
| 4838 | }, |
| 4839 | { } /* end */ |
| 4840 | }; |
| 4841 | |
| 4842 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
| 4843 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 4844 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
| 4845 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
| 4846 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
| 4847 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
| 4848 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 4849 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
| 4850 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
| 4851 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 4852 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 4853 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 4854 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 4855 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 4856 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 4857 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 4858 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
| 4859 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
| 4860 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 4861 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 4862 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 4863 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 4864 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 4865 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 4866 | { |
| 4867 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4868 | /* .name = "Capture Source", */ |
| 4869 | .name = "Input Source", |
| 4870 | .count = 2, |
| 4871 | .info = alc883_mux_enum_info, |
| 4872 | .get = alc883_mux_enum_get, |
| 4873 | .put = alc883_mux_enum_put, |
| 4874 | }, |
| 4875 | { } /* end */ |
| 4876 | }; |
| 4877 | |
| 4878 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
| 4879 | { |
| 4880 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4881 | .name = "Channel Mode", |
| 4882 | .info = alc_ch_mode_info, |
| 4883 | .get = alc_ch_mode_get, |
| 4884 | .put = alc_ch_mode_put, |
| 4885 | }, |
| 4886 | { } /* end */ |
| 4887 | }; |
| 4888 | |
| 4889 | static struct hda_verb alc883_init_verbs[] = { |
| 4890 | /* ADC1: mute amp left and right */ |
| 4891 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4892 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4893 | /* ADC2: mute amp left and right */ |
| 4894 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4895 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4896 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
| 4897 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4898 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4899 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4900 | /* Rear mixer */ |
| 4901 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4902 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4903 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4904 | /* CLFE mixer */ |
| 4905 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4906 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4907 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4908 | /* Side mixer */ |
| 4909 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4910 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 4911 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4912 | |
| 4913 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4914 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4915 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4916 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4917 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4918 | |
| 4919 | /* Front Pin: output 0 (0x0c) */ |
| 4920 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4921 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4922 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4923 | /* Rear Pin: output 1 (0x0d) */ |
| 4924 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4925 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4926 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 4927 | /* CLFE Pin: output 2 (0x0e) */ |
| 4928 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4929 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4930 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 4931 | /* Side Pin: output 3 (0x0f) */ |
| 4932 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 4933 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4934 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 4935 | /* Mic (rear) pin: input vref at 80% */ |
| 4936 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4937 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4938 | /* Front Mic pin: input vref at 80% */ |
| 4939 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 4940 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4941 | /* Line In pin: input */ |
| 4942 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4943 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 4944 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ |
| 4945 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 4946 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 4947 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4948 | /* CD pin widget for input */ |
| 4949 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 4950 | |
| 4951 | /* FIXME: use matrix-type input source selection */ |
| 4952 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 4953 | /* Input mixer2 */ |
| 4954 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4955 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4956 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4957 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4958 | /* Input mixer3 */ |
| 4959 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4960 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4961 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4962 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4963 | { } |
| 4964 | }; |
| 4965 | |
| 4966 | /* |
| 4967 | * generic initialization of ADC, input mixers and output mixers |
| 4968 | */ |
| 4969 | static struct hda_verb alc883_auto_init_verbs[] = { |
| 4970 | /* |
| 4971 | * Unmute ADC0-2 and set the default input to mic-in |
| 4972 | */ |
| 4973 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4974 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4975 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 4976 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4977 | |
| 4978 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 4979 | * mixer widget |
| 4980 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 4981 | * mic (mic 2) |
| 4982 | */ |
| 4983 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 4984 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4985 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 4986 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 4987 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 4988 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 4989 | |
| 4990 | /* |
| 4991 | * Set up output mixers (0x0c - 0x0f) |
| 4992 | */ |
| 4993 | /* set vol=0 to output mixers */ |
| 4994 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4995 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4996 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4997 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 4998 | /* set up input amps for analog loopback */ |
| 4999 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 5000 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5001 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5002 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5003 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5004 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5005 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5006 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5007 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5008 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5009 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5010 | |
| 5011 | /* FIXME: use matrix-type input source selection */ |
| 5012 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 5013 | /* Input mixer1 */ |
| 5014 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5015 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5016 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5017 | //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5018 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 5019 | /* Input mixer2 */ |
| 5020 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5021 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5022 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5023 | //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5024 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 5025 | |
| 5026 | { } |
| 5027 | }; |
| 5028 | |
| 5029 | /* capture mixer elements */ |
| 5030 | static struct snd_kcontrol_new alc883_capture_mixer[] = { |
| 5031 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 5032 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 5033 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), |
| 5034 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), |
| 5035 | { |
| 5036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5037 | /* The multiple "Capture Source" controls confuse alsamixer |
| 5038 | * So call somewhat different.. |
| 5039 | * FIXME: the controls appear in the "playback" view! |
| 5040 | */ |
| 5041 | /* .name = "Capture Source", */ |
| 5042 | .name = "Input Source", |
| 5043 | .count = 2, |
| 5044 | .info = alc882_mux_enum_info, |
| 5045 | .get = alc882_mux_enum_get, |
| 5046 | .put = alc882_mux_enum_put, |
| 5047 | }, |
| 5048 | { } /* end */ |
| 5049 | }; |
| 5050 | |
| 5051 | /* pcm configuration: identiacal with ALC880 */ |
| 5052 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback |
| 5053 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture |
| 5054 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
| 5055 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture |
| 5056 | |
| 5057 | /* |
| 5058 | * configuration and preset |
| 5059 | */ |
| 5060 | static struct hda_board_config alc883_cfg_tbl[] = { |
| 5061 | { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 5062 | { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG }, |
| 5063 | { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, |
| 5064 | .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/ |
| 5065 | { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch }, |
| 5066 | { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d, |
| 5067 | .config = ALC883_3ST_6ch }, |
Tobin Davis | 2aaeee8 | 2006-08-21 19:01:12 +0200 | [diff] [blame] | 5068 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601, |
| 5069 | .config = ALC883_3ST_6ch }, /* D102GGC */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5070 | { .modelname = "6stack-dig", .config = ALC883_6ST_DIG }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5071 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, |
| 5072 | .config = ALC883_6ST_DIG }, /* MSI */ |
| 5073 | { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, |
| 5074 | .config = ALC883_6ST_DIG }, /* Foxconn */ |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 5075 | { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD }, |
Vladimir Avdonin | bab282b | 2006-08-22 13:31:58 +0200 | [diff] [blame] | 5076 | { .modelname = "acer", .config = ALC883_ACER }, |
| 5077 | { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/, |
| 5078 | .config = ALC883_ACER }, |
Tobin Davis | 7a99795 | 2006-09-26 15:30:10 +0200 | [diff] [blame] | 5079 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102, |
| 5080 | .config = ALC883_ACER }, |
| 5081 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f, |
| 5082 | .config = ALC883_ACER }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5083 | { .modelname = "auto", .config = ALC883_AUTO }, |
| 5084 | {} |
| 5085 | }; |
| 5086 | |
| 5087 | static struct alc_config_preset alc883_presets[] = { |
| 5088 | [ALC883_3ST_2ch_DIG] = { |
| 5089 | .mixers = { alc883_3ST_2ch_mixer }, |
| 5090 | .init_verbs = { alc883_init_verbs }, |
| 5091 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5092 | .dac_nids = alc883_dac_nids, |
| 5093 | .dig_out_nid = ALC883_DIGOUT_NID, |
| 5094 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5095 | .adc_nids = alc883_adc_nids, |
| 5096 | .dig_in_nid = ALC883_DIGIN_NID, |
| 5097 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
| 5098 | .channel_mode = alc883_3ST_2ch_modes, |
| 5099 | .input_mux = &alc883_capture_source, |
| 5100 | }, |
| 5101 | [ALC883_3ST_6ch_DIG] = { |
| 5102 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
| 5103 | .init_verbs = { alc883_init_verbs }, |
| 5104 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5105 | .dac_nids = alc883_dac_nids, |
| 5106 | .dig_out_nid = ALC883_DIGOUT_NID, |
| 5107 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5108 | .adc_nids = alc883_adc_nids, |
| 5109 | .dig_in_nid = ALC883_DIGIN_NID, |
| 5110 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
| 5111 | .channel_mode = alc883_3ST_6ch_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 5112 | .need_dac_fix = 1, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5113 | .input_mux = &alc883_capture_source, |
| 5114 | }, |
| 5115 | [ALC883_3ST_6ch] = { |
| 5116 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
| 5117 | .init_verbs = { alc883_init_verbs }, |
| 5118 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5119 | .dac_nids = alc883_dac_nids, |
| 5120 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5121 | .adc_nids = alc883_adc_nids, |
| 5122 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
| 5123 | .channel_mode = alc883_3ST_6ch_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 5124 | .need_dac_fix = 1, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5125 | .input_mux = &alc883_capture_source, |
| 5126 | }, |
| 5127 | [ALC883_6ST_DIG] = { |
| 5128 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
| 5129 | .init_verbs = { alc883_init_verbs }, |
| 5130 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5131 | .dac_nids = alc883_dac_nids, |
| 5132 | .dig_out_nid = ALC883_DIGOUT_NID, |
| 5133 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5134 | .adc_nids = alc883_adc_nids, |
| 5135 | .dig_in_nid = ALC883_DIGIN_NID, |
| 5136 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
| 5137 | .channel_mode = alc883_sixstack_modes, |
| 5138 | .input_mux = &alc883_capture_source, |
| 5139 | }, |
| 5140 | [ALC888_DEMO_BOARD] = { |
| 5141 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
| 5142 | .init_verbs = { alc883_init_verbs }, |
| 5143 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5144 | .dac_nids = alc883_dac_nids, |
| 5145 | .dig_out_nid = ALC883_DIGOUT_NID, |
| 5146 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5147 | .adc_nids = alc883_adc_nids, |
| 5148 | .dig_in_nid = ALC883_DIGIN_NID, |
| 5149 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
| 5150 | .channel_mode = alc883_sixstack_modes, |
| 5151 | .input_mux = &alc883_capture_source, |
| 5152 | }, |
Vladimir Avdonin | bab282b | 2006-08-22 13:31:58 +0200 | [diff] [blame] | 5153 | [ALC883_ACER] = { |
| 5154 | .mixers = { alc883_base_mixer, |
| 5155 | alc883_chmode_mixer }, |
| 5156 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
| 5157 | * and the headphone jack. Turn this on and rely on the |
| 5158 | * standard mute methods whenever the user wants to turn |
| 5159 | * these outputs off. |
| 5160 | */ |
| 5161 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, |
| 5162 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
| 5163 | .dac_nids = alc883_dac_nids, |
| 5164 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), |
| 5165 | .adc_nids = alc883_adc_nids, |
| 5166 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
| 5167 | .channel_mode = alc883_3ST_2ch_modes, |
| 5168 | .input_mux = &alc883_capture_source, |
| 5169 | }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5170 | }; |
| 5171 | |
| 5172 | |
| 5173 | /* |
| 5174 | * BIOS auto configuration |
| 5175 | */ |
| 5176 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, |
| 5177 | hda_nid_t nid, int pin_type, |
| 5178 | int dac_idx) |
| 5179 | { |
| 5180 | /* set as output */ |
| 5181 | struct alc_spec *spec = codec->spec; |
| 5182 | int idx; |
| 5183 | |
| 5184 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
| 5185 | idx = 4; |
| 5186 | else |
| 5187 | idx = spec->multiout.dac_nids[dac_idx] - 2; |
| 5188 | |
| 5189 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5190 | pin_type); |
| 5191 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 5192 | AMP_OUT_UNMUTE); |
| 5193 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
| 5194 | |
| 5195 | } |
| 5196 | |
| 5197 | static void alc883_auto_init_multi_out(struct hda_codec *codec) |
| 5198 | { |
| 5199 | struct alc_spec *spec = codec->spec; |
| 5200 | int i; |
| 5201 | |
| 5202 | for (i = 0; i <= HDA_SIDE; i++) { |
| 5203 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 5204 | if (nid) |
| 5205 | alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 5206 | } |
| 5207 | } |
| 5208 | |
| 5209 | static void alc883_auto_init_hp_out(struct hda_codec *codec) |
| 5210 | { |
| 5211 | struct alc_spec *spec = codec->spec; |
| 5212 | hda_nid_t pin; |
| 5213 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5214 | pin = spec->autocfg.hp_pins[0]; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5215 | if (pin) /* connect to front */ |
| 5216 | /* use dac 0 */ |
| 5217 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 5218 | } |
| 5219 | |
| 5220 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) |
| 5221 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID |
| 5222 | |
| 5223 | static void alc883_auto_init_analog_input(struct hda_codec *codec) |
| 5224 | { |
| 5225 | struct alc_spec *spec = codec->spec; |
| 5226 | int i; |
| 5227 | |
| 5228 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 5229 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 5230 | if (alc883_is_input_pin(nid)) { |
| 5231 | snd_hda_codec_write(codec, nid, 0, |
| 5232 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5233 | (i <= AUTO_PIN_FRONT_MIC ? |
| 5234 | PIN_VREF80 : PIN_IN)); |
| 5235 | if (nid != ALC883_PIN_CD_NID) |
| 5236 | snd_hda_codec_write(codec, nid, 0, |
| 5237 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 5238 | AMP_OUT_MUTE); |
| 5239 | } |
| 5240 | } |
| 5241 | } |
| 5242 | |
| 5243 | /* almost identical with ALC880 parser... */ |
| 5244 | static int alc883_parse_auto_config(struct hda_codec *codec) |
| 5245 | { |
| 5246 | struct alc_spec *spec = codec->spec; |
| 5247 | int err = alc880_parse_auto_config(codec); |
| 5248 | |
| 5249 | if (err < 0) |
| 5250 | return err; |
| 5251 | else if (err > 0) |
| 5252 | /* hack - override the init verbs */ |
| 5253 | spec->init_verbs[0] = alc883_auto_init_verbs; |
| 5254 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
| 5255 | spec->num_mixers++; |
| 5256 | return err; |
| 5257 | } |
| 5258 | |
| 5259 | /* additional initialization for auto-configuration model */ |
| 5260 | static void alc883_auto_init(struct hda_codec *codec) |
| 5261 | { |
| 5262 | alc883_auto_init_multi_out(codec); |
| 5263 | alc883_auto_init_hp_out(codec); |
| 5264 | alc883_auto_init_analog_input(codec); |
| 5265 | } |
| 5266 | |
| 5267 | static int patch_alc883(struct hda_codec *codec) |
| 5268 | { |
| 5269 | struct alc_spec *spec; |
| 5270 | int err, board_config; |
| 5271 | |
| 5272 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5273 | if (spec == NULL) |
| 5274 | return -ENOMEM; |
| 5275 | |
| 5276 | codec->spec = spec; |
| 5277 | |
| 5278 | board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl); |
| 5279 | if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { |
| 5280 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
| 5281 | "trying auto-probe from BIOS...\n"); |
| 5282 | board_config = ALC883_AUTO; |
| 5283 | } |
| 5284 | |
| 5285 | if (board_config == ALC883_AUTO) { |
| 5286 | /* automatic parse from the BIOS config */ |
| 5287 | err = alc883_parse_auto_config(codec); |
| 5288 | if (err < 0) { |
| 5289 | alc_free(codec); |
| 5290 | return err; |
| 5291 | } else if (! err) { |
| 5292 | printk(KERN_INFO |
| 5293 | "hda_codec: Cannot set up configuration " |
| 5294 | "from BIOS. Using base mode...\n"); |
| 5295 | board_config = ALC883_3ST_2ch_DIG; |
| 5296 | } |
| 5297 | } |
| 5298 | |
| 5299 | if (board_config != ALC883_AUTO) |
| 5300 | setup_preset(spec, &alc883_presets[board_config]); |
| 5301 | |
| 5302 | spec->stream_name_analog = "ALC883 Analog"; |
| 5303 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
| 5304 | spec->stream_analog_capture = &alc883_pcm_analog_capture; |
| 5305 | |
| 5306 | spec->stream_name_digital = "ALC883 Digital"; |
| 5307 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
| 5308 | spec->stream_digital_capture = &alc883_pcm_digital_capture; |
| 5309 | |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 5310 | if (! spec->adc_nids && spec->input_mux) { |
| 5311 | spec->adc_nids = alc883_adc_nids; |
| 5312 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); |
| 5313 | } |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5314 | |
| 5315 | codec->patch_ops = alc_patch_ops; |
| 5316 | if (board_config == ALC883_AUTO) |
| 5317 | spec->init_hook = alc883_auto_init; |
| 5318 | |
| 5319 | return 0; |
| 5320 | } |
| 5321 | |
| 5322 | /* |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5323 | * ALC262 support |
| 5324 | */ |
| 5325 | |
| 5326 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID |
| 5327 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID |
| 5328 | |
| 5329 | #define alc262_dac_nids alc260_dac_nids |
| 5330 | #define alc262_adc_nids alc882_adc_nids |
| 5331 | #define alc262_adc_nids_alt alc882_adc_nids_alt |
| 5332 | |
| 5333 | #define alc262_modes alc260_modes |
Takashi Iwai | c5f2ea0 | 2005-12-06 18:54:31 +0100 | [diff] [blame] | 5334 | #define alc262_capture_source alc882_capture_source |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5335 | |
| 5336 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
| 5337 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 5338 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 5339 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 5340 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 5341 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 5342 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 5343 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 5344 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 5345 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 5346 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 5347 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 5348 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
| 5349 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
| 5350 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 5351 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 5352 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5353 | { } /* end */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5354 | }; |
| 5355 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5356 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
| 5357 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 5358 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 5359 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 5360 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
| 5361 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), |
| 5362 | |
| 5363 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 5364 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 5365 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
| 5366 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), |
| 5367 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
| 5368 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
| 5369 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 5370 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 5371 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
| 5372 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), |
| 5373 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), |
| 5374 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), |
| 5375 | { } /* end */ |
| 5376 | }; |
| 5377 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5378 | #define alc262_capture_mixer alc882_capture_mixer |
| 5379 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer |
| 5380 | |
| 5381 | /* |
| 5382 | * generic initialization of ADC, input mixers and output mixers |
| 5383 | */ |
| 5384 | static struct hda_verb alc262_init_verbs[] = { |
| 5385 | /* |
| 5386 | * Unmute ADC0-2 and set the default input to mic-in |
| 5387 | */ |
| 5388 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5389 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5390 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5391 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5392 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5393 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5394 | |
| 5395 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 5396 | * mixer widget |
| 5397 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 5398 | * mic (mic 2) |
| 5399 | */ |
| 5400 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 5401 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5402 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5403 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5404 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5405 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 5406 | |
| 5407 | /* |
| 5408 | * Set up output mixers (0x0c - 0x0e) |
| 5409 | */ |
| 5410 | /* set vol=0 to output mixers */ |
| 5411 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5412 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5413 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5414 | /* set up input amps for analog loopback */ |
| 5415 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 5416 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5417 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5418 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5419 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5420 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5421 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5422 | |
| 5423 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 5424 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 5425 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 5426 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 5427 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 5428 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 5429 | |
| 5430 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 5431 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 5432 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 5433 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 5434 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, |
| 5435 | |
| 5436 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5437 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 5438 | |
| 5439 | /* FIXME: use matrix-type input source selection */ |
| 5440 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 5441 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 5442 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5443 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5444 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5445 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5446 | /* Input mixer2 */ |
| 5447 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5448 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5449 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5450 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5451 | /* Input mixer3 */ |
| 5452 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5453 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5454 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5455 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5456 | |
| 5457 | { } |
| 5458 | }; |
| 5459 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5460 | /* |
| 5461 | * fujitsu model |
| 5462 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker |
| 5463 | */ |
| 5464 | |
| 5465 | #define ALC_HP_EVENT 0x37 |
| 5466 | |
| 5467 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { |
| 5468 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
| 5469 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 5470 | {} |
| 5471 | }; |
| 5472 | |
| 5473 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
| 5474 | .num_items = 2, |
| 5475 | .items = { |
| 5476 | { "Mic", 0x0 }, |
| 5477 | { "CD", 0x4 }, |
| 5478 | }, |
| 5479 | }; |
| 5480 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5481 | static struct hda_input_mux alc262_HP_capture_source = { |
| 5482 | .num_items = 5, |
| 5483 | .items = { |
| 5484 | { "Mic", 0x0 }, |
| 5485 | { "Front Mic", 0x3 }, |
| 5486 | { "Line", 0x2 }, |
| 5487 | { "CD", 0x4 }, |
| 5488 | { "AUX IN", 0x6 }, |
| 5489 | }, |
| 5490 | }; |
| 5491 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5492 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
| 5493 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
| 5494 | { |
| 5495 | struct alc_spec *spec = codec->spec; |
| 5496 | unsigned int mute; |
| 5497 | |
| 5498 | if (force || ! spec->sense_updated) { |
| 5499 | unsigned int present; |
| 5500 | /* need to execute and sync at first */ |
| 5501 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); |
| 5502 | present = snd_hda_codec_read(codec, 0x14, 0, |
| 5503 | AC_VERB_GET_PIN_SENSE, 0); |
| 5504 | spec->jack_present = (present & 0x80000000) != 0; |
| 5505 | spec->sense_updated = 1; |
| 5506 | } |
| 5507 | if (spec->jack_present) { |
| 5508 | /* mute internal speaker */ |
| 5509 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
| 5510 | 0x80, 0x80); |
| 5511 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
| 5512 | 0x80, 0x80); |
| 5513 | } else { |
| 5514 | /* unmute internal speaker if necessary */ |
| 5515 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
| 5516 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
| 5517 | 0x80, mute & 0x80); |
| 5518 | mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); |
| 5519 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
| 5520 | 0x80, mute & 0x80); |
| 5521 | } |
| 5522 | } |
| 5523 | |
| 5524 | /* unsolicited event for HP jack sensing */ |
| 5525 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, |
| 5526 | unsigned int res) |
| 5527 | { |
| 5528 | if ((res >> 26) != ALC_HP_EVENT) |
| 5529 | return; |
| 5530 | alc262_fujitsu_automute(codec, 1); |
| 5531 | } |
| 5532 | |
| 5533 | /* bind volumes of both NID 0x0c and 0x0d */ |
| 5534 | static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, |
| 5535 | struct snd_ctl_elem_value *ucontrol) |
| 5536 | { |
| 5537 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 5538 | long *valp = ucontrol->value.integer.value; |
| 5539 | int change; |
| 5540 | |
| 5541 | change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, |
| 5542 | 0x7f, valp[0] & 0x7f); |
| 5543 | change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, |
| 5544 | 0x7f, valp[1] & 0x7f); |
| 5545 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, |
| 5546 | 0x7f, valp[0] & 0x7f); |
| 5547 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, |
| 5548 | 0x7f, valp[1] & 0x7f); |
| 5549 | return change; |
| 5550 | } |
| 5551 | |
| 5552 | /* bind hp and internal speaker mute (with plug check) */ |
| 5553 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, |
| 5554 | struct snd_ctl_elem_value *ucontrol) |
| 5555 | { |
| 5556 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 5557 | long *valp = ucontrol->value.integer.value; |
| 5558 | int change; |
| 5559 | |
| 5560 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
| 5561 | 0x80, valp[0] ? 0 : 0x80); |
| 5562 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
| 5563 | 0x80, valp[1] ? 0 : 0x80); |
| 5564 | if (change || codec->in_resume) |
| 5565 | alc262_fujitsu_automute(codec, codec->in_resume); |
| 5566 | return change; |
| 5567 | } |
| 5568 | |
| 5569 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { |
| 5570 | { |
| 5571 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5572 | .name = "Master Playback Volume", |
| 5573 | .info = snd_hda_mixer_amp_volume_info, |
| 5574 | .get = snd_hda_mixer_amp_volume_get, |
| 5575 | .put = alc262_fujitsu_master_vol_put, |
Takashi Iwai | c256652 | 2006-08-17 18:21:36 +0200 | [diff] [blame] | 5576 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5577 | .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), |
| 5578 | }, |
| 5579 | { |
| 5580 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5581 | .name = "Master Playback Switch", |
| 5582 | .info = snd_hda_mixer_amp_switch_info, |
| 5583 | .get = snd_hda_mixer_amp_switch_get, |
| 5584 | .put = alc262_fujitsu_master_sw_put, |
| 5585 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 5586 | }, |
| 5587 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
| 5588 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
| 5589 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
| 5590 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
| 5591 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
| 5592 | { } /* end */ |
| 5593 | }; |
| 5594 | |
Takashi Iwai | 304dcaa | 2006-07-25 14:51:16 +0200 | [diff] [blame] | 5595 | /* additional init verbs for Benq laptops */ |
| 5596 | static struct hda_verb alc262_EAPD_verbs[] = { |
| 5597 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
| 5598 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, |
| 5599 | {} |
| 5600 | }; |
| 5601 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5602 | /* add playback controls from the parsed DAC table */ |
| 5603 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 5604 | { |
| 5605 | hda_nid_t nid; |
| 5606 | int err; |
| 5607 | |
| 5608 | spec->multiout.num_dacs = 1; /* only use one dac */ |
| 5609 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 5610 | spec->multiout.dac_nids[0] = 2; |
| 5611 | |
| 5612 | nid = cfg->line_out_pins[0]; |
| 5613 | if (nid) { |
| 5614 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", |
| 5615 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) |
| 5616 | return err; |
| 5617 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", |
| 5618 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 5619 | return err; |
| 5620 | } |
| 5621 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5622 | nid = cfg->speaker_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5623 | if (nid) { |
| 5624 | if (nid == 0x16) { |
| 5625 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", |
| 5626 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 5627 | return err; |
| 5628 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 5629 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 5630 | return err; |
| 5631 | } else { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5632 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
| 5633 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 5634 | return err; |
| 5635 | } |
| 5636 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5637 | nid = cfg->hp_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5638 | if (nid) { |
| 5639 | /* spec->multiout.hp_nid = 2; */ |
| 5640 | if (nid == 0x16) { |
| 5641 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 5642 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) |
| 5643 | return err; |
| 5644 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 5645 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 5646 | return err; |
| 5647 | } else { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5648 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 5649 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 5650 | return err; |
| 5651 | } |
| 5652 | } |
| 5653 | return 0; |
| 5654 | } |
| 5655 | |
| 5656 | /* identical with ALC880 */ |
| 5657 | #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls |
| 5658 | |
| 5659 | /* |
| 5660 | * generic initialization of ADC, input mixers and output mixers |
| 5661 | */ |
| 5662 | static struct hda_verb alc262_volume_init_verbs[] = { |
| 5663 | /* |
| 5664 | * Unmute ADC0-2 and set the default input to mic-in |
| 5665 | */ |
| 5666 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5667 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5668 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5669 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5670 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5671 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5672 | |
| 5673 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 5674 | * mixer widget |
| 5675 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 5676 | * mic (mic 2) |
| 5677 | */ |
| 5678 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 5679 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5680 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5681 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5682 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5683 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 5684 | |
| 5685 | /* |
| 5686 | * Set up output mixers (0x0c - 0x0f) |
| 5687 | */ |
| 5688 | /* set vol=0 to output mixers */ |
| 5689 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5690 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5691 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5692 | |
| 5693 | /* set up input amps for analog loopback */ |
| 5694 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 5695 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5696 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5697 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5698 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5699 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5700 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5701 | |
| 5702 | /* FIXME: use matrix-type input source selection */ |
| 5703 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 5704 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 5705 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5706 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5707 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5708 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5709 | /* Input mixer2 */ |
| 5710 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5711 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5712 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5713 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5714 | /* Input mixer3 */ |
| 5715 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5716 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
| 5717 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
| 5718 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
| 5719 | |
| 5720 | { } |
| 5721 | }; |
| 5722 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5723 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
| 5724 | /* |
| 5725 | * Unmute ADC0-2 and set the default input to mic-in |
| 5726 | */ |
| 5727 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5728 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5729 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5730 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5731 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5732 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5733 | |
| 5734 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 5735 | * mixer widget |
| 5736 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
| 5737 | * mic (mic 2) |
| 5738 | */ |
| 5739 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
| 5740 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5741 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5742 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 5743 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 5744 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 5745 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, |
| 5746 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, |
| 5747 | |
| 5748 | /* |
| 5749 | * Set up output mixers (0x0c - 0x0e) |
| 5750 | */ |
| 5751 | /* set vol=0 to output mixers */ |
| 5752 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5753 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5754 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 5755 | |
| 5756 | /* set up input amps for analog loopback */ |
| 5757 | /* Amp Indices: DAC = 0, mixer = 1 */ |
| 5758 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5759 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5760 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5761 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5762 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5763 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 5764 | |
| 5765 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
| 5766 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 5767 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 5768 | |
| 5769 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 5770 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 5771 | |
| 5772 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5773 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 5774 | |
| 5775 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 5776 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 5777 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, |
| 5778 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 5779 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 5780 | |
| 5781 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, |
| 5782 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
| 5783 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
| 5784 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, |
| 5785 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
| 5786 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
| 5787 | |
| 5788 | |
| 5789 | /* FIXME: use matrix-type input source selection */ |
| 5790 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
| 5791 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
| 5792 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5793 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, |
| 5794 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 5795 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 5796 | /* Input mixer2 */ |
| 5797 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5798 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, |
| 5799 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 5800 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 5801 | /* Input mixer3 */ |
| 5802 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
| 5803 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, |
| 5804 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, |
| 5805 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, |
| 5806 | |
| 5807 | { } |
| 5808 | }; |
| 5809 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5810 | /* pcm configuration: identiacal with ALC880 */ |
| 5811 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback |
| 5812 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture |
| 5813 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback |
| 5814 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture |
| 5815 | |
| 5816 | /* |
| 5817 | * BIOS auto configuration |
| 5818 | */ |
| 5819 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5820 | { |
| 5821 | struct alc_spec *spec = codec->spec; |
| 5822 | int err; |
| 5823 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
| 5824 | |
| 5825 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 5826 | alc262_ignore)) < 0) |
| 5827 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5828 | if (! spec->autocfg.line_outs) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5829 | return 0; /* can't find valid BIOS pin config */ |
| 5830 | if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 5831 | (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 5832 | return err; |
| 5833 | |
| 5834 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 5835 | |
| 5836 | if (spec->autocfg.dig_out_pin) |
| 5837 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; |
| 5838 | if (spec->autocfg.dig_in_pin) |
| 5839 | spec->dig_in_nid = ALC262_DIGIN_NID; |
| 5840 | |
| 5841 | if (spec->kctl_alloc) |
| 5842 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 5843 | |
| 5844 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 5845 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5846 | spec->input_mux = &spec->private_imux; |
| 5847 | |
| 5848 | return 1; |
| 5849 | } |
| 5850 | |
| 5851 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out |
| 5852 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out |
| 5853 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input |
| 5854 | |
| 5855 | |
| 5856 | /* init callback for auto-configuration model -- overriding the default init */ |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 5857 | static void alc262_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5858 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5859 | alc262_auto_init_multi_out(codec); |
| 5860 | alc262_auto_init_hp_out(codec); |
| 5861 | alc262_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5862 | } |
| 5863 | |
| 5864 | /* |
| 5865 | * configuration and preset |
| 5866 | */ |
| 5867 | static struct hda_board_config alc262_cfg_tbl[] = { |
| 5868 | { .modelname = "basic", .config = ALC262_BASIC }, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5869 | { .modelname = "fujitsu", .config = ALC262_FUJITSU }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5870 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, |
| 5871 | .config = ALC262_FUJITSU }, |
Takashi Iwai | 6d177ba | 2006-07-25 14:51:15 +0200 | [diff] [blame] | 5872 | { .modelname = "hp-bpc", .config = ALC262_HP_BPC }, |
John W. Linville | 282e0c8 | 2006-11-06 12:01:53 +0100 | [diff] [blame] | 5873 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5874 | .config = ALC262_HP_BPC }, /* xw4400 */ |
Takashi Iwai | efeccac | 2006-10-24 14:57:52 +0200 | [diff] [blame^] | 5875 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801, |
| 5876 | .config = ALC262_HP_BPC }, /* q965 */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5877 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, |
| 5878 | .config = ALC262_HP_BPC }, /* xw6400 */ |
| 5879 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, |
| 5880 | .config = ALC262_HP_BPC }, /* xw8400 */ |
| 5881 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe, |
| 5882 | .config = ALC262_HP_BPC }, /* xw9400 */ |
Takashi Iwai | 304dcaa | 2006-07-25 14:51:16 +0200 | [diff] [blame] | 5883 | { .modelname = "benq", .config = ALC262_BENQ_ED8 }, |
| 5884 | { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560, |
| 5885 | .config = ALC262_BENQ_ED8 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5886 | { .modelname = "auto", .config = ALC262_AUTO }, |
| 5887 | {} |
| 5888 | }; |
| 5889 | |
| 5890 | static struct alc_config_preset alc262_presets[] = { |
| 5891 | [ALC262_BASIC] = { |
| 5892 | .mixers = { alc262_base_mixer }, |
| 5893 | .init_verbs = { alc262_init_verbs }, |
| 5894 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 5895 | .dac_nids = alc262_dac_nids, |
| 5896 | .hp_nid = 0x03, |
| 5897 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 5898 | .channel_mode = alc262_modes, |
Takashi Iwai | a3bcba3 | 2005-12-06 19:05:29 +0100 | [diff] [blame] | 5899 | .input_mux = &alc262_capture_source, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5900 | }, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5901 | [ALC262_FUJITSU] = { |
| 5902 | .mixers = { alc262_fujitsu_mixer }, |
| 5903 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, |
| 5904 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 5905 | .dac_nids = alc262_dac_nids, |
| 5906 | .hp_nid = 0x03, |
| 5907 | .dig_out_nid = ALC262_DIGOUT_NID, |
| 5908 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 5909 | .channel_mode = alc262_modes, |
| 5910 | .input_mux = &alc262_fujitsu_capture_source, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 5911 | .unsol_event = alc262_fujitsu_unsol_event, |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 5912 | }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5913 | [ALC262_HP_BPC] = { |
| 5914 | .mixers = { alc262_HP_BPC_mixer }, |
| 5915 | .init_verbs = { alc262_HP_BPC_init_verbs }, |
| 5916 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 5917 | .dac_nids = alc262_dac_nids, |
| 5918 | .hp_nid = 0x03, |
| 5919 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 5920 | .channel_mode = alc262_modes, |
| 5921 | .input_mux = &alc262_HP_capture_source, |
| 5922 | }, |
Takashi Iwai | 304dcaa | 2006-07-25 14:51:16 +0200 | [diff] [blame] | 5923 | [ALC262_BENQ_ED8] = { |
| 5924 | .mixers = { alc262_base_mixer }, |
| 5925 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, |
| 5926 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
| 5927 | .dac_nids = alc262_dac_nids, |
| 5928 | .hp_nid = 0x03, |
| 5929 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 5930 | .channel_mode = alc262_modes, |
| 5931 | .input_mux = &alc262_capture_source, |
| 5932 | }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5933 | }; |
| 5934 | |
| 5935 | static int patch_alc262(struct hda_codec *codec) |
| 5936 | { |
| 5937 | struct alc_spec *spec; |
| 5938 | int board_config; |
| 5939 | int err; |
| 5940 | |
| 5941 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 5942 | if (spec == NULL) |
| 5943 | return -ENOMEM; |
| 5944 | |
| 5945 | codec->spec = spec; |
| 5946 | #if 0 |
| 5947 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ |
| 5948 | { |
| 5949 | int tmp; |
| 5950 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5951 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5952 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5953 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5954 | } |
| 5955 | #endif |
| 5956 | |
| 5957 | board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5958 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5959 | if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5960 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
| 5961 | "trying auto-probe from BIOS...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5962 | board_config = ALC262_AUTO; |
| 5963 | } |
| 5964 | |
| 5965 | if (board_config == ALC262_AUTO) { |
| 5966 | /* automatic parse from the BIOS config */ |
| 5967 | err = alc262_parse_auto_config(codec); |
| 5968 | if (err < 0) { |
| 5969 | alc_free(codec); |
| 5970 | return err; |
| 5971 | } else if (! err) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 5972 | printk(KERN_INFO |
| 5973 | "hda_codec: Cannot set up configuration " |
| 5974 | "from BIOS. Using base mode...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5975 | board_config = ALC262_BASIC; |
| 5976 | } |
| 5977 | } |
| 5978 | |
| 5979 | if (board_config != ALC262_AUTO) |
| 5980 | setup_preset(spec, &alc262_presets[board_config]); |
| 5981 | |
| 5982 | spec->stream_name_analog = "ALC262 Analog"; |
| 5983 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
| 5984 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
| 5985 | |
| 5986 | spec->stream_name_digital = "ALC262 Digital"; |
| 5987 | spec->stream_digital_playback = &alc262_pcm_digital_playback; |
| 5988 | spec->stream_digital_capture = &alc262_pcm_digital_capture; |
| 5989 | |
| 5990 | if (! spec->adc_nids && spec->input_mux) { |
| 5991 | /* check whether NID 0x07 is valid */ |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 5992 | unsigned int wcap = get_wcaps(codec, 0x07); |
| 5993 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5994 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
| 5995 | if (wcap != AC_WID_AUD_IN) { |
| 5996 | spec->adc_nids = alc262_adc_nids_alt; |
| 5997 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); |
| 5998 | spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; |
| 5999 | spec->num_mixers++; |
| 6000 | } else { |
| 6001 | spec->adc_nids = alc262_adc_nids; |
| 6002 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); |
| 6003 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; |
| 6004 | spec->num_mixers++; |
| 6005 | } |
| 6006 | } |
| 6007 | |
| 6008 | codec->patch_ops = alc_patch_ops; |
| 6009 | if (board_config == ALC262_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 6010 | spec->init_hook = alc262_auto_init; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 6011 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6012 | return 0; |
| 6013 | } |
| 6014 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6015 | /* |
| 6016 | * ALC861 channel source setting (2/6 channel selection for 3-stack) |
| 6017 | */ |
| 6018 | |
| 6019 | /* |
| 6020 | * set the path ways for 2 channel output |
| 6021 | * need to set the codec line out and mic 1 pin widgets to inputs |
| 6022 | */ |
| 6023 | static struct hda_verb alc861_threestack_ch2_init[] = { |
| 6024 | /* set pin widget 1Ah (line in) for input */ |
| 6025 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6026 | /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ |
| 6027 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6028 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6029 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
| 6030 | #if 0 |
| 6031 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ |
| 6032 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ |
| 6033 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6034 | { } /* end */ |
| 6035 | }; |
| 6036 | /* |
| 6037 | * 6ch mode |
| 6038 | * need to set the codec line out and mic 1 pin widgets to outputs |
| 6039 | */ |
| 6040 | static struct hda_verb alc861_threestack_ch6_init[] = { |
| 6041 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ |
| 6042 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6043 | /* set pin widget 18h (mic1) for output (CLFE)*/ |
| 6044 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6045 | |
| 6046 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6047 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6048 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6049 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 6050 | #if 0 |
| 6051 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ |
| 6052 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ |
| 6053 | #endif |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6054 | { } /* end */ |
| 6055 | }; |
| 6056 | |
| 6057 | static struct hda_channel_mode alc861_threestack_modes[2] = { |
| 6058 | { 2, alc861_threestack_ch2_init }, |
| 6059 | { 6, alc861_threestack_ch6_init }, |
| 6060 | }; |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 6061 | /* Set mic1 as input and unmute the mixer */ |
| 6062 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { |
| 6063 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6064 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ |
| 6065 | { } /* end */ |
| 6066 | }; |
| 6067 | /* Set mic1 as output and mute mixer */ |
| 6068 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { |
| 6069 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6070 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ |
| 6071 | { } /* end */ |
| 6072 | }; |
| 6073 | |
| 6074 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { |
| 6075 | { 2, alc861_uniwill_m31_ch2_init }, |
| 6076 | { 4, alc861_uniwill_m31_ch4_init }, |
| 6077 | }; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6078 | |
| 6079 | /* patch-ALC861 */ |
| 6080 | |
| 6081 | static struct snd_kcontrol_new alc861_base_mixer[] = { |
| 6082 | /* output mixer control */ |
| 6083 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 6084 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 6085 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 6086 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 6087 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), |
| 6088 | |
| 6089 | /*Input mixer control */ |
| 6090 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 6091 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 6092 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 6093 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 6094 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 6095 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 6096 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 6097 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 6098 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 6099 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 6100 | |
| 6101 | /* Capture mixer control */ |
| 6102 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 6103 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 6104 | { |
| 6105 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6106 | .name = "Capture Source", |
| 6107 | .count = 1, |
| 6108 | .info = alc_mux_enum_info, |
| 6109 | .get = alc_mux_enum_get, |
| 6110 | .put = alc_mux_enum_put, |
| 6111 | }, |
| 6112 | { } /* end */ |
| 6113 | }; |
| 6114 | |
| 6115 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { |
| 6116 | /* output mixer control */ |
| 6117 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 6118 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 6119 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 6120 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 6121 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ |
| 6122 | |
| 6123 | /* Input mixer control */ |
| 6124 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 6125 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 6126 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 6127 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 6128 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 6129 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 6130 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 6131 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 6132 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 6133 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 6134 | |
| 6135 | /* Capture mixer control */ |
| 6136 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 6137 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 6138 | { |
| 6139 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6140 | .name = "Capture Source", |
| 6141 | .count = 1, |
| 6142 | .info = alc_mux_enum_info, |
| 6143 | .get = alc_mux_enum_get, |
| 6144 | .put = alc_mux_enum_put, |
| 6145 | }, |
| 6146 | { |
| 6147 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6148 | .name = "Channel Mode", |
| 6149 | .info = alc_ch_mode_info, |
| 6150 | .get = alc_ch_mode_get, |
| 6151 | .put = alc_ch_mode_put, |
| 6152 | .private_value = ARRAY_SIZE(alc861_threestack_modes), |
| 6153 | }, |
| 6154 | { } /* end */ |
| 6155 | }; |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 6156 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
| 6157 | /* output mixer control */ |
| 6158 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 6159 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 6160 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), |
| 6161 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), |
| 6162 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ |
| 6163 | |
| 6164 | /* Input mixer control */ |
| 6165 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 6166 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ |
| 6167 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
| 6168 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), |
| 6169 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), |
| 6170 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), |
| 6171 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), |
| 6172 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), |
| 6173 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), |
| 6174 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), |
| 6175 | |
| 6176 | /* Capture mixer control */ |
| 6177 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 6178 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 6179 | { |
| 6180 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6181 | .name = "Capture Source", |
| 6182 | .count = 1, |
| 6183 | .info = alc_mux_enum_info, |
| 6184 | .get = alc_mux_enum_get, |
| 6185 | .put = alc_mux_enum_put, |
| 6186 | }, |
| 6187 | { |
| 6188 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6189 | .name = "Channel Mode", |
| 6190 | .info = alc_ch_mode_info, |
| 6191 | .get = alc_ch_mode_get, |
| 6192 | .put = alc_ch_mode_put, |
| 6193 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), |
| 6194 | }, |
| 6195 | { } /* end */ |
| 6196 | }; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6197 | |
| 6198 | /* |
| 6199 | * generic initialization of ADC, input mixers and output mixers |
| 6200 | */ |
| 6201 | static struct hda_verb alc861_base_init_verbs[] = { |
| 6202 | /* |
| 6203 | * Unmute ADC0 and set the default input to mic-in |
| 6204 | */ |
| 6205 | /* port-A for surround (rear panel) */ |
| 6206 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6207 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6208 | /* port-B for mic-in (rear panel) with vref */ |
| 6209 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6210 | /* port-C for line-in (rear panel) */ |
| 6211 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6212 | /* port-D for Front */ |
| 6213 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6214 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6215 | /* port-E for HP out (front panel) */ |
| 6216 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 6217 | /* route front PCM to HP */ |
| 6218 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 6219 | /* port-F for mic-in (front panel) with vref */ |
| 6220 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6221 | /* port-G for CLFE (rear panel) */ |
| 6222 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6223 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6224 | /* port-H for side (rear panel) */ |
| 6225 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6226 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6227 | /* CD-in */ |
| 6228 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6229 | /* route front mic to ADC1*/ |
| 6230 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 6231 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6232 | |
| 6233 | /* Unmute DAC0~3 & spdif out*/ |
| 6234 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6235 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6236 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6237 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6238 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6239 | |
| 6240 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 6241 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6242 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6243 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6244 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6245 | |
| 6246 | /* Unmute Stereo Mixer 15 */ |
| 6247 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6248 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6249 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6250 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 6251 | |
| 6252 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6253 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6254 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6255 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6256 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6257 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6258 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6259 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6260 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 6261 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6262 | |
| 6263 | { } |
| 6264 | }; |
| 6265 | |
| 6266 | static struct hda_verb alc861_threestack_init_verbs[] = { |
| 6267 | /* |
| 6268 | * Unmute ADC0 and set the default input to mic-in |
| 6269 | */ |
| 6270 | /* port-A for surround (rear panel) */ |
| 6271 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6272 | /* port-B for mic-in (rear panel) with vref */ |
| 6273 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6274 | /* port-C for line-in (rear panel) */ |
| 6275 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6276 | /* port-D for Front */ |
| 6277 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6278 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6279 | /* port-E for HP out (front panel) */ |
| 6280 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 6281 | /* route front PCM to HP */ |
| 6282 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 6283 | /* port-F for mic-in (front panel) with vref */ |
| 6284 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6285 | /* port-G for CLFE (rear panel) */ |
| 6286 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6287 | /* port-H for side (rear panel) */ |
| 6288 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6289 | /* CD-in */ |
| 6290 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6291 | /* route front mic to ADC1*/ |
| 6292 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 6293 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6294 | /* Unmute DAC0~3 & spdif out*/ |
| 6295 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6296 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6297 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6298 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6299 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6300 | |
| 6301 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 6302 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6303 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6304 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6305 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6306 | |
| 6307 | /* Unmute Stereo Mixer 15 */ |
| 6308 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6309 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6310 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6311 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 6312 | |
| 6313 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6314 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6315 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6316 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6317 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6318 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6319 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6320 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6321 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 6322 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6323 | { } |
| 6324 | }; |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 6325 | |
| 6326 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { |
| 6327 | /* |
| 6328 | * Unmute ADC0 and set the default input to mic-in |
| 6329 | */ |
| 6330 | /* port-A for surround (rear panel) */ |
| 6331 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6332 | /* port-B for mic-in (rear panel) with vref */ |
| 6333 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6334 | /* port-C for line-in (rear panel) */ |
| 6335 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6336 | /* port-D for Front */ |
| 6337 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 6338 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 6339 | /* port-E for HP out (front panel) */ |
| 6340 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 |
| 6341 | /* route front PCM to HP */ |
| 6342 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 6343 | /* port-F for mic-in (front panel) with vref */ |
| 6344 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 6345 | /* port-G for CLFE (rear panel) */ |
| 6346 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6347 | /* port-H for side (rear panel) */ |
| 6348 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, |
| 6349 | /* CD-in */ |
| 6350 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 6351 | /* route front mic to ADC1*/ |
| 6352 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 6353 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6354 | /* Unmute DAC0~3 & spdif out*/ |
| 6355 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6356 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6357 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6358 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6359 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6360 | |
| 6361 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 6362 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6363 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6364 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6365 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6366 | |
| 6367 | /* Unmute Stereo Mixer 15 */ |
| 6368 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6369 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6370 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6371 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step |
| 6372 | |
| 6373 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6374 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6375 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6376 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6377 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6378 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6379 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6380 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6381 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) |
| 6382 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6383 | { } |
| 6384 | }; |
| 6385 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6386 | /* |
| 6387 | * generic initialization of ADC, input mixers and output mixers |
| 6388 | */ |
| 6389 | static struct hda_verb alc861_auto_init_verbs[] = { |
| 6390 | /* |
| 6391 | * Unmute ADC0 and set the default input to mic-in |
| 6392 | */ |
| 6393 | // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 6394 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6395 | |
| 6396 | /* Unmute DAC0~3 & spdif out*/ |
| 6397 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 6398 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 6399 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 6400 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 6401 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 6402 | |
| 6403 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
| 6404 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6405 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6406 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6407 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6408 | |
| 6409 | /* Unmute Stereo Mixer 15 */ |
| 6410 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6411 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6412 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6413 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, |
| 6414 | |
| 6415 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6416 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6417 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6418 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6419 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6420 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6421 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 6422 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 6423 | |
| 6424 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 6425 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 6426 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6427 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 6428 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 6429 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 6430 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 6431 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 6432 | |
| 6433 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 |
| 6434 | |
| 6435 | { } |
| 6436 | }; |
| 6437 | |
| 6438 | /* pcm configuration: identiacal with ALC880 */ |
| 6439 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback |
| 6440 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture |
| 6441 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback |
| 6442 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture |
| 6443 | |
| 6444 | |
| 6445 | #define ALC861_DIGOUT_NID 0x07 |
| 6446 | |
| 6447 | static struct hda_channel_mode alc861_8ch_modes[1] = { |
| 6448 | { 8, NULL } |
| 6449 | }; |
| 6450 | |
| 6451 | static hda_nid_t alc861_dac_nids[4] = { |
| 6452 | /* front, surround, clfe, side */ |
| 6453 | 0x03, 0x06, 0x05, 0x04 |
| 6454 | }; |
| 6455 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6456 | static hda_nid_t alc660_dac_nids[3] = { |
| 6457 | /* front, clfe, surround */ |
| 6458 | 0x03, 0x05, 0x06 |
| 6459 | }; |
| 6460 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6461 | static hda_nid_t alc861_adc_nids[1] = { |
| 6462 | /* ADC0-2 */ |
| 6463 | 0x08, |
| 6464 | }; |
| 6465 | |
| 6466 | static struct hda_input_mux alc861_capture_source = { |
| 6467 | .num_items = 5, |
| 6468 | .items = { |
| 6469 | { "Mic", 0x0 }, |
| 6470 | { "Front Mic", 0x3 }, |
| 6471 | { "Line", 0x1 }, |
| 6472 | { "CD", 0x4 }, |
| 6473 | { "Mixer", 0x5 }, |
| 6474 | }, |
| 6475 | }; |
| 6476 | |
| 6477 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 6478 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 6479 | { |
| 6480 | int i; |
| 6481 | hda_nid_t nid; |
| 6482 | |
| 6483 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 6484 | for (i = 0; i < cfg->line_outs; i++) { |
| 6485 | nid = cfg->line_out_pins[i]; |
| 6486 | if (nid) { |
| 6487 | if (i >= ARRAY_SIZE(alc861_dac_nids)) |
| 6488 | continue; |
| 6489 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; |
| 6490 | } |
| 6491 | } |
| 6492 | spec->multiout.num_dacs = cfg->line_outs; |
| 6493 | return 0; |
| 6494 | } |
| 6495 | |
| 6496 | /* add playback controls from the parsed DAC table */ |
| 6497 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, |
| 6498 | const struct auto_pin_cfg *cfg) |
| 6499 | { |
| 6500 | char name[32]; |
| 6501 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 6502 | hda_nid_t nid; |
| 6503 | int i, idx, err; |
| 6504 | |
| 6505 | for (i = 0; i < cfg->line_outs; i++) { |
| 6506 | nid = spec->multiout.dac_nids[i]; |
| 6507 | if (! nid) |
| 6508 | continue; |
| 6509 | if (nid == 0x05) { |
| 6510 | /* Center/LFE */ |
| 6511 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", |
| 6512 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 6513 | return err; |
| 6514 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", |
| 6515 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 6516 | return err; |
| 6517 | } else { |
| 6518 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) |
| 6519 | if (nid == alc861_dac_nids[idx]) |
| 6520 | break; |
| 6521 | sprintf(name, "%s Playback Switch", chname[idx]); |
| 6522 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
| 6523 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 6524 | return err; |
| 6525 | } |
| 6526 | } |
| 6527 | return 0; |
| 6528 | } |
| 6529 | |
| 6530 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) |
| 6531 | { |
| 6532 | int err; |
| 6533 | hda_nid_t nid; |
| 6534 | |
| 6535 | if (! pin) |
| 6536 | return 0; |
| 6537 | |
| 6538 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { |
| 6539 | nid = 0x03; |
| 6540 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 6541 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 6542 | return err; |
| 6543 | spec->multiout.hp_nid = nid; |
| 6544 | } |
| 6545 | return 0; |
| 6546 | } |
| 6547 | |
| 6548 | /* create playback/capture controls for input pins */ |
| 6549 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) |
| 6550 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6551 | struct hda_input_mux *imux = &spec->private_imux; |
| 6552 | int i, err, idx, idx1; |
| 6553 | |
| 6554 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 6555 | switch(cfg->input_pins[i]) { |
| 6556 | case 0x0c: |
| 6557 | idx1 = 1; |
| 6558 | idx = 2; // Line In |
| 6559 | break; |
| 6560 | case 0x0f: |
| 6561 | idx1 = 2; |
| 6562 | idx = 2; // Line In |
| 6563 | break; |
| 6564 | case 0x0d: |
| 6565 | idx1 = 0; |
| 6566 | idx = 1; // Mic In |
| 6567 | break; |
| 6568 | case 0x10: |
| 6569 | idx1 = 3; |
| 6570 | idx = 1; // Mic In |
| 6571 | break; |
| 6572 | case 0x11: |
| 6573 | idx1 = 4; |
| 6574 | idx = 0; // CD |
| 6575 | break; |
| 6576 | default: |
| 6577 | continue; |
| 6578 | } |
| 6579 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 6580 | err = new_analog_input(spec, cfg->input_pins[i], |
| 6581 | auto_pin_cfg_labels[i], idx, 0x15); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6582 | if (err < 0) |
| 6583 | return err; |
| 6584 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 6585 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6586 | imux->items[imux->num_items].index = idx1; |
| 6587 | imux->num_items++; |
| 6588 | } |
| 6589 | return 0; |
| 6590 | } |
| 6591 | |
| 6592 | static struct snd_kcontrol_new alc861_capture_mixer[] = { |
| 6593 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
| 6594 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
| 6595 | |
| 6596 | { |
| 6597 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6598 | /* The multiple "Capture Source" controls confuse alsamixer |
| 6599 | * So call somewhat different.. |
| 6600 | *FIXME: the controls appear in the "playback" view! |
| 6601 | */ |
| 6602 | /* .name = "Capture Source", */ |
| 6603 | .name = "Input Source", |
| 6604 | .count = 1, |
| 6605 | .info = alc_mux_enum_info, |
| 6606 | .get = alc_mux_enum_get, |
| 6607 | .put = alc_mux_enum_put, |
| 6608 | }, |
| 6609 | { } /* end */ |
| 6610 | }; |
| 6611 | |
| 6612 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, |
| 6613 | int pin_type, int dac_idx) |
| 6614 | { |
| 6615 | /* set as output */ |
| 6616 | |
| 6617 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 6618 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 6619 | |
| 6620 | } |
| 6621 | |
| 6622 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
| 6623 | { |
| 6624 | struct alc_spec *spec = codec->spec; |
| 6625 | int i; |
| 6626 | |
| 6627 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 6628 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 6629 | if (nid) |
| 6630 | alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); |
| 6631 | } |
| 6632 | } |
| 6633 | |
| 6634 | static void alc861_auto_init_hp_out(struct hda_codec *codec) |
| 6635 | { |
| 6636 | struct alc_spec *spec = codec->spec; |
| 6637 | hda_nid_t pin; |
| 6638 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 6639 | pin = spec->autocfg.hp_pins[0]; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6640 | if (pin) /* connect to front */ |
| 6641 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); |
| 6642 | } |
| 6643 | |
| 6644 | static void alc861_auto_init_analog_input(struct hda_codec *codec) |
| 6645 | { |
| 6646 | struct alc_spec *spec = codec->spec; |
| 6647 | int i; |
| 6648 | |
| 6649 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 6650 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 6651 | if ((nid>=0x0c) && (nid <=0x11)) { |
| 6652 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 6653 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 6654 | } |
| 6655 | } |
| 6656 | } |
| 6657 | |
| 6658 | /* parse the BIOS configuration and set up the alc_spec */ |
| 6659 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 6660 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6661 | { |
| 6662 | struct alc_spec *spec = codec->spec; |
| 6663 | int err; |
| 6664 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
| 6665 | |
| 6666 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
| 6667 | alc861_ignore)) < 0) |
| 6668 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 6669 | if (! spec->autocfg.line_outs) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6670 | return 0; /* can't find valid BIOS pin config */ |
| 6671 | |
| 6672 | if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || |
| 6673 | (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 6674 | (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6675 | (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 6676 | return err; |
| 6677 | |
| 6678 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 6679 | |
| 6680 | if (spec->autocfg.dig_out_pin) |
| 6681 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; |
| 6682 | |
| 6683 | if (spec->kctl_alloc) |
| 6684 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 6685 | |
| 6686 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; |
| 6687 | |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 6688 | spec->num_mux_defs = 1; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6689 | spec->input_mux = &spec->private_imux; |
| 6690 | |
| 6691 | spec->adc_nids = alc861_adc_nids; |
| 6692 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
| 6693 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; |
| 6694 | spec->num_mixers++; |
| 6695 | |
| 6696 | return 1; |
| 6697 | } |
| 6698 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 6699 | /* additional initialization for auto-configuration model */ |
| 6700 | static void alc861_auto_init(struct hda_codec *codec) |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6701 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6702 | alc861_auto_init_multi_out(codec); |
| 6703 | alc861_auto_init_hp_out(codec); |
| 6704 | alc861_auto_init_analog_input(codec); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6705 | } |
| 6706 | |
| 6707 | |
| 6708 | /* |
| 6709 | * configuration and preset |
| 6710 | */ |
| 6711 | static struct hda_board_config alc861_cfg_tbl[] = { |
| 6712 | { .modelname = "3stack", .config = ALC861_3ST }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6713 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, |
| 6714 | .config = ALC861_3ST }, |
Takashi Iwai | 4b146cb | 2006-07-28 14:42:36 +0200 | [diff] [blame] | 6715 | { .modelname = "3stack-660", .config = ALC660_3ST }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6716 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7, |
| 6717 | .config = ALC660_3ST }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6718 | { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, |
| 6719 | { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 6720 | { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31}, |
| 6721 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072, |
| 6722 | .config = ALC861_UNIWILL_M31 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6723 | { .modelname = "auto", .config = ALC861_AUTO }, |
| 6724 | {} |
| 6725 | }; |
| 6726 | |
| 6727 | static struct alc_config_preset alc861_presets[] = { |
| 6728 | [ALC861_3ST] = { |
| 6729 | .mixers = { alc861_3ST_mixer }, |
| 6730 | .init_verbs = { alc861_threestack_init_verbs }, |
| 6731 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 6732 | .dac_nids = alc861_dac_nids, |
| 6733 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 6734 | .channel_mode = alc861_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 6735 | .need_dac_fix = 1, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6736 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 6737 | .adc_nids = alc861_adc_nids, |
| 6738 | .input_mux = &alc861_capture_source, |
| 6739 | }, |
| 6740 | [ALC861_3ST_DIG] = { |
| 6741 | .mixers = { alc861_base_mixer }, |
| 6742 | .init_verbs = { alc861_threestack_init_verbs }, |
| 6743 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 6744 | .dac_nids = alc861_dac_nids, |
| 6745 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 6746 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 6747 | .channel_mode = alc861_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 6748 | .need_dac_fix = 1, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6749 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 6750 | .adc_nids = alc861_adc_nids, |
| 6751 | .input_mux = &alc861_capture_source, |
| 6752 | }, |
| 6753 | [ALC861_6ST_DIG] = { |
| 6754 | .mixers = { alc861_base_mixer }, |
| 6755 | .init_verbs = { alc861_base_init_verbs }, |
| 6756 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 6757 | .dac_nids = alc861_dac_nids, |
| 6758 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 6759 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), |
| 6760 | .channel_mode = alc861_8ch_modes, |
| 6761 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 6762 | .adc_nids = alc861_adc_nids, |
| 6763 | .input_mux = &alc861_capture_source, |
| 6764 | }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6765 | [ALC660_3ST] = { |
| 6766 | .mixers = { alc861_3ST_mixer }, |
| 6767 | .init_verbs = { alc861_threestack_init_verbs }, |
| 6768 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), |
| 6769 | .dac_nids = alc660_dac_nids, |
| 6770 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), |
| 6771 | .channel_mode = alc861_threestack_modes, |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 6772 | .need_dac_fix = 1, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6773 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 6774 | .adc_nids = alc861_adc_nids, |
| 6775 | .input_mux = &alc861_capture_source, |
| 6776 | }, |
Takashi Iwai | 22309c3 | 2006-08-09 16:57:28 +0200 | [diff] [blame] | 6777 | [ALC861_UNIWILL_M31] = { |
| 6778 | .mixers = { alc861_uniwill_m31_mixer }, |
| 6779 | .init_verbs = { alc861_uniwill_m31_init_verbs }, |
| 6780 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
| 6781 | .dac_nids = alc861_dac_nids, |
| 6782 | .dig_out_nid = ALC861_DIGOUT_NID, |
| 6783 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), |
| 6784 | .channel_mode = alc861_uniwill_m31_modes, |
| 6785 | .need_dac_fix = 1, |
| 6786 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
| 6787 | .adc_nids = alc861_adc_nids, |
| 6788 | .input_mux = &alc861_capture_source, |
| 6789 | }, |
| 6790 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6791 | }; |
| 6792 | |
| 6793 | |
| 6794 | static int patch_alc861(struct hda_codec *codec) |
| 6795 | { |
| 6796 | struct alc_spec *spec; |
| 6797 | int board_config; |
| 6798 | int err; |
| 6799 | |
| 6800 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
| 6801 | if (spec == NULL) |
| 6802 | return -ENOMEM; |
| 6803 | |
| 6804 | codec->spec = spec; |
| 6805 | |
| 6806 | board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6807 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6808 | if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6809 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
| 6810 | "trying auto-probe from BIOS...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6811 | board_config = ALC861_AUTO; |
| 6812 | } |
| 6813 | |
| 6814 | if (board_config == ALC861_AUTO) { |
| 6815 | /* automatic parse from the BIOS config */ |
| 6816 | err = alc861_parse_auto_config(codec); |
| 6817 | if (err < 0) { |
| 6818 | alc_free(codec); |
| 6819 | return err; |
| 6820 | } else if (! err) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6821 | printk(KERN_INFO |
| 6822 | "hda_codec: Cannot set up configuration " |
| 6823 | "from BIOS. Using base mode...\n"); |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6824 | board_config = ALC861_3ST_DIG; |
| 6825 | } |
| 6826 | } |
| 6827 | |
| 6828 | if (board_config != ALC861_AUTO) |
| 6829 | setup_preset(spec, &alc861_presets[board_config]); |
| 6830 | |
| 6831 | spec->stream_name_analog = "ALC861 Analog"; |
| 6832 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
| 6833 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
| 6834 | |
| 6835 | spec->stream_name_digital = "ALC861 Digital"; |
| 6836 | spec->stream_digital_playback = &alc861_pcm_digital_playback; |
| 6837 | spec->stream_digital_capture = &alc861_pcm_digital_capture; |
| 6838 | |
| 6839 | codec->patch_ops = alc_patch_ops; |
| 6840 | if (board_config == ALC861_AUTO) |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 6841 | spec->init_hook = alc861_auto_init; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6842 | |
| 6843 | return 0; |
| 6844 | } |
| 6845 | |
| 6846 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6847 | * patch entries |
| 6848 | */ |
| 6849 | struct hda_codec_preset snd_hda_preset_realtek[] = { |
| 6850 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6851 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6852 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
| 6853 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6854 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6855 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 6856 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
| 6857 | { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861", |
| 6858 | .patch = patch_alc861 }, |
| 6859 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
| 6860 | .patch = patch_alc861 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6861 | {} /* terminator */ |
| 6862 | }; |