Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 2 | * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984, |
| 3 | * AD1986A, AD1988 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 5 | * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This driver is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This driver is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include <sound/driver.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/pci.h> |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 27 | #include <linux/mutex.h> |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <sound/core.h> |
| 30 | #include "hda_codec.h" |
| 31 | #include "hda_local.h" |
| 32 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 33 | struct ad198x_spec { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 34 | struct snd_kcontrol_new *mixers[5]; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 35 | int num_mixers; |
| 36 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 37 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 38 | * don't forget NULL termination! |
| 39 | */ |
| 40 | unsigned int num_init_verbs; |
| 41 | |
| 42 | /* playback */ |
| 43 | struct hda_multi_out multiout; /* playback set-up |
| 44 | * max_channels, dacs must be set |
| 45 | * dig_out_nid and hp_nid are optional |
| 46 | */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 47 | unsigned int cur_eapd; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 48 | unsigned int need_dac_fix; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 49 | |
| 50 | /* capture */ |
| 51 | unsigned int num_adc_nids; |
| 52 | hda_nid_t *adc_nids; |
| 53 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 54 | |
| 55 | /* capture source */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 56 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 57 | hda_nid_t *capsrc_nids; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 58 | unsigned int cur_mux[3]; |
| 59 | |
| 60 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 61 | const struct hda_channel_mode *channel_mode; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 62 | int num_channel_mode; |
| 63 | |
| 64 | /* PCM information */ |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 65 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 66 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 67 | struct mutex amp_mutex; /* PCM volume/mute control mutex */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 68 | unsigned int spdif_route; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 69 | |
| 70 | /* dynamic controls, init_verbs and input_mux */ |
| 71 | struct auto_pin_cfg autocfg; |
| 72 | unsigned int num_kctl_alloc, num_kctl_used; |
| 73 | struct snd_kcontrol_new *kctl_alloc; |
| 74 | struct hda_input_mux private_imux; |
| 75 | hda_nid_t private_dac_nids[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 78 | /* |
| 79 | * input MUX handling (common part) |
| 80 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 81 | static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 82 | { |
| 83 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 84 | struct ad198x_spec *spec = codec->spec; |
| 85 | |
| 86 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 87 | } |
| 88 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 89 | static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 90 | { |
| 91 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 92 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 93 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 94 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 95 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 96 | return 0; |
| 97 | } |
| 98 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 99 | static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 100 | { |
| 101 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 102 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 103 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 104 | |
| 105 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 106 | spec->capsrc_nids[adc_idx], |
| 107 | &spec->cur_mux[adc_idx]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /* |
| 111 | * initialization (common callbacks) |
| 112 | */ |
| 113 | static int ad198x_init(struct hda_codec *codec) |
| 114 | { |
| 115 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 116 | int i; |
| 117 | |
| 118 | for (i = 0; i < spec->num_init_verbs; i++) |
| 119 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static int ad198x_build_controls(struct hda_codec *codec) |
| 124 | { |
| 125 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 126 | unsigned int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 127 | int err; |
| 128 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 129 | for (i = 0; i < spec->num_mixers; i++) { |
| 130 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 131 | if (err < 0) |
| 132 | return err; |
| 133 | } |
| 134 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 135 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 136 | if (err < 0) |
| 137 | return err; |
| 138 | } |
| 139 | if (spec->dig_in_nid) { |
| 140 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 141 | if (err < 0) |
| 142 | return err; |
| 143 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Analog playback callbacks |
| 149 | */ |
| 150 | static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 151 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 152 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 153 | { |
| 154 | struct ad198x_spec *spec = codec->spec; |
| 155 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 156 | } |
| 157 | |
| 158 | static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 159 | struct hda_codec *codec, |
| 160 | unsigned int stream_tag, |
| 161 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 162 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 163 | { |
| 164 | struct ad198x_spec *spec = codec->spec; |
| 165 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 166 | format, substream); |
| 167 | } |
| 168 | |
| 169 | static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 170 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 171 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 172 | { |
| 173 | struct ad198x_spec *spec = codec->spec; |
| 174 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 175 | } |
| 176 | |
| 177 | /* |
| 178 | * Digital out |
| 179 | */ |
| 180 | static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 181 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 182 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 183 | { |
| 184 | struct ad198x_spec *spec = codec->spec; |
| 185 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 186 | } |
| 187 | |
| 188 | static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 189 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 190 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 191 | { |
| 192 | struct ad198x_spec *spec = codec->spec; |
| 193 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 194 | } |
| 195 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 196 | static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 197 | struct hda_codec *codec, |
| 198 | unsigned int stream_tag, |
| 199 | unsigned int format, |
| 200 | struct snd_pcm_substream *substream) |
| 201 | { |
| 202 | struct ad198x_spec *spec = codec->spec; |
| 203 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
| 204 | format, substream); |
| 205 | } |
| 206 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 207 | /* |
| 208 | * Analog capture |
| 209 | */ |
| 210 | static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 211 | struct hda_codec *codec, |
| 212 | unsigned int stream_tag, |
| 213 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 214 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 215 | { |
| 216 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 217 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 218 | stream_tag, 0, format); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 223 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 224 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 225 | { |
| 226 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 227 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 228 | 0, 0, 0); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | /* |
| 234 | */ |
| 235 | static struct hda_pcm_stream ad198x_pcm_analog_playback = { |
| 236 | .substreams = 1, |
| 237 | .channels_min = 2, |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 238 | .channels_max = 6, /* changed later */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 239 | .nid = 0, /* fill later */ |
| 240 | .ops = { |
| 241 | .open = ad198x_playback_pcm_open, |
| 242 | .prepare = ad198x_playback_pcm_prepare, |
| 243 | .cleanup = ad198x_playback_pcm_cleanup |
| 244 | }, |
| 245 | }; |
| 246 | |
| 247 | static struct hda_pcm_stream ad198x_pcm_analog_capture = { |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 248 | .substreams = 1, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 249 | .channels_min = 2, |
| 250 | .channels_max = 2, |
| 251 | .nid = 0, /* fill later */ |
| 252 | .ops = { |
| 253 | .prepare = ad198x_capture_pcm_prepare, |
| 254 | .cleanup = ad198x_capture_pcm_cleanup |
| 255 | }, |
| 256 | }; |
| 257 | |
| 258 | static struct hda_pcm_stream ad198x_pcm_digital_playback = { |
| 259 | .substreams = 1, |
| 260 | .channels_min = 2, |
| 261 | .channels_max = 2, |
| 262 | .nid = 0, /* fill later */ |
| 263 | .ops = { |
| 264 | .open = ad198x_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 265 | .close = ad198x_dig_playback_pcm_close, |
| 266 | .prepare = ad198x_dig_playback_pcm_prepare |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 267 | }, |
| 268 | }; |
| 269 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 270 | static struct hda_pcm_stream ad198x_pcm_digital_capture = { |
| 271 | .substreams = 1, |
| 272 | .channels_min = 2, |
| 273 | .channels_max = 2, |
| 274 | /* NID is set in alc_build_pcms */ |
| 275 | }; |
| 276 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 277 | static int ad198x_build_pcms(struct hda_codec *codec) |
| 278 | { |
| 279 | struct ad198x_spec *spec = codec->spec; |
| 280 | struct hda_pcm *info = spec->pcm_rec; |
| 281 | |
| 282 | codec->num_pcms = 1; |
| 283 | codec->pcm_info = info; |
| 284 | |
| 285 | info->name = "AD198x Analog"; |
| 286 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; |
| 287 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; |
| 288 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 289 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 290 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; |
| 291 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 292 | |
| 293 | if (spec->multiout.dig_out_nid) { |
| 294 | info++; |
| 295 | codec->num_pcms++; |
| 296 | info->name = "AD198x Digital"; |
| 297 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; |
| 298 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 299 | if (spec->dig_in_nid) { |
| 300 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture; |
| 301 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 302 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static void ad198x_free(struct hda_codec *codec) |
| 309 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 310 | struct ad198x_spec *spec = codec->spec; |
| 311 | unsigned int i; |
| 312 | |
| 313 | if (spec->kctl_alloc) { |
| 314 | for (i = 0; i < spec->num_kctl_used; i++) |
| 315 | kfree(spec->kctl_alloc[i].name); |
| 316 | kfree(spec->kctl_alloc); |
| 317 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 318 | kfree(codec->spec); |
| 319 | } |
| 320 | |
| 321 | #ifdef CONFIG_PM |
| 322 | static int ad198x_resume(struct hda_codec *codec) |
| 323 | { |
| 324 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 325 | int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 326 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 327 | codec->patch_ops.init(codec); |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 328 | for (i = 0; i < spec->num_mixers; i++) |
| 329 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
| 330 | if (spec->multiout.dig_out_nid) |
| 331 | snd_hda_resume_spdif_out(codec); |
| 332 | if (spec->dig_in_nid) |
| 333 | snd_hda_resume_spdif_in(codec); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 334 | return 0; |
| 335 | } |
| 336 | #endif |
| 337 | |
| 338 | static struct hda_codec_ops ad198x_patch_ops = { |
| 339 | .build_controls = ad198x_build_controls, |
| 340 | .build_pcms = ad198x_build_pcms, |
| 341 | .init = ad198x_init, |
| 342 | .free = ad198x_free, |
| 343 | #ifdef CONFIG_PM |
| 344 | .resume = ad198x_resume, |
| 345 | #endif |
| 346 | }; |
| 347 | |
| 348 | |
| 349 | /* |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 350 | * EAPD control |
| 351 | * the private value = nid | (invert << 8) |
| 352 | */ |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 353 | #define ad198x_eapd_info snd_ctl_boolean_mono_info |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 354 | |
| 355 | static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, |
| 356 | struct snd_ctl_elem_value *ucontrol) |
| 357 | { |
| 358 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 359 | struct ad198x_spec *spec = codec->spec; |
| 360 | int invert = (kcontrol->private_value >> 8) & 1; |
| 361 | if (invert) |
| 362 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; |
| 363 | else |
| 364 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, |
| 369 | struct snd_ctl_elem_value *ucontrol) |
| 370 | { |
| 371 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 372 | struct ad198x_spec *spec = codec->spec; |
| 373 | int invert = (kcontrol->private_value >> 8) & 1; |
| 374 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 375 | unsigned int eapd; |
| 376 | eapd = ucontrol->value.integer.value[0]; |
| 377 | if (invert) |
| 378 | eapd = !eapd; |
| 379 | if (eapd == spec->cur_eapd && ! codec->in_resume) |
| 380 | return 0; |
| 381 | spec->cur_eapd = eapd; |
| 382 | snd_hda_codec_write(codec, nid, |
| 383 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 384 | eapd ? 0x02 : 0x00); |
| 385 | return 1; |
| 386 | } |
| 387 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 388 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 389 | struct snd_ctl_elem_info *uinfo); |
| 390 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 391 | struct snd_ctl_elem_value *ucontrol); |
| 392 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 393 | struct snd_ctl_elem_value *ucontrol); |
| 394 | |
| 395 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 396 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 397 | * AD1986A specific |
| 398 | */ |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | #define AD1986A_SPDIF_OUT 0x02 |
| 401 | #define AD1986A_FRONT_DAC 0x03 |
| 402 | #define AD1986A_SURR_DAC 0x04 |
| 403 | #define AD1986A_CLFE_DAC 0x05 |
| 404 | #define AD1986A_ADC 0x06 |
| 405 | |
| 406 | static hda_nid_t ad1986a_dac_nids[3] = { |
| 407 | AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC |
| 408 | }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 409 | static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 410 | static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
| 412 | static struct hda_input_mux ad1986a_capture_source = { |
| 413 | .num_items = 7, |
| 414 | .items = { |
| 415 | { "Mic", 0x0 }, |
| 416 | { "CD", 0x1 }, |
| 417 | { "Aux", 0x3 }, |
| 418 | { "Line", 0x4 }, |
| 419 | { "Mix", 0x5 }, |
| 420 | { "Mono", 0x6 }, |
| 421 | { "Phone", 0x7 }, |
| 422 | }, |
| 423 | }; |
| 424 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 426 | static struct hda_bind_ctls ad1986a_bind_pcm_vol = { |
| 427 | .ops = &snd_hda_bind_vol, |
| 428 | .values = { |
| 429 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 430 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 431 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 432 | 0 |
| 433 | }, |
| 434 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 436 | static struct hda_bind_ctls ad1986a_bind_pcm_sw = { |
| 437 | .ops = &snd_hda_bind_sw, |
| 438 | .values = { |
| 439 | HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT), |
| 440 | HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT), |
| 441 | HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT), |
| 442 | 0 |
| 443 | }, |
| 444 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
| 446 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | * mixers |
| 448 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 449 | static struct snd_kcontrol_new ad1986a_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 450 | /* |
| 451 | * bind volumes/mutes of 3 DACs as a single PCM control for simplicity |
| 452 | */ |
| 453 | HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol), |
| 454 | HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 456 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 457 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 458 | HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 459 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 460 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 461 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 462 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 463 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 464 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 465 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 466 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 467 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 468 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 469 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 470 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 471 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 472 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 473 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 475 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 476 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 477 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), |
| 478 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 479 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 480 | { |
| 481 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 482 | .name = "Capture Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 483 | .info = ad198x_mux_enum_info, |
| 484 | .get = ad198x_mux_enum_get, |
| 485 | .put = ad198x_mux_enum_put, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | }, |
| 487 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), |
| 488 | { } /* end */ |
| 489 | }; |
| 490 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 491 | /* additional mixers for 3stack mode */ |
| 492 | static struct snd_kcontrol_new ad1986a_3st_mixers[] = { |
| 493 | { |
| 494 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 495 | .name = "Channel Mode", |
| 496 | .info = ad198x_ch_mode_info, |
| 497 | .get = ad198x_ch_mode_get, |
| 498 | .put = ad198x_ch_mode_put, |
| 499 | }, |
| 500 | { } /* end */ |
| 501 | }; |
| 502 | |
| 503 | /* laptop model - 2ch only */ |
| 504 | static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC }; |
| 505 | |
| 506 | static struct snd_kcontrol_new ad1986a_laptop_mixers[] = { |
| 507 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 508 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 509 | HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 510 | HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 511 | /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 512 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */ |
| 513 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 514 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 515 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 516 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 517 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 518 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 519 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 520 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 521 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 522 | /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 523 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 524 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 525 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ |
| 526 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 527 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 528 | { |
| 529 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 530 | .name = "Capture Source", |
| 531 | .info = ad198x_mux_enum_info, |
| 532 | .get = ad198x_mux_enum_get, |
| 533 | .put = ad198x_mux_enum_put, |
| 534 | }, |
| 535 | { } /* end */ |
| 536 | }; |
| 537 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 538 | /* laptop-eapd model - 2ch only */ |
| 539 | |
| 540 | /* master controls both pins 0x1a and 0x1b */ |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 541 | static struct hda_bind_ctls ad1986a_laptop_master_vol = { |
| 542 | .ops = &snd_hda_bind_vol, |
| 543 | .values = { |
| 544 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 545 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 546 | 0, |
| 547 | }, |
| 548 | }; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 549 | |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 550 | static struct hda_bind_ctls ad1986a_laptop_master_sw = { |
| 551 | .ops = &snd_hda_bind_sw, |
| 552 | .values = { |
| 553 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 554 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 555 | 0, |
| 556 | }, |
| 557 | }; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 558 | |
| 559 | static struct hda_input_mux ad1986a_laptop_eapd_capture_source = { |
| 560 | .num_items = 3, |
| 561 | .items = { |
| 562 | { "Mic", 0x0 }, |
| 563 | { "Internal Mic", 0x4 }, |
| 564 | { "Mix", 0x5 }, |
| 565 | }, |
| 566 | }; |
| 567 | |
| 568 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
Takashi Iwai | 532d538 | 2007-07-27 19:02:40 +0200 | [diff] [blame^] | 569 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
| 570 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 571 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 572 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 573 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 574 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 575 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 576 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Takashi Iwai | fe8970b | 2007-02-26 16:00:34 +0100 | [diff] [blame] | 577 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 578 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 579 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 580 | { |
| 581 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 582 | .name = "Capture Source", |
| 583 | .info = ad198x_mux_enum_info, |
| 584 | .get = ad198x_mux_enum_get, |
| 585 | .put = ad198x_mux_enum_put, |
| 586 | }, |
| 587 | { |
| 588 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 589 | .name = "External Amplifier", |
| 590 | .info = ad198x_eapd_info, |
| 591 | .get = ad198x_eapd_get, |
| 592 | .put = ad198x_eapd_put, |
| 593 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ |
| 594 | }, |
| 595 | { } /* end */ |
| 596 | }; |
| 597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | /* |
| 599 | * initialization verbs |
| 600 | */ |
| 601 | static struct hda_verb ad1986a_init_verbs[] = { |
| 602 | /* Front, Surround, CLFE DAC; mute as default */ |
| 603 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 604 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 605 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 606 | /* Downmix - off */ |
| 607 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 608 | /* HP, Line-Out, Surround, CLFE selectors */ |
| 609 | {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 610 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 611 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 612 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 613 | /* Mono selector */ |
| 614 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 615 | /* Mic selector: Mic 1/2 pin */ |
| 616 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 617 | /* Line-in selector: Line-in */ |
| 618 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 619 | /* Mic 1/2 swap */ |
| 620 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 621 | /* Record selector: mic */ |
| 622 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 623 | /* Mic, Phone, CD, Aux, Line-In amp; mute as default */ |
| 624 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 625 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 626 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 627 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 628 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 629 | /* PC beep */ |
| 630 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 631 | /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */ |
| 632 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 633 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 634 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 635 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 636 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 637 | /* HP Pin */ |
| 638 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 639 | /* Front, Surround, CLFE Pins */ |
| 640 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 641 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 642 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 643 | /* Mono Pin */ |
| 644 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 645 | /* Mic Pin */ |
| 646 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 647 | /* Line, Aux, CD, Beep-In Pin */ |
| 648 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 649 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 650 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 651 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 652 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | { } /* end */ |
| 654 | }; |
| 655 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 656 | static struct hda_verb ad1986a_ch2_init[] = { |
| 657 | /* Surround out -> Line In */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 658 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 659 | /* Line-in selectors */ |
| 660 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 661 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 662 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 663 | /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */ |
| 664 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 665 | { } /* end */ |
| 666 | }; |
| 667 | |
| 668 | static struct hda_verb ad1986a_ch4_init[] = { |
| 669 | /* Surround out -> Surround */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 670 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 671 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 672 | /* CLFE -> Mic in */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 673 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 674 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 675 | { } /* end */ |
| 676 | }; |
| 677 | |
| 678 | static struct hda_verb ad1986a_ch6_init[] = { |
| 679 | /* Surround out -> Surround out */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 680 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 681 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 682 | /* CLFE -> CLFE */ |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 683 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
| 684 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 685 | { } /* end */ |
| 686 | }; |
| 687 | |
| 688 | static struct hda_channel_mode ad1986a_modes[3] = { |
| 689 | { 2, ad1986a_ch2_init }, |
| 690 | { 4, ad1986a_ch4_init }, |
| 691 | { 6, ad1986a_ch6_init }, |
| 692 | }; |
| 693 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 694 | /* eapd initialization */ |
| 695 | static struct hda_verb ad1986a_eapd_init_verbs[] = { |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 696 | {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 697 | {} |
| 698 | }; |
| 699 | |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 700 | /* Ultra initialization */ |
| 701 | static struct hda_verb ad1986a_ultra_init[] = { |
| 702 | /* eapd initialization */ |
| 703 | { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, |
| 704 | /* CLFE -> Mic in */ |
| 705 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 }, |
| 706 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 707 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
| 708 | { } /* end */ |
| 709 | }; |
| 710 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 711 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 712 | enum { |
| 713 | AD1986A_6STACK, |
| 714 | AD1986A_3STACK, |
| 715 | AD1986A_LAPTOP, |
| 716 | AD1986A_LAPTOP_EAPD, |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 717 | AD1986A_ULTRA, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 718 | AD1986A_MODELS |
| 719 | }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 720 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 721 | static const char *ad1986a_models[AD1986A_MODELS] = { |
| 722 | [AD1986A_6STACK] = "6stack", |
| 723 | [AD1986A_3STACK] = "3stack", |
| 724 | [AD1986A_LAPTOP] = "laptop", |
| 725 | [AD1986A_LAPTOP_EAPD] = "laptop-eapd", |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 726 | [AD1986A_ULTRA] = "ultra", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 727 | }; |
| 728 | |
| 729 | static struct snd_pci_quirk ad1986a_cfg_tbl[] = { |
| 730 | SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD), |
| 731 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), |
| 732 | SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD), |
| 733 | SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD), |
| 734 | SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD), |
| 735 | SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD), |
| 736 | SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), |
| 737 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), |
| 738 | SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), |
Tobin Davis | 658fba0 | 2007-04-23 16:41:12 +0200 | [diff] [blame] | 739 | SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 740 | SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), |
| 741 | SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), |
| 742 | SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), |
| 743 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), |
| 744 | SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 745 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 746 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), |
| 747 | SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD), |
| 748 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD), |
| 749 | SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD), |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 750 | SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), |
| 751 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 752 | SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 753 | SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), |
| 754 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD), |
| 755 | SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP), |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 756 | {} |
| 757 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | static int patch_ad1986a(struct hda_codec *codec) |
| 760 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 761 | struct ad198x_spec *spec; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 762 | int board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 764 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | if (spec == NULL) |
| 766 | return -ENOMEM; |
| 767 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | codec->spec = spec; |
| 769 | |
| 770 | spec->multiout.max_channels = 6; |
| 771 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); |
| 772 | spec->multiout.dac_nids = ad1986a_dac_nids; |
| 773 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 774 | spec->num_adc_nids = 1; |
| 775 | spec->adc_nids = ad1986a_adc_nids; |
Takashi Iwai | a7ee820 | 2006-03-01 20:05:39 +0100 | [diff] [blame] | 776 | spec->capsrc_nids = ad1986a_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 777 | spec->input_mux = &ad1986a_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 778 | spec->num_mixers = 1; |
| 779 | spec->mixers[0] = ad1986a_mixers; |
| 780 | spec->num_init_verbs = 1; |
| 781 | spec->init_verbs[0] = ad1986a_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 783 | codec->patch_ops = ad198x_patch_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 785 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 786 | board_config = snd_hda_check_board_config(codec, AD1986A_MODELS, |
| 787 | ad1986a_models, |
| 788 | ad1986a_cfg_tbl); |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 789 | switch (board_config) { |
| 790 | case AD1986A_3STACK: |
| 791 | spec->num_mixers = 2; |
| 792 | spec->mixers[1] = ad1986a_3st_mixers; |
Takashi Iwai | fb956c1 | 2007-04-18 23:03:56 +0200 | [diff] [blame] | 793 | spec->num_init_verbs = 2; |
| 794 | spec->init_verbs[1] = ad1986a_ch2_init; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 795 | spec->channel_mode = ad1986a_modes; |
| 796 | spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 797 | spec->need_dac_fix = 1; |
| 798 | spec->multiout.max_channels = 2; |
| 799 | spec->multiout.num_dacs = 1; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 800 | break; |
| 801 | case AD1986A_LAPTOP: |
| 802 | spec->mixers[0] = ad1986a_laptop_mixers; |
| 803 | spec->multiout.max_channels = 2; |
| 804 | spec->multiout.num_dacs = 1; |
| 805 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 806 | break; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 807 | case AD1986A_LAPTOP_EAPD: |
| 808 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 809 | spec->num_init_verbs = 2; |
| 810 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 811 | spec->multiout.max_channels = 2; |
| 812 | spec->multiout.num_dacs = 1; |
| 813 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 814 | spec->multiout.dig_out_nid = 0; |
| 815 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 816 | break; |
Tobin Davis | f36090f | 2007-01-08 11:07:12 +0100 | [diff] [blame] | 817 | case AD1986A_ULTRA: |
| 818 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 819 | spec->num_init_verbs = 2; |
| 820 | spec->init_verbs[1] = ad1986a_ultra_init; |
| 821 | spec->multiout.max_channels = 2; |
| 822 | spec->multiout.num_dacs = 1; |
| 823 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 824 | spec->multiout.dig_out_nid = 0; |
| 825 | break; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 826 | } |
| 827 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | return 0; |
| 829 | } |
| 830 | |
| 831 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 832 | * AD1983 specific |
| 833 | */ |
| 834 | |
| 835 | #define AD1983_SPDIF_OUT 0x02 |
| 836 | #define AD1983_DAC 0x03 |
| 837 | #define AD1983_ADC 0x04 |
| 838 | |
| 839 | static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 840 | static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 841 | static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 842 | |
| 843 | static struct hda_input_mux ad1983_capture_source = { |
| 844 | .num_items = 4, |
| 845 | .items = { |
| 846 | { "Mic", 0x0 }, |
| 847 | { "Line", 0x1 }, |
| 848 | { "Mix", 0x2 }, |
| 849 | { "Mix Mono", 0x3 }, |
| 850 | }, |
| 851 | }; |
| 852 | |
| 853 | /* |
| 854 | * SPDIF playback route |
| 855 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 856 | static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 857 | { |
| 858 | static char *texts[] = { "PCM", "ADC" }; |
| 859 | |
| 860 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 861 | uinfo->count = 1; |
| 862 | uinfo->value.enumerated.items = 2; |
| 863 | if (uinfo->value.enumerated.item > 1) |
| 864 | uinfo->value.enumerated.item = 1; |
| 865 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 866 | return 0; |
| 867 | } |
| 868 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 869 | static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 870 | { |
| 871 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 872 | struct ad198x_spec *spec = codec->spec; |
| 873 | |
| 874 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
| 875 | return 0; |
| 876 | } |
| 877 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 878 | static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 879 | { |
| 880 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 881 | struct ad198x_spec *spec = codec->spec; |
| 882 | |
| 883 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { |
| 884 | spec->spdif_route = ucontrol->value.enumerated.item[0]; |
| 885 | snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, |
| 886 | AC_VERB_SET_CONNECT_SEL, spec->spdif_route); |
| 887 | return 1; |
| 888 | } |
| 889 | return 0; |
| 890 | } |
| 891 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 892 | static struct snd_kcontrol_new ad1983_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 893 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 894 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 895 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 896 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 897 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 898 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 899 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 900 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 901 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 902 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 903 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 904 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 905 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT), |
| 906 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT), |
| 907 | HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), |
| 908 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 909 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 910 | { |
| 911 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 912 | .name = "Capture Source", |
| 913 | .info = ad198x_mux_enum_info, |
| 914 | .get = ad198x_mux_enum_get, |
| 915 | .put = ad198x_mux_enum_put, |
| 916 | }, |
| 917 | { |
| 918 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 919 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 920 | .info = ad1983_spdif_route_info, |
| 921 | .get = ad1983_spdif_route_get, |
| 922 | .put = ad1983_spdif_route_put, |
| 923 | }, |
| 924 | { } /* end */ |
| 925 | }; |
| 926 | |
| 927 | static struct hda_verb ad1983_init_verbs[] = { |
| 928 | /* Front, HP, Mono; mute as default */ |
| 929 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 930 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 931 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 932 | /* Beep, PCM, Mic, Line-In: mute */ |
| 933 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 934 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 935 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 936 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 937 | /* Front, HP selectors; from Mix */ |
| 938 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 939 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 940 | /* Mono selector; from Mix */ |
| 941 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 942 | /* Mic selector; Mic */ |
| 943 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 944 | /* Line-in selector: Line-in */ |
| 945 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 946 | /* Mic boost: 0dB */ |
| 947 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 948 | /* Record selector: mic */ |
| 949 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 950 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 951 | /* SPDIF route: PCM */ |
| 952 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 953 | /* Front Pin */ |
| 954 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 955 | /* HP Pin */ |
| 956 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 957 | /* Mono Pin */ |
| 958 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 959 | /* Mic Pin */ |
| 960 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 961 | /* Line Pin */ |
| 962 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 963 | { } /* end */ |
| 964 | }; |
| 965 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 966 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 967 | static int patch_ad1983(struct hda_codec *codec) |
| 968 | { |
| 969 | struct ad198x_spec *spec; |
| 970 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 971 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 972 | if (spec == NULL) |
| 973 | return -ENOMEM; |
| 974 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 975 | codec->spec = spec; |
| 976 | |
| 977 | spec->multiout.max_channels = 2; |
| 978 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); |
| 979 | spec->multiout.dac_nids = ad1983_dac_nids; |
| 980 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 981 | spec->num_adc_nids = 1; |
| 982 | spec->adc_nids = ad1983_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 983 | spec->capsrc_nids = ad1983_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 984 | spec->input_mux = &ad1983_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 985 | spec->num_mixers = 1; |
| 986 | spec->mixers[0] = ad1983_mixers; |
| 987 | spec->num_init_verbs = 1; |
| 988 | spec->init_verbs[0] = ad1983_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 989 | spec->spdif_route = 0; |
| 990 | |
| 991 | codec->patch_ops = ad198x_patch_ops; |
| 992 | |
| 993 | return 0; |
| 994 | } |
| 995 | |
| 996 | |
| 997 | /* |
| 998 | * AD1981 HD specific |
| 999 | */ |
| 1000 | |
| 1001 | #define AD1981_SPDIF_OUT 0x02 |
| 1002 | #define AD1981_DAC 0x03 |
| 1003 | #define AD1981_ADC 0x04 |
| 1004 | |
| 1005 | static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1006 | static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1007 | static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1008 | |
| 1009 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
| 1010 | static struct hda_input_mux ad1981_capture_source = { |
| 1011 | .num_items = 7, |
| 1012 | .items = { |
| 1013 | { "Front Mic", 0x0 }, |
| 1014 | { "Line", 0x1 }, |
| 1015 | { "Mix", 0x2 }, |
| 1016 | { "Mix Mono", 0x3 }, |
| 1017 | { "CD", 0x4 }, |
| 1018 | { "Mic", 0x6 }, |
| 1019 | { "Aux", 0x7 }, |
| 1020 | }, |
| 1021 | }; |
| 1022 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1023 | static struct snd_kcontrol_new ad1981_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1024 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1025 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1026 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1027 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1028 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1029 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1030 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1031 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1032 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1033 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1034 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1035 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1036 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1037 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 1038 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1039 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1040 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1041 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1042 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1043 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1044 | HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1045 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1046 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1047 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1048 | { |
| 1049 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1050 | .name = "Capture Source", |
| 1051 | .info = ad198x_mux_enum_info, |
| 1052 | .get = ad198x_mux_enum_get, |
| 1053 | .put = ad198x_mux_enum_put, |
| 1054 | }, |
| 1055 | /* identical with AD1983 */ |
| 1056 | { |
| 1057 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1058 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1059 | .info = ad1983_spdif_route_info, |
| 1060 | .get = ad1983_spdif_route_get, |
| 1061 | .put = ad1983_spdif_route_put, |
| 1062 | }, |
| 1063 | { } /* end */ |
| 1064 | }; |
| 1065 | |
| 1066 | static struct hda_verb ad1981_init_verbs[] = { |
| 1067 | /* Front, HP, Mono; mute as default */ |
| 1068 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1069 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1070 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1071 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ |
| 1072 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1073 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1074 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1075 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1076 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1077 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1078 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1079 | /* Front, HP selectors; from Mix */ |
| 1080 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1081 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1082 | /* Mono selector; from Mix */ |
| 1083 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1084 | /* Mic Mixer; select Front Mic */ |
| 1085 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1086 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1087 | /* Mic boost: 0dB */ |
| 1088 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1089 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1090 | /* Record selector: Front mic */ |
| 1091 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1092 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1093 | /* SPDIF route: PCM */ |
| 1094 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1095 | /* Front Pin */ |
| 1096 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1097 | /* HP Pin */ |
| 1098 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1099 | /* Mono Pin */ |
| 1100 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1101 | /* Front & Rear Mic Pins */ |
| 1102 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1103 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1104 | /* Line Pin */ |
| 1105 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1106 | /* Digital Beep */ |
| 1107 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1108 | /* Line-Out as Input: disabled */ |
| 1109 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1110 | { } /* end */ |
| 1111 | }; |
| 1112 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1113 | /* |
| 1114 | * Patch for HP nx6320 |
| 1115 | * |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1116 | * nx6320 uses EAPD in the reverse way - EAPD-on means the internal |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1117 | * speaker output enabled _and_ mute-LED off. |
| 1118 | */ |
| 1119 | |
| 1120 | #define AD1981_HP_EVENT 0x37 |
| 1121 | #define AD1981_MIC_EVENT 0x38 |
| 1122 | |
| 1123 | static struct hda_verb ad1981_hp_init_verbs[] = { |
| 1124 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ |
| 1125 | /* pin sensing on HP and Mic jacks */ |
| 1126 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1127 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1128 | {} |
| 1129 | }; |
| 1130 | |
| 1131 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1132 | static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1133 | struct snd_ctl_elem_value *ucontrol) |
| 1134 | { |
| 1135 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1136 | struct ad198x_spec *spec = codec->spec; |
| 1137 | |
| 1138 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1139 | return 0; |
| 1140 | |
| 1141 | /* toggle HP mute appropriately */ |
| 1142 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1143 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1144 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1145 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1146 | return 1; |
| 1147 | } |
| 1148 | |
| 1149 | /* bind volumes of both NID 0x05 and 0x06 */ |
| 1150 | static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, |
| 1151 | struct snd_ctl_elem_value *ucontrol) |
| 1152 | { |
| 1153 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1154 | long *valp = ucontrol->value.integer.value; |
| 1155 | int change; |
| 1156 | |
| 1157 | change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1158 | 0x7f, valp[0] & 0x7f); |
| 1159 | change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1160 | 0x7f, valp[1] & 0x7f); |
| 1161 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1162 | 0x7f, valp[0] & 0x7f); |
| 1163 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1164 | 0x7f, valp[1] & 0x7f); |
| 1165 | return change; |
| 1166 | } |
| 1167 | |
| 1168 | /* mute internal speaker if HP is plugged */ |
| 1169 | static void ad1981_hp_automute(struct hda_codec *codec) |
| 1170 | { |
| 1171 | unsigned int present; |
| 1172 | |
| 1173 | present = snd_hda_codec_read(codec, 0x06, 0, |
| 1174 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1175 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1176 | 0x80, present ? 0x80 : 0); |
| 1177 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1178 | 0x80, present ? 0x80 : 0); |
| 1179 | } |
| 1180 | |
| 1181 | /* toggle input of built-in and mic jack appropriately */ |
| 1182 | static void ad1981_hp_automic(struct hda_codec *codec) |
| 1183 | { |
| 1184 | static struct hda_verb mic_jack_on[] = { |
| 1185 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1186 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1187 | {} |
| 1188 | }; |
| 1189 | static struct hda_verb mic_jack_off[] = { |
| 1190 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1191 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1192 | {} |
| 1193 | }; |
| 1194 | unsigned int present; |
| 1195 | |
| 1196 | present = snd_hda_codec_read(codec, 0x08, 0, |
| 1197 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1198 | if (present) |
| 1199 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1200 | else |
| 1201 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1202 | } |
| 1203 | |
| 1204 | /* unsolicited event for HP jack sensing */ |
| 1205 | static void ad1981_hp_unsol_event(struct hda_codec *codec, |
| 1206 | unsigned int res) |
| 1207 | { |
| 1208 | res >>= 26; |
| 1209 | switch (res) { |
| 1210 | case AD1981_HP_EVENT: |
| 1211 | ad1981_hp_automute(codec); |
| 1212 | break; |
| 1213 | case AD1981_MIC_EVENT: |
| 1214 | ad1981_hp_automic(codec); |
| 1215 | break; |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | static struct hda_input_mux ad1981_hp_capture_source = { |
| 1220 | .num_items = 3, |
| 1221 | .items = { |
| 1222 | { "Mic", 0x0 }, |
| 1223 | { "Docking-Station", 0x1 }, |
| 1224 | { "Mix", 0x2 }, |
| 1225 | }, |
| 1226 | }; |
| 1227 | |
| 1228 | static struct snd_kcontrol_new ad1981_hp_mixers[] = { |
| 1229 | { |
| 1230 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1231 | .name = "Master Playback Volume", |
| 1232 | .info = snd_hda_mixer_amp_volume_info, |
| 1233 | .get = snd_hda_mixer_amp_volume_get, |
| 1234 | .put = ad1981_hp_master_vol_put, |
| 1235 | .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 1236 | }, |
| 1237 | { |
| 1238 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1239 | .name = "Master Playback Switch", |
| 1240 | .info = ad198x_eapd_info, |
| 1241 | .get = ad198x_eapd_get, |
| 1242 | .put = ad1981_hp_master_sw_put, |
| 1243 | .private_value = 0x05, |
| 1244 | }, |
| 1245 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1246 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1247 | #if 0 |
| 1248 | /* FIXME: analog mic/line loopback doesn't work with my tests... |
| 1249 | * (although recording is OK) |
| 1250 | */ |
| 1251 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1252 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1253 | HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1254 | HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1255 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1256 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1257 | /* FIXME: does this laptop have analog CD connection? */ |
| 1258 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1259 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1260 | #endif |
| 1261 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1262 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1263 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1264 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1265 | { |
| 1266 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1267 | .name = "Capture Source", |
| 1268 | .info = ad198x_mux_enum_info, |
| 1269 | .get = ad198x_mux_enum_get, |
| 1270 | .put = ad198x_mux_enum_put, |
| 1271 | }, |
| 1272 | { } /* end */ |
| 1273 | }; |
| 1274 | |
| 1275 | /* initialize jack-sensing, too */ |
| 1276 | static int ad1981_hp_init(struct hda_codec *codec) |
| 1277 | { |
| 1278 | ad198x_init(codec); |
| 1279 | ad1981_hp_automute(codec); |
| 1280 | ad1981_hp_automic(codec); |
| 1281 | return 0; |
| 1282 | } |
| 1283 | |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1284 | /* configuration for Toshiba Laptops */ |
| 1285 | static struct hda_verb ad1981_toshiba_init_verbs[] = { |
| 1286 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */ |
| 1287 | /* pin sensing on HP and Mic jacks */ |
| 1288 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1289 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1290 | {} |
| 1291 | }; |
| 1292 | |
| 1293 | static struct snd_kcontrol_new ad1981_toshiba_mixers[] = { |
| 1294 | HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 1295 | HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 1296 | { } |
| 1297 | }; |
| 1298 | |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1299 | /* configuration for Lenovo Thinkpad T60 */ |
| 1300 | static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = { |
| 1301 | HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1302 | HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1303 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1304 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1305 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1306 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1307 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1308 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1309 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1310 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1311 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1312 | { |
| 1313 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1314 | .name = "Capture Source", |
| 1315 | .info = ad198x_mux_enum_info, |
| 1316 | .get = ad198x_mux_enum_get, |
| 1317 | .put = ad198x_mux_enum_put, |
| 1318 | }, |
Takashi Iwai | 6540dff | 2006-06-13 11:57:22 +0200 | [diff] [blame] | 1319 | /* identical with AD1983 */ |
| 1320 | { |
| 1321 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1322 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 1323 | .info = ad1983_spdif_route_info, |
| 1324 | .get = ad1983_spdif_route_get, |
| 1325 | .put = ad1983_spdif_route_put, |
| 1326 | }, |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1327 | { } /* end */ |
| 1328 | }; |
| 1329 | |
| 1330 | static struct hda_input_mux ad1981_thinkpad_capture_source = { |
| 1331 | .num_items = 3, |
| 1332 | .items = { |
| 1333 | { "Mic", 0x0 }, |
| 1334 | { "Mix", 0x2 }, |
| 1335 | { "CD", 0x4 }, |
| 1336 | }, |
| 1337 | }; |
| 1338 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1339 | /* models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1340 | enum { |
| 1341 | AD1981_BASIC, |
| 1342 | AD1981_HP, |
| 1343 | AD1981_THINKPAD, |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1344 | AD1981_TOSHIBA, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1345 | AD1981_MODELS |
| 1346 | }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1347 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1348 | static const char *ad1981_models[AD1981_MODELS] = { |
| 1349 | [AD1981_HP] = "hp", |
| 1350 | [AD1981_THINKPAD] = "thinkpad", |
| 1351 | [AD1981_BASIC] = "basic", |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1352 | [AD1981_TOSHIBA] = "toshiba" |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1353 | }; |
| 1354 | |
| 1355 | static struct snd_pci_quirk ad1981_cfg_tbl[] = { |
Takashi Iwai | 8970ccd | 2006-04-18 12:50:40 +0200 | [diff] [blame] | 1356 | /* All HP models */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1357 | SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), |
| 1358 | /* HP nx6320 (reversed SSID, H/W bug) */ |
| 1359 | SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1360 | /* Lenovo Thinkpad T60/X60/Z6xx */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1361 | SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), |
| 1362 | SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1363 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1364 | {} |
| 1365 | }; |
| 1366 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1367 | static int patch_ad1981(struct hda_codec *codec) |
| 1368 | { |
| 1369 | struct ad198x_spec *spec; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1370 | int board_config; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1371 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1372 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1373 | if (spec == NULL) |
| 1374 | return -ENOMEM; |
| 1375 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1376 | codec->spec = spec; |
| 1377 | |
| 1378 | spec->multiout.max_channels = 2; |
| 1379 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
| 1380 | spec->multiout.dac_nids = ad1981_dac_nids; |
| 1381 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1382 | spec->num_adc_nids = 1; |
| 1383 | spec->adc_nids = ad1981_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1384 | spec->capsrc_nids = ad1981_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1385 | spec->input_mux = &ad1981_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1386 | spec->num_mixers = 1; |
| 1387 | spec->mixers[0] = ad1981_mixers; |
| 1388 | spec->num_init_verbs = 1; |
| 1389 | spec->init_verbs[0] = ad1981_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1390 | spec->spdif_route = 0; |
| 1391 | |
| 1392 | codec->patch_ops = ad198x_patch_ops; |
| 1393 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1394 | /* override some parameters */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1395 | board_config = snd_hda_check_board_config(codec, AD1981_MODELS, |
| 1396 | ad1981_models, |
| 1397 | ad1981_cfg_tbl); |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1398 | switch (board_config) { |
| 1399 | case AD1981_HP: |
| 1400 | spec->mixers[0] = ad1981_hp_mixers; |
| 1401 | spec->num_init_verbs = 2; |
| 1402 | spec->init_verbs[1] = ad1981_hp_init_verbs; |
| 1403 | spec->multiout.dig_out_nid = 0; |
| 1404 | spec->input_mux = &ad1981_hp_capture_source; |
| 1405 | |
| 1406 | codec->patch_ops.init = ad1981_hp_init; |
| 1407 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1408 | break; |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1409 | case AD1981_THINKPAD: |
| 1410 | spec->mixers[0] = ad1981_thinkpad_mixers; |
Takashi Iwai | 01686c5 | 2006-04-18 12:54:11 +0200 | [diff] [blame] | 1411 | spec->input_mux = &ad1981_thinkpad_capture_source; |
| 1412 | break; |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 1413 | case AD1981_TOSHIBA: |
| 1414 | spec->mixers[0] = ad1981_hp_mixers; |
| 1415 | spec->mixers[1] = ad1981_toshiba_mixers; |
| 1416 | spec->num_init_verbs = 2; |
| 1417 | spec->init_verbs[1] = ad1981_toshiba_init_verbs; |
| 1418 | spec->multiout.dig_out_nid = 0; |
| 1419 | spec->input_mux = &ad1981_hp_capture_source; |
| 1420 | codec->patch_ops.init = ad1981_hp_init; |
| 1421 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1422 | break; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1423 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1424 | return 0; |
| 1425 | } |
| 1426 | |
| 1427 | |
| 1428 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1429 | * AD1988 |
| 1430 | * |
| 1431 | * Output pins and routes |
| 1432 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1433 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1434 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 1435 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 1436 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 1437 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 1438 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 1439 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 1440 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 1441 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 1442 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 1443 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1444 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 1445 | * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug. |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1446 | * |
| 1447 | * Input pins and routes |
| 1448 | * |
| 1449 | * pin boost mix input # / adc input # |
| 1450 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 1451 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 1452 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 1453 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 1454 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 1455 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 1456 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 1457 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 1458 | * |
| 1459 | * |
| 1460 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1461 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1462 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1463 | * |
| 1464 | * Inputs of Analog Mix (0x20) |
| 1465 | * 0:Port-B (front mic) |
| 1466 | * 1:Port-C/G/H (line-in) |
| 1467 | * 2:Port-A |
| 1468 | * 3:Port-D (line-in/2) |
| 1469 | * 4:Port-E/G/H (mic-in) |
| 1470 | * 5:Port-F (mic2-in) |
| 1471 | * 6:CD |
| 1472 | * 7:Beep |
| 1473 | * |
| 1474 | * ADC selection |
| 1475 | * 0:Port-A |
| 1476 | * 1:Port-B (front mic-in) |
| 1477 | * 2:Port-C (line-in) |
| 1478 | * 3:Port-F (mic2-in) |
| 1479 | * 4:Port-E (mic-in) |
| 1480 | * 5:CD |
| 1481 | * 6:Port-G |
| 1482 | * 7:Port-H |
| 1483 | * 8:Port-D (line-in/2) |
| 1484 | * 9:Mix |
| 1485 | * |
| 1486 | * Proposed pin assignments by the datasheet |
| 1487 | * |
| 1488 | * 6-stack |
| 1489 | * Port-A front headphone |
| 1490 | * B front mic-in |
| 1491 | * C rear line-in |
| 1492 | * D rear front-out |
| 1493 | * E rear mic-in |
| 1494 | * F rear surround |
| 1495 | * G rear CLFE |
| 1496 | * H rear side |
| 1497 | * |
| 1498 | * 3-stack |
| 1499 | * Port-A front headphone |
| 1500 | * B front mic |
| 1501 | * C rear line-in/surround |
| 1502 | * D rear front-out |
| 1503 | * E rear mic-in/CLFE |
| 1504 | * |
| 1505 | * laptop |
| 1506 | * Port-A headphone |
| 1507 | * B mic-in |
| 1508 | * C docking station |
| 1509 | * D internal speaker (with EAPD) |
| 1510 | * E/F quad mic array |
| 1511 | */ |
| 1512 | |
| 1513 | |
| 1514 | /* models */ |
| 1515 | enum { |
| 1516 | AD1988_6STACK, |
| 1517 | AD1988_6STACK_DIG, |
| 1518 | AD1988_3STACK, |
| 1519 | AD1988_3STACK_DIG, |
| 1520 | AD1988_LAPTOP, |
| 1521 | AD1988_LAPTOP_DIG, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1522 | AD1988_AUTO, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1523 | AD1988_MODEL_LAST, |
| 1524 | }; |
| 1525 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1526 | /* reivision id to check workarounds */ |
| 1527 | #define AD1988A_REV2 0x100200 |
| 1528 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 1529 | #define is_rev2(codec) \ |
| 1530 | ((codec)->vendor_id == 0x11d41988 && \ |
| 1531 | (codec)->revision_id == AD1988A_REV2) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1532 | |
| 1533 | /* |
| 1534 | * mixers |
| 1535 | */ |
| 1536 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1537 | static hda_nid_t ad1988_6stack_dac_nids[4] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1538 | 0x04, 0x06, 0x05, 0x0a |
| 1539 | }; |
| 1540 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1541 | static hda_nid_t ad1988_3stack_dac_nids[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1542 | 0x04, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1543 | }; |
| 1544 | |
| 1545 | /* for AD1988A revision-2, DAC2-4 are swapped */ |
| 1546 | static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { |
| 1547 | 0x04, 0x05, 0x0a, 0x06 |
| 1548 | }; |
| 1549 | |
| 1550 | static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1551 | 0x04, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1552 | }; |
| 1553 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1554 | static hda_nid_t ad1988_adc_nids[3] = { |
| 1555 | 0x08, 0x09, 0x0f |
| 1556 | }; |
| 1557 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1558 | static hda_nid_t ad1988_capsrc_nids[3] = { |
| 1559 | 0x0c, 0x0d, 0x0e |
| 1560 | }; |
| 1561 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1562 | #define AD1988_SPDIF_OUT 0x02 |
| 1563 | #define AD1988_SPDIF_IN 0x07 |
| 1564 | |
| 1565 | static struct hda_input_mux ad1988_6stack_capture_source = { |
| 1566 | .num_items = 5, |
| 1567 | .items = { |
| 1568 | { "Front Mic", 0x0 }, |
| 1569 | { "Line", 0x1 }, |
| 1570 | { "Mic", 0x4 }, |
| 1571 | { "CD", 0x5 }, |
| 1572 | { "Mix", 0x9 }, |
| 1573 | }, |
| 1574 | }; |
| 1575 | |
| 1576 | static struct hda_input_mux ad1988_laptop_capture_source = { |
| 1577 | .num_items = 3, |
| 1578 | .items = { |
| 1579 | { "Mic/Line", 0x0 }, |
| 1580 | { "CD", 0x5 }, |
| 1581 | { "Mix", 0x9 }, |
| 1582 | }, |
| 1583 | }; |
| 1584 | |
| 1585 | /* |
| 1586 | */ |
| 1587 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 1588 | struct snd_ctl_elem_info *uinfo) |
| 1589 | { |
| 1590 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1591 | struct ad198x_spec *spec = codec->spec; |
| 1592 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 1593 | spec->num_channel_mode); |
| 1594 | } |
| 1595 | |
| 1596 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 1597 | struct snd_ctl_elem_value *ucontrol) |
| 1598 | { |
| 1599 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1600 | struct ad198x_spec *spec = codec->spec; |
| 1601 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 1602 | spec->num_channel_mode, spec->multiout.max_channels); |
| 1603 | } |
| 1604 | |
| 1605 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 1606 | struct snd_ctl_elem_value *ucontrol) |
| 1607 | { |
| 1608 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1609 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 1610 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 1611 | spec->num_channel_mode, |
| 1612 | &spec->multiout.max_channels); |
Takashi Iwai | bd2033f | 2006-10-10 19:49:31 +0200 | [diff] [blame] | 1613 | if (err >= 0 && spec->need_dac_fix) |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 1614 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 1615 | return err; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1616 | } |
| 1617 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1618 | /* 6-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1619 | static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1620 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1621 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1622 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1623 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 1624 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1625 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1626 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1627 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1628 | static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { |
| 1629 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1630 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1631 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 1632 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), |
| 1633 | HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1634 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1635 | }; |
| 1636 | |
| 1637 | static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1638 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
| 1639 | HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), |
| 1640 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), |
| 1641 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), |
| 1642 | HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), |
| 1643 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1644 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1645 | |
| 1646 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1647 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1648 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1649 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1650 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1651 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1652 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1653 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1654 | |
| 1655 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1656 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1657 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1658 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1659 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1660 | |
| 1661 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1662 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1663 | |
| 1664 | { } /* end */ |
| 1665 | }; |
| 1666 | |
| 1667 | /* 3-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1668 | static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1669 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1670 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1671 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1672 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1673 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1674 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1675 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1676 | static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { |
| 1677 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1678 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
| 1679 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), |
| 1680 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | 2ece5f42 | 2006-07-06 19:16:40 +0200 | [diff] [blame] | 1681 | { } /* end */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1682 | }; |
| 1683 | |
| 1684 | static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1685 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1686 | HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), |
| 1687 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), |
| 1688 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1689 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1690 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1691 | |
| 1692 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1693 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1694 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1695 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1696 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1697 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1698 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1699 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1700 | |
| 1701 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1702 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1703 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1704 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1705 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1706 | |
| 1707 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1708 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1709 | { |
| 1710 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1711 | .name = "Channel Mode", |
| 1712 | .info = ad198x_ch_mode_info, |
| 1713 | .get = ad198x_ch_mode_get, |
| 1714 | .put = ad198x_ch_mode_put, |
| 1715 | }, |
| 1716 | |
| 1717 | { } /* end */ |
| 1718 | }; |
| 1719 | |
| 1720 | /* laptop mode */ |
| 1721 | static struct snd_kcontrol_new ad1988_laptop_mixers[] = { |
| 1722 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1723 | HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), |
| 1724 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1725 | |
| 1726 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1727 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1728 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1729 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1730 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1731 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1732 | |
| 1733 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1734 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1735 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1736 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1737 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1738 | |
| 1739 | HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1740 | |
| 1741 | { |
| 1742 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1743 | .name = "External Amplifier", |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1744 | .info = ad198x_eapd_info, |
| 1745 | .get = ad198x_eapd_get, |
| 1746 | .put = ad198x_eapd_put, |
| 1747 | .private_value = 0x12 | (1 << 8), /* port-D, inversed */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1748 | }, |
| 1749 | |
| 1750 | { } /* end */ |
| 1751 | }; |
| 1752 | |
| 1753 | /* capture */ |
| 1754 | static struct snd_kcontrol_new ad1988_capture_mixers[] = { |
| 1755 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1756 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 1757 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1758 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1759 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1760 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1761 | { |
| 1762 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1763 | /* The multiple "Capture Source" controls confuse alsamixer |
| 1764 | * So call somewhat different.. |
| 1765 | * FIXME: the controls appear in the "playback" view! |
| 1766 | */ |
| 1767 | /* .name = "Capture Source", */ |
| 1768 | .name = "Input Source", |
| 1769 | .count = 3, |
| 1770 | .info = ad198x_mux_enum_info, |
| 1771 | .get = ad198x_mux_enum_get, |
| 1772 | .put = ad198x_mux_enum_put, |
| 1773 | }, |
| 1774 | { } /* end */ |
| 1775 | }; |
| 1776 | |
| 1777 | static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, |
| 1778 | struct snd_ctl_elem_info *uinfo) |
| 1779 | { |
| 1780 | static char *texts[] = { |
| 1781 | "PCM", "ADC1", "ADC2", "ADC3" |
| 1782 | }; |
| 1783 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1784 | uinfo->count = 1; |
| 1785 | uinfo->value.enumerated.items = 4; |
| 1786 | if (uinfo->value.enumerated.item >= 4) |
| 1787 | uinfo->value.enumerated.item = 3; |
| 1788 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1789 | return 0; |
| 1790 | } |
| 1791 | |
| 1792 | static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, |
| 1793 | struct snd_ctl_elem_value *ucontrol) |
| 1794 | { |
| 1795 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1796 | unsigned int sel; |
| 1797 | |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 1798 | sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE, |
| 1799 | AC_AMP_GET_INPUT); |
| 1800 | if (!(sel & 0x80)) |
| 1801 | ucontrol->value.enumerated.item[0] = 0; |
| 1802 | else { |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 1803 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 1804 | AC_VERB_GET_CONNECT_SEL, 0); |
| 1805 | if (sel < 3) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1806 | sel++; |
| 1807 | else |
| 1808 | sel = 0; |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 1809 | ucontrol->value.enumerated.item[0] = sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1810 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1811 | return 0; |
| 1812 | } |
| 1813 | |
| 1814 | static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, |
| 1815 | struct snd_ctl_elem_value *ucontrol) |
| 1816 | { |
| 1817 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 1818 | unsigned int val, sel; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1819 | int change; |
| 1820 | |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 1821 | val = ucontrol->value.enumerated.item[0]; |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 1822 | if (!val) { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 1823 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 1824 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 1825 | AC_AMP_GET_INPUT); |
| 1826 | change = sel & 0x80; |
| 1827 | if (change || codec->in_resume) { |
| 1828 | snd_hda_codec_write(codec, 0x1d, 0, |
| 1829 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1830 | AMP_IN_UNMUTE(0)); |
| 1831 | snd_hda_codec_write(codec, 0x1d, 0, |
| 1832 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1833 | AMP_IN_MUTE(1)); |
| 1834 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1835 | } else { |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 1836 | sel = snd_hda_codec_read(codec, 0x1d, 0, |
| 1837 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 1838 | AC_AMP_GET_INPUT | 0x01); |
| 1839 | change = sel & 0x80; |
| 1840 | if (change || codec->in_resume) { |
| 1841 | snd_hda_codec_write(codec, 0x1d, 0, |
| 1842 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1843 | AMP_IN_MUTE(0)); |
| 1844 | snd_hda_codec_write(codec, 0x1d, 0, |
| 1845 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1846 | AMP_IN_UNMUTE(1)); |
| 1847 | } |
Takashi Iwai | 35b2672 | 2007-05-05 12:17:17 +0200 | [diff] [blame] | 1848 | sel = snd_hda_codec_read(codec, 0x0b, 0, |
| 1849 | AC_VERB_GET_CONNECT_SEL, 0) + 1; |
| 1850 | change |= sel != val; |
| 1851 | if (change || codec->in_resume) |
| 1852 | snd_hda_codec_write(codec, 0x0b, 0, |
| 1853 | AC_VERB_SET_CONNECT_SEL, val - 1); |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1854 | } |
| 1855 | return change; |
| 1856 | } |
| 1857 | |
| 1858 | static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { |
| 1859 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1860 | { |
| 1861 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1862 | .name = "IEC958 Playback Source", |
| 1863 | .info = ad1988_spdif_playback_source_info, |
| 1864 | .get = ad1988_spdif_playback_source_get, |
| 1865 | .put = ad1988_spdif_playback_source_put, |
| 1866 | }, |
| 1867 | { } /* end */ |
| 1868 | }; |
| 1869 | |
| 1870 | static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { |
| 1871 | HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), |
| 1872 | { } /* end */ |
| 1873 | }; |
| 1874 | |
| 1875 | |
| 1876 | /* |
| 1877 | * initialization verbs |
| 1878 | */ |
| 1879 | |
| 1880 | /* |
| 1881 | * for 6-stack (+dig) |
| 1882 | */ |
| 1883 | static struct hda_verb ad1988_6stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1884 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1885 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1886 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1887 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1888 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1889 | /* Port-A front headphon path */ |
| 1890 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 1891 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1892 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1893 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1894 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1895 | /* Port-D line-out path */ |
| 1896 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1897 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1898 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1899 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1900 | /* Port-F surround path */ |
| 1901 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1902 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1903 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1904 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1905 | /* Port-G CLFE path */ |
| 1906 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1907 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1908 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1909 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1910 | /* Port-H side path */ |
| 1911 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1912 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1913 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1914 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1915 | /* Mono out path */ |
| 1916 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 1917 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1918 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1919 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1920 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 1921 | /* Port-B front mic-in path */ |
| 1922 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1923 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1924 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1925 | /* Port-C line-in path */ |
| 1926 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1927 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1928 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1929 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1930 | /* Port-E mic-in path */ |
| 1931 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1932 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1933 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1934 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1935 | |
| 1936 | { } |
| 1937 | }; |
| 1938 | |
| 1939 | static struct hda_verb ad1988_capture_init_verbs[] = { |
| 1940 | /* mute analog mix */ |
| 1941 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1942 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1943 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1944 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1945 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 1946 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 1947 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 1948 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 1949 | /* select ADCs - front-mic */ |
| 1950 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1951 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1952 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1953 | /* ADCs; muted */ |
| 1954 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1955 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1956 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1957 | |
| 1958 | { } |
| 1959 | }; |
| 1960 | |
| 1961 | static struct hda_verb ad1988_spdif_init_verbs[] = { |
| 1962 | /* SPDIF out sel */ |
| 1963 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 1964 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ |
| 1965 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Takashi Iwai | bddcf54 | 2007-07-24 18:04:05 +0200 | [diff] [blame] | 1966 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1967 | /* SPDIF out pin */ |
| 1968 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1969 | |
| 1970 | { } |
| 1971 | }; |
| 1972 | |
| 1973 | /* |
| 1974 | * verbs for 3stack (+dig) |
| 1975 | */ |
| 1976 | static struct hda_verb ad1988_3stack_ch2_init[] = { |
| 1977 | /* set port-C to line-in */ |
| 1978 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1979 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1980 | /* set port-E to mic-in */ |
| 1981 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1982 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1983 | { } /* end */ |
| 1984 | }; |
| 1985 | |
| 1986 | static struct hda_verb ad1988_3stack_ch6_init[] = { |
| 1987 | /* set port-C to surround out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1988 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1989 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1990 | /* set port-E to CLFE out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1991 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1992 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1993 | { } /* end */ |
| 1994 | }; |
| 1995 | |
| 1996 | static struct hda_channel_mode ad1988_3stack_modes[2] = { |
| 1997 | { 2, ad1988_3stack_ch2_init }, |
| 1998 | { 6, ad1988_3stack_ch6_init }, |
| 1999 | }; |
| 2000 | |
| 2001 | static struct hda_verb ad1988_3stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2002 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2003 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2004 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2005 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2006 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2007 | /* Port-A front headphon path */ |
| 2008 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2009 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2010 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2011 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2012 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2013 | /* Port-D line-out path */ |
| 2014 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2015 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2016 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2017 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2018 | /* Mono out path */ |
| 2019 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2020 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2021 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2022 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2023 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2024 | /* Port-B front mic-in path */ |
| 2025 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2026 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2027 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2028 | /* Port-C line-in/surround path - 6ch mode as default */ |
| 2029 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2030 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2031 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2032 | {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2033 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2034 | /* Port-E mic-in/CLFE path - 6ch mode as default */ |
| 2035 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2036 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2037 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2038 | {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2039 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2040 | /* mute analog mix */ |
| 2041 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2042 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2043 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2044 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2045 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2046 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2047 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2048 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2049 | /* select ADCs - front-mic */ |
| 2050 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2051 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2052 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2053 | /* ADCs; muted */ |
| 2054 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2055 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2056 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2057 | { } |
| 2058 | }; |
| 2059 | |
| 2060 | /* |
| 2061 | * verbs for laptop mode (+dig) |
| 2062 | */ |
| 2063 | static struct hda_verb ad1988_laptop_hp_on[] = { |
| 2064 | /* unmute port-A and mute port-D */ |
| 2065 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2066 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2067 | { } /* end */ |
| 2068 | }; |
| 2069 | static struct hda_verb ad1988_laptop_hp_off[] = { |
| 2070 | /* mute port-A and unmute port-D */ |
| 2071 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2072 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2073 | { } /* end */ |
| 2074 | }; |
| 2075 | |
| 2076 | #define AD1988_HP_EVENT 0x01 |
| 2077 | |
| 2078 | static struct hda_verb ad1988_laptop_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2079 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2080 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2081 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2082 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2083 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2084 | /* Port-A front headphon path */ |
| 2085 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2086 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2087 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2088 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2089 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2090 | /* unsolicited event for pin-sense */ |
| 2091 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, |
| 2092 | /* Port-D line-out path + EAPD */ |
| 2093 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2094 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2095 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2096 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2097 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ |
| 2098 | /* Mono out path */ |
| 2099 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2100 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2101 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2102 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2103 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2104 | /* Port-B mic-in path */ |
| 2105 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2106 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2107 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2108 | /* Port-C docking station - try to output */ |
| 2109 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2110 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2111 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2112 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2113 | /* mute analog mix */ |
| 2114 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2115 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2116 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2117 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2118 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2119 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2120 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2121 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2122 | /* select ADCs - mic */ |
| 2123 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2124 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2125 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2126 | /* ADCs; muted */ |
| 2127 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2128 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2129 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2130 | { } |
| 2131 | }; |
| 2132 | |
| 2133 | static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2134 | { |
| 2135 | if ((res >> 26) != AD1988_HP_EVENT) |
| 2136 | return; |
| 2137 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) |
| 2138 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
| 2139 | else |
| 2140 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
| 2141 | } |
| 2142 | |
| 2143 | |
| 2144 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2145 | * Automatic parse of I/O pins from the BIOS configuration |
| 2146 | */ |
| 2147 | |
| 2148 | #define NUM_CONTROL_ALLOC 32 |
| 2149 | #define NUM_VERB_ALLOC 32 |
| 2150 | |
| 2151 | enum { |
| 2152 | AD_CTL_WIDGET_VOL, |
| 2153 | AD_CTL_WIDGET_MUTE, |
| 2154 | AD_CTL_BIND_MUTE, |
| 2155 | }; |
| 2156 | static struct snd_kcontrol_new ad1988_control_templates[] = { |
| 2157 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2158 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
| 2159 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
| 2160 | }; |
| 2161 | |
| 2162 | /* add dynamic controls */ |
| 2163 | static int add_control(struct ad198x_spec *spec, int type, const char *name, |
| 2164 | unsigned long val) |
| 2165 | { |
| 2166 | struct snd_kcontrol_new *knew; |
| 2167 | |
| 2168 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2169 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2170 | |
| 2171 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2172 | if (! knew) |
| 2173 | return -ENOMEM; |
| 2174 | if (spec->kctl_alloc) { |
| 2175 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2176 | kfree(spec->kctl_alloc); |
| 2177 | } |
| 2178 | spec->kctl_alloc = knew; |
| 2179 | spec->num_kctl_alloc = num; |
| 2180 | } |
| 2181 | |
| 2182 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2183 | *knew = ad1988_control_templates[type]; |
| 2184 | knew->name = kstrdup(name, GFP_KERNEL); |
| 2185 | if (! knew->name) |
| 2186 | return -ENOMEM; |
| 2187 | knew->private_value = val; |
| 2188 | spec->num_kctl_used++; |
| 2189 | return 0; |
| 2190 | } |
| 2191 | |
| 2192 | #define AD1988_PIN_CD_NID 0x18 |
| 2193 | #define AD1988_PIN_BEEP_NID 0x10 |
| 2194 | |
| 2195 | static hda_nid_t ad1988_mixer_nids[8] = { |
| 2196 | /* A B C D E F G H */ |
| 2197 | 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 |
| 2198 | }; |
| 2199 | |
| 2200 | static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) |
| 2201 | { |
| 2202 | static hda_nid_t idx_to_dac[8] = { |
| 2203 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2204 | 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2205 | }; |
| 2206 | static hda_nid_t idx_to_dac_rev2[8] = { |
| 2207 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2208 | 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2209 | }; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2210 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2211 | return idx_to_dac_rev2[idx]; |
| 2212 | else |
| 2213 | return idx_to_dac[idx]; |
| 2214 | } |
| 2215 | |
| 2216 | static hda_nid_t ad1988_boost_nids[8] = { |
| 2217 | 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 |
| 2218 | }; |
| 2219 | |
| 2220 | static int ad1988_pin_idx(hda_nid_t nid) |
| 2221 | { |
| 2222 | static hda_nid_t ad1988_io_pins[8] = { |
| 2223 | 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 |
| 2224 | }; |
| 2225 | int i; |
| 2226 | for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) |
| 2227 | if (ad1988_io_pins[i] == nid) |
| 2228 | return i; |
| 2229 | return 0; /* should be -1 */ |
| 2230 | } |
| 2231 | |
| 2232 | static int ad1988_pin_to_loopback_idx(hda_nid_t nid) |
| 2233 | { |
| 2234 | static int loopback_idx[8] = { |
| 2235 | 2, 0, 1, 3, 4, 5, 1, 4 |
| 2236 | }; |
| 2237 | switch (nid) { |
| 2238 | case AD1988_PIN_CD_NID: |
| 2239 | return 6; |
| 2240 | default: |
| 2241 | return loopback_idx[ad1988_pin_idx(nid)]; |
| 2242 | } |
| 2243 | } |
| 2244 | |
| 2245 | static int ad1988_pin_to_adc_idx(hda_nid_t nid) |
| 2246 | { |
| 2247 | static int adc_idx[8] = { |
| 2248 | 0, 1, 2, 8, 4, 3, 6, 7 |
| 2249 | }; |
| 2250 | switch (nid) { |
| 2251 | case AD1988_PIN_CD_NID: |
| 2252 | return 5; |
| 2253 | default: |
| 2254 | return adc_idx[ad1988_pin_idx(nid)]; |
| 2255 | } |
| 2256 | } |
| 2257 | |
| 2258 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2259 | static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, |
| 2260 | const struct auto_pin_cfg *cfg) |
| 2261 | { |
| 2262 | struct ad198x_spec *spec = codec->spec; |
| 2263 | int i, idx; |
| 2264 | |
| 2265 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2266 | |
| 2267 | /* check the pins hardwired to audio widget */ |
| 2268 | for (i = 0; i < cfg->line_outs; i++) { |
| 2269 | idx = ad1988_pin_idx(cfg->line_out_pins[i]); |
| 2270 | spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); |
| 2271 | } |
| 2272 | spec->multiout.num_dacs = cfg->line_outs; |
| 2273 | return 0; |
| 2274 | } |
| 2275 | |
| 2276 | /* add playback controls from the parsed DAC table */ |
| 2277 | static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, |
| 2278 | const struct auto_pin_cfg *cfg) |
| 2279 | { |
| 2280 | char name[32]; |
| 2281 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2282 | hda_nid_t nid; |
| 2283 | int i, err; |
| 2284 | |
| 2285 | for (i = 0; i < cfg->line_outs; i++) { |
| 2286 | hda_nid_t dac = spec->multiout.dac_nids[i]; |
| 2287 | if (! dac) |
| 2288 | continue; |
| 2289 | nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; |
| 2290 | if (i == 2) { |
| 2291 | /* Center/LFE */ |
| 2292 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2293 | "Center Playback Volume", |
| 2294 | HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); |
| 2295 | if (err < 0) |
| 2296 | return err; |
| 2297 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2298 | "LFE Playback Volume", |
| 2299 | HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); |
| 2300 | if (err < 0) |
| 2301 | return err; |
| 2302 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2303 | "Center Playback Switch", |
| 2304 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); |
| 2305 | if (err < 0) |
| 2306 | return err; |
| 2307 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2308 | "LFE Playback Switch", |
| 2309 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); |
| 2310 | if (err < 0) |
| 2311 | return err; |
| 2312 | } else { |
| 2313 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2314 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2315 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); |
| 2316 | if (err < 0) |
| 2317 | return err; |
| 2318 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2319 | err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2320 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
| 2321 | if (err < 0) |
| 2322 | return err; |
| 2323 | } |
| 2324 | } |
| 2325 | return 0; |
| 2326 | } |
| 2327 | |
| 2328 | /* add playback controls for speaker and HP outputs */ |
| 2329 | static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
| 2330 | const char *pfx) |
| 2331 | { |
| 2332 | struct ad198x_spec *spec = codec->spec; |
| 2333 | hda_nid_t nid; |
| 2334 | int idx, err; |
| 2335 | char name[32]; |
| 2336 | |
| 2337 | if (! pin) |
| 2338 | return 0; |
| 2339 | |
| 2340 | idx = ad1988_pin_idx(pin); |
| 2341 | nid = ad1988_idx_to_dac(codec, idx); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2342 | /* specify the DAC as the extra output */ |
| 2343 | if (! spec->multiout.hp_nid) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2344 | spec->multiout.hp_nid = nid; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2345 | else |
| 2346 | spec->multiout.extra_out_nid[0] = nid; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2347 | /* control HP volume/switch on the output mixer amp */ |
| 2348 | sprintf(name, "%s Playback Volume", pfx); |
| 2349 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2350 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2351 | return err; |
| 2352 | nid = ad1988_mixer_nids[idx]; |
| 2353 | sprintf(name, "%s Playback Switch", pfx); |
| 2354 | if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2355 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2356 | return err; |
| 2357 | return 0; |
| 2358 | } |
| 2359 | |
| 2360 | /* create input playback/capture controls for the given pin */ |
| 2361 | static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, |
| 2362 | const char *ctlname, int boost) |
| 2363 | { |
| 2364 | char name[32]; |
| 2365 | int err, idx; |
| 2366 | |
| 2367 | sprintf(name, "%s Playback Volume", ctlname); |
| 2368 | idx = ad1988_pin_to_loopback_idx(pin); |
| 2369 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2370 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2371 | return err; |
| 2372 | sprintf(name, "%s Playback Switch", ctlname); |
| 2373 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, |
| 2374 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2375 | return err; |
| 2376 | if (boost) { |
| 2377 | hda_nid_t bnid; |
| 2378 | idx = ad1988_pin_idx(pin); |
| 2379 | bnid = ad1988_boost_nids[idx]; |
| 2380 | if (bnid) { |
| 2381 | sprintf(name, "%s Boost", ctlname); |
| 2382 | return add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2383 | HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); |
| 2384 | |
| 2385 | } |
| 2386 | } |
| 2387 | return 0; |
| 2388 | } |
| 2389 | |
| 2390 | /* create playback/capture controls for input pins */ |
| 2391 | static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, |
| 2392 | const struct auto_pin_cfg *cfg) |
| 2393 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2394 | struct hda_input_mux *imux = &spec->private_imux; |
| 2395 | int i, err; |
| 2396 | |
| 2397 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2398 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2399 | auto_pin_cfg_labels[i], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2400 | i <= AUTO_PIN_FRONT_MIC); |
| 2401 | if (err < 0) |
| 2402 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2403 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2404 | imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); |
| 2405 | imux->num_items++; |
| 2406 | } |
| 2407 | imux->items[imux->num_items].label = "Mix"; |
| 2408 | imux->items[imux->num_items].index = 9; |
| 2409 | imux->num_items++; |
| 2410 | |
| 2411 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2412 | "Analog Mix Playback Volume", |
| 2413 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2414 | return err; |
| 2415 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, |
| 2416 | "Analog Mix Playback Switch", |
| 2417 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2418 | return err; |
| 2419 | |
| 2420 | return 0; |
| 2421 | } |
| 2422 | |
| 2423 | static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2424 | hda_nid_t nid, int pin_type, |
| 2425 | int dac_idx) |
| 2426 | { |
| 2427 | /* set as output */ |
| 2428 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2429 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2430 | switch (nid) { |
| 2431 | case 0x11: /* port-A - DAC 04 */ |
| 2432 | snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2433 | break; |
| 2434 | case 0x14: /* port-B - DAC 06 */ |
| 2435 | snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); |
| 2436 | break; |
| 2437 | case 0x15: /* port-C - DAC 05 */ |
| 2438 | snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); |
| 2439 | break; |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2440 | case 0x17: /* port-E - DAC 0a */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2441 | snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2442 | break; |
| 2443 | case 0x13: /* mono - DAC 04 */ |
| 2444 | snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2445 | break; |
| 2446 | } |
| 2447 | } |
| 2448 | |
| 2449 | static void ad1988_auto_init_multi_out(struct hda_codec *codec) |
| 2450 | { |
| 2451 | struct ad198x_spec *spec = codec->spec; |
| 2452 | int i; |
| 2453 | |
| 2454 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2455 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2456 | ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2457 | } |
| 2458 | } |
| 2459 | |
| 2460 | static void ad1988_auto_init_extra_out(struct hda_codec *codec) |
| 2461 | { |
| 2462 | struct ad198x_spec *spec = codec->spec; |
| 2463 | hda_nid_t pin; |
| 2464 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2465 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2466 | if (pin) /* connect to front */ |
| 2467 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2468 | pin = spec->autocfg.hp_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2469 | if (pin) /* connect to front */ |
| 2470 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2471 | } |
| 2472 | |
| 2473 | static void ad1988_auto_init_analog_input(struct hda_codec *codec) |
| 2474 | { |
| 2475 | struct ad198x_spec *spec = codec->spec; |
| 2476 | int i, idx; |
| 2477 | |
| 2478 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2479 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2480 | if (! nid) |
| 2481 | continue; |
| 2482 | switch (nid) { |
| 2483 | case 0x15: /* port-C */ |
| 2484 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2485 | break; |
| 2486 | case 0x17: /* port-E */ |
| 2487 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2488 | break; |
| 2489 | } |
| 2490 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2491 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2492 | if (nid != AD1988_PIN_CD_NID) |
| 2493 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2494 | AMP_OUT_MUTE); |
| 2495 | idx = ad1988_pin_idx(nid); |
| 2496 | if (ad1988_boost_nids[idx]) |
| 2497 | snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, |
| 2498 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2499 | AMP_OUT_ZERO); |
| 2500 | } |
| 2501 | } |
| 2502 | |
| 2503 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2504 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2505 | static int ad1988_parse_auto_config(struct hda_codec *codec) |
| 2506 | { |
| 2507 | struct ad198x_spec *spec = codec->spec; |
| 2508 | int err; |
| 2509 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2510 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2511 | return err; |
| 2512 | if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 2513 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2514 | if (! spec->autocfg.line_outs) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2515 | return 0; /* can't find valid BIOS pin config */ |
| 2516 | if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2517 | (err = ad1988_auto_create_extra_out(codec, |
| 2518 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2519 | "Speaker")) < 0 || |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2520 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2521 | "Headphone")) < 0 || |
| 2522 | (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2523 | return err; |
| 2524 | |
| 2525 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2526 | |
| 2527 | if (spec->autocfg.dig_out_pin) |
| 2528 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2529 | if (spec->autocfg.dig_in_pin) |
| 2530 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2531 | |
| 2532 | if (spec->kctl_alloc) |
| 2533 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2534 | |
| 2535 | spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; |
| 2536 | |
| 2537 | spec->input_mux = &spec->private_imux; |
| 2538 | |
| 2539 | return 1; |
| 2540 | } |
| 2541 | |
| 2542 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2543 | static int ad1988_auto_init(struct hda_codec *codec) |
| 2544 | { |
| 2545 | ad198x_init(codec); |
| 2546 | ad1988_auto_init_multi_out(codec); |
| 2547 | ad1988_auto_init_extra_out(codec); |
| 2548 | ad1988_auto_init_analog_input(codec); |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
| 2552 | |
| 2553 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2554 | */ |
| 2555 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2556 | static const char *ad1988_models[AD1988_MODEL_LAST] = { |
| 2557 | [AD1988_6STACK] = "6stack", |
| 2558 | [AD1988_6STACK_DIG] = "6stack-dig", |
| 2559 | [AD1988_3STACK] = "3stack", |
| 2560 | [AD1988_3STACK_DIG] = "3stack-dig", |
| 2561 | [AD1988_LAPTOP] = "laptop", |
| 2562 | [AD1988_LAPTOP_DIG] = "laptop-dig", |
| 2563 | [AD1988_AUTO] = "auto", |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2564 | }; |
| 2565 | |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2566 | static struct snd_pci_quirk ad1988_cfg_tbl[] = { |
| 2567 | SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG), |
Tobin Davis | 1876899 | 2007-03-12 22:20:51 +0100 | [diff] [blame] | 2568 | SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG), |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2569 | {} |
| 2570 | }; |
| 2571 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2572 | static int patch_ad1988(struct hda_codec *codec) |
| 2573 | { |
| 2574 | struct ad198x_spec *spec; |
| 2575 | int board_config; |
| 2576 | |
| 2577 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2578 | if (spec == NULL) |
| 2579 | return -ENOMEM; |
| 2580 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2581 | codec->spec = spec; |
| 2582 | |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2583 | if (is_rev2(codec)) |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2584 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
| 2585 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2586 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, |
Tobin Davis | a64c8cd | 2007-03-12 11:36:00 +0100 | [diff] [blame] | 2587 | ad1988_models, ad1988_cfg_tbl); |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2588 | if (board_config < 0) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2589 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); |
| 2590 | board_config = AD1988_AUTO; |
| 2591 | } |
| 2592 | |
| 2593 | if (board_config == AD1988_AUTO) { |
| 2594 | /* automatic parse from the BIOS config */ |
| 2595 | int err = ad1988_parse_auto_config(codec); |
| 2596 | if (err < 0) { |
| 2597 | ad198x_free(codec); |
| 2598 | return err; |
| 2599 | } else if (! err) { |
| 2600 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); |
| 2601 | board_config = AD1988_6STACK; |
| 2602 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2603 | } |
| 2604 | |
| 2605 | switch (board_config) { |
| 2606 | case AD1988_6STACK: |
| 2607 | case AD1988_6STACK_DIG: |
| 2608 | spec->multiout.max_channels = 8; |
| 2609 | spec->multiout.num_dacs = 4; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2610 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2611 | spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; |
| 2612 | else |
| 2613 | spec->multiout.dac_nids = ad1988_6stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2614 | spec->input_mux = &ad1988_6stack_capture_source; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2615 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2616 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2617 | spec->mixers[0] = ad1988_6stack_mixers1_rev2; |
| 2618 | else |
| 2619 | spec->mixers[0] = ad1988_6stack_mixers1; |
| 2620 | spec->mixers[1] = ad1988_6stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2621 | spec->num_init_verbs = 1; |
| 2622 | spec->init_verbs[0] = ad1988_6stack_init_verbs; |
| 2623 | if (board_config == AD1988_6STACK_DIG) { |
| 2624 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2625 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2626 | } |
| 2627 | break; |
| 2628 | case AD1988_3STACK: |
| 2629 | case AD1988_3STACK_DIG: |
| 2630 | spec->multiout.max_channels = 6; |
| 2631 | spec->multiout.num_dacs = 3; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2632 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2633 | spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; |
| 2634 | else |
| 2635 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2636 | spec->input_mux = &ad1988_6stack_capture_source; |
| 2637 | spec->channel_mode = ad1988_3stack_modes; |
| 2638 | spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2639 | spec->num_mixers = 2; |
Takashi Iwai | 1a806f4 | 2006-07-03 15:58:16 +0200 | [diff] [blame] | 2640 | if (is_rev2(codec)) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2641 | spec->mixers[0] = ad1988_3stack_mixers1_rev2; |
| 2642 | else |
| 2643 | spec->mixers[0] = ad1988_3stack_mixers1; |
| 2644 | spec->mixers[1] = ad1988_3stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2645 | spec->num_init_verbs = 1; |
| 2646 | spec->init_verbs[0] = ad1988_3stack_init_verbs; |
| 2647 | if (board_config == AD1988_3STACK_DIG) |
| 2648 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2649 | break; |
| 2650 | case AD1988_LAPTOP: |
| 2651 | case AD1988_LAPTOP_DIG: |
| 2652 | spec->multiout.max_channels = 2; |
| 2653 | spec->multiout.num_dacs = 1; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2654 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2655 | spec->input_mux = &ad1988_laptop_capture_source; |
| 2656 | spec->num_mixers = 1; |
| 2657 | spec->mixers[0] = ad1988_laptop_mixers; |
| 2658 | spec->num_init_verbs = 1; |
| 2659 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
| 2660 | if (board_config == AD1988_LAPTOP_DIG) |
| 2661 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2662 | break; |
| 2663 | } |
| 2664 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2665 | spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); |
| 2666 | spec->adc_nids = ad1988_adc_nids; |
| 2667 | spec->capsrc_nids = ad1988_capsrc_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2668 | spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; |
| 2669 | spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; |
| 2670 | if (spec->multiout.dig_out_nid) { |
| 2671 | spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; |
| 2672 | spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; |
| 2673 | } |
| 2674 | if (spec->dig_in_nid) |
| 2675 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
| 2676 | |
| 2677 | codec->patch_ops = ad198x_patch_ops; |
| 2678 | switch (board_config) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2679 | case AD1988_AUTO: |
| 2680 | codec->patch_ops.init = ad1988_auto_init; |
| 2681 | break; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2682 | case AD1988_LAPTOP: |
| 2683 | case AD1988_LAPTOP_DIG: |
| 2684 | codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; |
| 2685 | break; |
| 2686 | } |
| 2687 | |
| 2688 | return 0; |
| 2689 | } |
| 2690 | |
| 2691 | |
| 2692 | /* |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2693 | * AD1884 / AD1984 |
| 2694 | * |
| 2695 | * port-B - front line/mic-in |
| 2696 | * port-E - aux in/out |
| 2697 | * port-F - aux in/out |
| 2698 | * port-C - rear line/mic-in |
| 2699 | * port-D - rear line/hp-out |
| 2700 | * port-A - front line/hp-out |
| 2701 | * |
| 2702 | * AD1984 = AD1884 + two digital mic-ins |
| 2703 | * |
| 2704 | * FIXME: |
| 2705 | * For simplicity, we share the single DAC for both HP and line-outs |
| 2706 | * right now. The inidividual playbacks could be easily implemented, |
| 2707 | * but no build-up framework is given, so far. |
| 2708 | */ |
| 2709 | |
| 2710 | static hda_nid_t ad1884_dac_nids[1] = { |
| 2711 | 0x04, |
| 2712 | }; |
| 2713 | |
| 2714 | static hda_nid_t ad1884_adc_nids[2] = { |
| 2715 | 0x08, 0x09, |
| 2716 | }; |
| 2717 | |
| 2718 | static hda_nid_t ad1884_capsrc_nids[2] = { |
| 2719 | 0x0c, 0x0d, |
| 2720 | }; |
| 2721 | |
| 2722 | #define AD1884_SPDIF_OUT 0x02 |
| 2723 | |
| 2724 | static struct hda_input_mux ad1884_capture_source = { |
| 2725 | .num_items = 4, |
| 2726 | .items = { |
| 2727 | { "Front Mic", 0x0 }, |
| 2728 | { "Mic", 0x1 }, |
| 2729 | { "CD", 0x2 }, |
| 2730 | { "Mix", 0x3 }, |
| 2731 | }, |
| 2732 | }; |
| 2733 | |
| 2734 | static struct snd_kcontrol_new ad1884_base_mixers[] = { |
| 2735 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 2736 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 2737 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 2738 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 2739 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 2740 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 2741 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 2742 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 2743 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 2744 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 2745 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), |
| 2746 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), |
| 2747 | /* |
| 2748 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 2749 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT), |
| 2750 | HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 2751 | HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 2752 | */ |
| 2753 | HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT), |
| 2754 | HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 2755 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 2756 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 2757 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2758 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2759 | { |
| 2760 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2761 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2762 | * So call somewhat different.. |
| 2763 | * FIXME: the controls appear in the "playback" view! |
| 2764 | */ |
| 2765 | /* .name = "Capture Source", */ |
| 2766 | .name = "Input Source", |
| 2767 | .count = 2, |
| 2768 | .info = ad198x_mux_enum_info, |
| 2769 | .get = ad198x_mux_enum_get, |
| 2770 | .put = ad198x_mux_enum_put, |
| 2771 | }, |
| 2772 | /* SPDIF controls */ |
| 2773 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 2774 | { |
| 2775 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2776 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 2777 | /* identical with ad1983 */ |
| 2778 | .info = ad1983_spdif_route_info, |
| 2779 | .get = ad1983_spdif_route_get, |
| 2780 | .put = ad1983_spdif_route_put, |
| 2781 | }, |
| 2782 | { } /* end */ |
| 2783 | }; |
| 2784 | |
| 2785 | static struct snd_kcontrol_new ad1984_dmic_mixers[] = { |
| 2786 | HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT), |
| 2787 | HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT), |
| 2788 | HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 2789 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2790 | HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0, |
Takashi Iwai | 538c49c | 2007-06-05 12:13:34 +0200 | [diff] [blame] | 2791 | HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2792 | { } /* end */ |
| 2793 | }; |
| 2794 | |
| 2795 | /* |
| 2796 | * initialization verbs |
| 2797 | */ |
| 2798 | static struct hda_verb ad1884_init_verbs[] = { |
| 2799 | /* DACs; mute as default */ |
Takashi Iwai | 3b19440 | 2007-06-04 18:32:23 +0200 | [diff] [blame] | 2800 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2801 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2802 | /* Port-A (HP) mixer */ |
| 2803 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2804 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2805 | /* Port-A pin */ |
| 2806 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2807 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2808 | /* HP selector - select DAC2 */ |
| 2809 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2810 | /* Port-D (Line-out) mixer */ |
| 2811 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2812 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2813 | /* Port-D pin */ |
| 2814 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2815 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2816 | /* Mono-out mixer */ |
| 2817 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2818 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2819 | /* Mono-out pin */ |
| 2820 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2821 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2822 | /* Mono selector */ |
| 2823 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2824 | /* Port-B (front mic) pin */ |
| 2825 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2826 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2827 | /* Port-C (rear mic) pin */ |
| 2828 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2829 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2830 | /* Analog mixer; mute as default */ |
| 2831 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2832 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2833 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2834 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2835 | /* Analog Mix output amp */ |
| 2836 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 2837 | /* SPDIF output selector */ |
| 2838 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 2839 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 2840 | { } /* end */ |
| 2841 | }; |
| 2842 | |
| 2843 | static int patch_ad1884(struct hda_codec *codec) |
| 2844 | { |
| 2845 | struct ad198x_spec *spec; |
| 2846 | |
| 2847 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2848 | if (spec == NULL) |
| 2849 | return -ENOMEM; |
| 2850 | |
| 2851 | mutex_init(&spec->amp_mutex); |
| 2852 | codec->spec = spec; |
| 2853 | |
| 2854 | spec->multiout.max_channels = 2; |
| 2855 | spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids); |
| 2856 | spec->multiout.dac_nids = ad1884_dac_nids; |
| 2857 | spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; |
| 2858 | spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids); |
| 2859 | spec->adc_nids = ad1884_adc_nids; |
| 2860 | spec->capsrc_nids = ad1884_capsrc_nids; |
| 2861 | spec->input_mux = &ad1884_capture_source; |
| 2862 | spec->num_mixers = 1; |
| 2863 | spec->mixers[0] = ad1884_base_mixers; |
| 2864 | spec->num_init_verbs = 1; |
| 2865 | spec->init_verbs[0] = ad1884_init_verbs; |
| 2866 | spec->spdif_route = 0; |
| 2867 | |
| 2868 | codec->patch_ops = ad198x_patch_ops; |
| 2869 | |
| 2870 | return 0; |
| 2871 | } |
| 2872 | |
| 2873 | /* |
| 2874 | * Lenovo Thinkpad T61/X61 |
| 2875 | */ |
| 2876 | static struct hda_input_mux ad1984_thinkpad_capture_source = { |
Takashi Iwai | 3b19440 | 2007-06-04 18:32:23 +0200 | [diff] [blame] | 2877 | .num_items = 3, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2878 | .items = { |
| 2879 | { "Mic", 0x0 }, |
| 2880 | { "Internal Mic", 0x1 }, |
| 2881 | { "Mix", 0x3 }, |
| 2882 | }, |
| 2883 | }; |
| 2884 | |
| 2885 | static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = { |
| 2886 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 2887 | /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */ |
| 2888 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 2889 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 2890 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 2891 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 2892 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 2893 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 2894 | HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 2895 | HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2896 | HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), |
| 2897 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), |
Takashi Iwai | 0ba7962 | 2007-05-23 16:27:32 +0200 | [diff] [blame] | 2898 | HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
Takashi Iwai | b959d1f | 2007-06-08 12:25:25 +0200 | [diff] [blame] | 2899 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT), |
| 2900 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT), |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2901 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 2902 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 2903 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2904 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 2905 | { |
| 2906 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2907 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2908 | * So call somewhat different.. |
| 2909 | * FIXME: the controls appear in the "playback" view! |
| 2910 | */ |
| 2911 | /* .name = "Capture Source", */ |
| 2912 | .name = "Input Source", |
| 2913 | .count = 2, |
| 2914 | .info = ad198x_mux_enum_info, |
| 2915 | .get = ad198x_mux_enum_get, |
| 2916 | .put = ad198x_mux_enum_put, |
| 2917 | }, |
| 2918 | { } /* end */ |
| 2919 | }; |
| 2920 | |
| 2921 | /* additional verbs */ |
| 2922 | static struct hda_verb ad1984_thinkpad_init_verbs[] = { |
| 2923 | /* Port-E (docking station mic) pin */ |
| 2924 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2925 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2926 | /* docking mic boost */ |
| 2927 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2928 | /* Analog mixer - docking mic; mute as default */ |
| 2929 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
Takashi Iwai | b959d1f | 2007-06-08 12:25:25 +0200 | [diff] [blame] | 2930 | /* enable EAPD bit */ |
| 2931 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 2932 | { } /* end */ |
| 2933 | }; |
| 2934 | |
| 2935 | /* Digial MIC ADC NID 0x05 + 0x06 */ |
| 2936 | static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo, |
| 2937 | struct hda_codec *codec, |
| 2938 | unsigned int stream_tag, |
| 2939 | unsigned int format, |
| 2940 | struct snd_pcm_substream *substream) |
| 2941 | { |
| 2942 | snd_hda_codec_setup_stream(codec, 0x05 + substream->number, |
| 2943 | stream_tag, 0, format); |
| 2944 | return 0; |
| 2945 | } |
| 2946 | |
| 2947 | static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo, |
| 2948 | struct hda_codec *codec, |
| 2949 | struct snd_pcm_substream *substream) |
| 2950 | { |
| 2951 | snd_hda_codec_setup_stream(codec, 0x05 + substream->number, |
| 2952 | 0, 0, 0); |
| 2953 | return 0; |
| 2954 | } |
| 2955 | |
| 2956 | static struct hda_pcm_stream ad1984_pcm_dmic_capture = { |
| 2957 | .substreams = 2, |
| 2958 | .channels_min = 2, |
| 2959 | .channels_max = 2, |
| 2960 | .nid = 0x05, |
| 2961 | .ops = { |
| 2962 | .prepare = ad1984_pcm_dmic_prepare, |
| 2963 | .cleanup = ad1984_pcm_dmic_cleanup |
| 2964 | }, |
| 2965 | }; |
| 2966 | |
| 2967 | static int ad1984_build_pcms(struct hda_codec *codec) |
| 2968 | { |
| 2969 | struct ad198x_spec *spec = codec->spec; |
| 2970 | struct hda_pcm *info; |
| 2971 | int err; |
| 2972 | |
| 2973 | err = ad198x_build_pcms(codec); |
| 2974 | if (err < 0) |
| 2975 | return err; |
| 2976 | |
| 2977 | info = spec->pcm_rec + codec->num_pcms; |
| 2978 | codec->num_pcms++; |
| 2979 | info->name = "AD1984 Digital Mic"; |
| 2980 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture; |
| 2981 | return 0; |
| 2982 | } |
| 2983 | |
| 2984 | /* models */ |
| 2985 | enum { |
| 2986 | AD1984_BASIC, |
| 2987 | AD1984_THINKPAD, |
| 2988 | AD1984_MODELS |
| 2989 | }; |
| 2990 | |
| 2991 | static const char *ad1984_models[AD1984_MODELS] = { |
| 2992 | [AD1984_BASIC] = "basic", |
| 2993 | [AD1984_THINKPAD] = "thinkpad", |
| 2994 | }; |
| 2995 | |
| 2996 | static struct snd_pci_quirk ad1984_cfg_tbl[] = { |
| 2997 | /* Lenovo Thinkpad T61/X61 */ |
| 2998 | SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD), |
| 2999 | {} |
| 3000 | }; |
| 3001 | |
| 3002 | static int patch_ad1984(struct hda_codec *codec) |
| 3003 | { |
| 3004 | struct ad198x_spec *spec; |
| 3005 | int board_config, err; |
| 3006 | |
| 3007 | err = patch_ad1884(codec); |
| 3008 | if (err < 0) |
| 3009 | return err; |
| 3010 | spec = codec->spec; |
| 3011 | board_config = snd_hda_check_board_config(codec, AD1984_MODELS, |
| 3012 | ad1984_models, ad1984_cfg_tbl); |
| 3013 | switch (board_config) { |
| 3014 | case AD1984_BASIC: |
| 3015 | /* additional digital mics */ |
| 3016 | spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers; |
| 3017 | codec->patch_ops.build_pcms = ad1984_build_pcms; |
| 3018 | break; |
| 3019 | case AD1984_THINKPAD: |
| 3020 | spec->multiout.dig_out_nid = 0; |
| 3021 | spec->input_mux = &ad1984_thinkpad_capture_source; |
| 3022 | spec->mixers[0] = ad1984_thinkpad_mixers; |
| 3023 | spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; |
| 3024 | break; |
| 3025 | } |
| 3026 | return 0; |
| 3027 | } |
| 3028 | |
| 3029 | |
| 3030 | /* |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 3031 | * AD1882 |
| 3032 | * |
| 3033 | * port-A - front hp-out |
| 3034 | * port-B - front mic-in |
| 3035 | * port-C - rear line-in, shared surr-out (3stack) |
| 3036 | * port-D - rear line-out |
| 3037 | * port-E - rear mic-in, shared clfe-out (3stack) |
| 3038 | * port-F - rear surr-out (6stack) |
| 3039 | * port-G - rear clfe-out (6stack) |
| 3040 | */ |
| 3041 | |
| 3042 | static hda_nid_t ad1882_dac_nids[3] = { |
| 3043 | 0x04, 0x03, 0x05 |
| 3044 | }; |
| 3045 | |
| 3046 | static hda_nid_t ad1882_adc_nids[2] = { |
| 3047 | 0x08, 0x09, |
| 3048 | }; |
| 3049 | |
| 3050 | static hda_nid_t ad1882_capsrc_nids[2] = { |
| 3051 | 0x0c, 0x0d, |
| 3052 | }; |
| 3053 | |
| 3054 | #define AD1882_SPDIF_OUT 0x02 |
| 3055 | |
| 3056 | /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */ |
| 3057 | static struct hda_input_mux ad1882_capture_source = { |
| 3058 | .num_items = 5, |
| 3059 | .items = { |
| 3060 | { "Front Mic", 0x1 }, |
| 3061 | { "Mic", 0x4 }, |
| 3062 | { "Line", 0x2 }, |
| 3063 | { "CD", 0x3 }, |
| 3064 | { "Mix", 0x7 }, |
| 3065 | }, |
| 3066 | }; |
| 3067 | |
| 3068 | static struct snd_kcontrol_new ad1882_base_mixers[] = { |
| 3069 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 3070 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 3071 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 3072 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 3073 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 3074 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 3075 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3076 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT), |
| 3077 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT), |
| 3078 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), |
| 3079 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), |
| 3080 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), |
| 3081 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT), |
| 3082 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT), |
| 3083 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), |
| 3084 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), |
| 3085 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT), |
| 3086 | HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT), |
| 3087 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 3088 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 3089 | HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT), |
| 3090 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 3091 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 3092 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3093 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 3094 | { |
| 3095 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3096 | /* The multiple "Capture Source" controls confuse alsamixer |
| 3097 | * So call somewhat different.. |
| 3098 | * FIXME: the controls appear in the "playback" view! |
| 3099 | */ |
| 3100 | /* .name = "Capture Source", */ |
| 3101 | .name = "Input Source", |
| 3102 | .count = 2, |
| 3103 | .info = ad198x_mux_enum_info, |
| 3104 | .get = ad198x_mux_enum_get, |
| 3105 | .put = ad198x_mux_enum_put, |
| 3106 | }, |
| 3107 | /* SPDIF controls */ |
| 3108 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 3109 | { |
| 3110 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3111 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
| 3112 | /* identical with ad1983 */ |
| 3113 | .info = ad1983_spdif_route_info, |
| 3114 | .get = ad1983_spdif_route_get, |
| 3115 | .put = ad1983_spdif_route_put, |
| 3116 | }, |
| 3117 | { } /* end */ |
| 3118 | }; |
| 3119 | |
| 3120 | static struct snd_kcontrol_new ad1882_3stack_mixers[] = { |
| 3121 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 3122 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT), |
| 3123 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT), |
| 3124 | { |
| 3125 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3126 | .name = "Channel Mode", |
| 3127 | .info = ad198x_ch_mode_info, |
| 3128 | .get = ad198x_ch_mode_get, |
| 3129 | .put = ad198x_ch_mode_put, |
| 3130 | }, |
| 3131 | { } /* end */ |
| 3132 | }; |
| 3133 | |
| 3134 | static struct snd_kcontrol_new ad1882_6stack_mixers[] = { |
| 3135 | HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 3136 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT), |
| 3137 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT), |
| 3138 | { } /* end */ |
| 3139 | }; |
| 3140 | |
| 3141 | static struct hda_verb ad1882_ch2_init[] = { |
| 3142 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3143 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3144 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3145 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3146 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3147 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3148 | { } /* end */ |
| 3149 | }; |
| 3150 | |
| 3151 | static struct hda_verb ad1882_ch4_init[] = { |
| 3152 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3153 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3154 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3155 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3156 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3157 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3158 | { } /* end */ |
| 3159 | }; |
| 3160 | |
| 3161 | static struct hda_verb ad1882_ch6_init[] = { |
| 3162 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3163 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3164 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3165 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3166 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3167 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3168 | { } /* end */ |
| 3169 | }; |
| 3170 | |
| 3171 | static struct hda_channel_mode ad1882_modes[3] = { |
| 3172 | { 2, ad1882_ch2_init }, |
| 3173 | { 4, ad1882_ch4_init }, |
| 3174 | { 6, ad1882_ch6_init }, |
| 3175 | }; |
| 3176 | |
| 3177 | /* |
| 3178 | * initialization verbs |
| 3179 | */ |
| 3180 | static struct hda_verb ad1882_init_verbs[] = { |
| 3181 | /* DACs; mute as default */ |
| 3182 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3183 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3184 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 3185 | /* Port-A (HP) mixer */ |
| 3186 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3187 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3188 | /* Port-A pin */ |
| 3189 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3190 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3191 | /* HP selector - select DAC2 */ |
| 3192 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3193 | /* Port-D (Line-out) mixer */ |
| 3194 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3195 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3196 | /* Port-D pin */ |
| 3197 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3198 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3199 | /* Mono-out mixer */ |
| 3200 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3201 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3202 | /* Mono-out pin */ |
| 3203 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 3204 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3205 | /* Port-B (front mic) pin */ |
| 3206 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3207 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3208 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 3209 | /* Port-C (line-in) pin */ |
| 3210 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 3211 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3212 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 3213 | /* Port-C mixer - mute as input */ |
| 3214 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3215 | {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3216 | /* Port-E (mic-in) pin */ |
| 3217 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 3218 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3219 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */ |
| 3220 | /* Port-E mixer - mute as input */ |
| 3221 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3222 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3223 | /* Port-F (surround) */ |
| 3224 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3225 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3226 | /* Port-G (CLFE) */ |
| 3227 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 3228 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 3229 | /* Analog mixer; mute as default */ |
| 3230 | /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */ |
| 3231 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3232 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3233 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3234 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3235 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3236 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 3237 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 3238 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 3239 | /* Analog Mix output amp */ |
| 3240 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ |
| 3241 | /* SPDIF output selector */ |
| 3242 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3243 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 3244 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 3245 | { } /* end */ |
| 3246 | }; |
| 3247 | |
| 3248 | /* models */ |
| 3249 | enum { |
| 3250 | AD1882_3STACK, |
| 3251 | AD1882_6STACK, |
| 3252 | AD1882_MODELS |
| 3253 | }; |
| 3254 | |
| 3255 | static const char *ad1882_models[AD1986A_MODELS] = { |
| 3256 | [AD1882_3STACK] = "3stack", |
| 3257 | [AD1882_6STACK] = "6stack", |
| 3258 | }; |
| 3259 | |
| 3260 | |
| 3261 | static int patch_ad1882(struct hda_codec *codec) |
| 3262 | { |
| 3263 | struct ad198x_spec *spec; |
| 3264 | int board_config; |
| 3265 | |
| 3266 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3267 | if (spec == NULL) |
| 3268 | return -ENOMEM; |
| 3269 | |
| 3270 | mutex_init(&spec->amp_mutex); |
| 3271 | codec->spec = spec; |
| 3272 | |
| 3273 | spec->multiout.max_channels = 6; |
| 3274 | spec->multiout.num_dacs = 3; |
| 3275 | spec->multiout.dac_nids = ad1882_dac_nids; |
| 3276 | spec->multiout.dig_out_nid = AD1882_SPDIF_OUT; |
| 3277 | spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids); |
| 3278 | spec->adc_nids = ad1882_adc_nids; |
| 3279 | spec->capsrc_nids = ad1882_capsrc_nids; |
| 3280 | spec->input_mux = &ad1882_capture_source; |
| 3281 | spec->num_mixers = 1; |
| 3282 | spec->mixers[0] = ad1882_base_mixers; |
| 3283 | spec->num_init_verbs = 1; |
| 3284 | spec->init_verbs[0] = ad1882_init_verbs; |
| 3285 | spec->spdif_route = 0; |
| 3286 | |
| 3287 | codec->patch_ops = ad198x_patch_ops; |
| 3288 | |
| 3289 | /* override some parameters */ |
| 3290 | board_config = snd_hda_check_board_config(codec, AD1882_MODELS, |
| 3291 | ad1882_models, NULL); |
| 3292 | switch (board_config) { |
| 3293 | default: |
| 3294 | case AD1882_3STACK: |
| 3295 | spec->num_mixers = 2; |
| 3296 | spec->mixers[1] = ad1882_3stack_mixers; |
| 3297 | spec->channel_mode = ad1882_modes; |
| 3298 | spec->num_channel_mode = ARRAY_SIZE(ad1882_modes); |
| 3299 | spec->need_dac_fix = 1; |
| 3300 | spec->multiout.max_channels = 2; |
| 3301 | spec->multiout.num_dacs = 1; |
| 3302 | break; |
| 3303 | case AD1882_6STACK: |
| 3304 | spec->num_mixers = 2; |
| 3305 | spec->mixers[1] = ad1882_6stack_mixers; |
| 3306 | break; |
| 3307 | } |
| 3308 | return 0; |
| 3309 | } |
| 3310 | |
| 3311 | |
| 3312 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3313 | * patch entries |
| 3314 | */ |
| 3315 | struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | 0ac8551 | 2007-06-20 15:46:13 +0200 | [diff] [blame] | 3316 | { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3317 | { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 3318 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 3319 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Takashi Iwai | 2bac647 | 2007-05-18 18:21:41 +0200 | [diff] [blame] | 3320 | { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3321 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 3322 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Takashi Iwai | 71b2ccc | 2006-04-21 16:09:31 +0200 | [diff] [blame] | 3323 | { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3324 | {} /* terminator */ |
| 3325 | }; |