Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2 | * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> |
| 5 | * |
| 6 | * This driver is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This driver is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include <sound/driver.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/pci.h> |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 26 | #include <linux/mutex.h> |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <sound/core.h> |
| 29 | #include "hda_codec.h" |
| 30 | #include "hda_local.h" |
| 31 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 32 | struct ad198x_spec { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 33 | struct snd_kcontrol_new *mixers[5]; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 34 | int num_mixers; |
| 35 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 36 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 37 | * don't forget NULL termination! |
| 38 | */ |
| 39 | unsigned int num_init_verbs; |
| 40 | |
| 41 | /* playback */ |
| 42 | struct hda_multi_out multiout; /* playback set-up |
| 43 | * max_channels, dacs must be set |
| 44 | * dig_out_nid and hp_nid are optional |
| 45 | */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 46 | unsigned int cur_eapd; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 47 | unsigned int need_dac_fix; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 48 | |
| 49 | /* capture */ |
| 50 | unsigned int num_adc_nids; |
| 51 | hda_nid_t *adc_nids; |
| 52 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 53 | |
| 54 | /* capture source */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 55 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 56 | hda_nid_t *capsrc_nids; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 57 | unsigned int cur_mux[3]; |
| 58 | |
| 59 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 60 | const struct hda_channel_mode *channel_mode; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 61 | int num_channel_mode; |
| 62 | |
| 63 | /* PCM information */ |
| 64 | struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ |
| 65 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 66 | struct mutex amp_mutex; /* PCM volume/mute control mutex */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 67 | unsigned int spdif_route; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 68 | |
| 69 | /* dynamic controls, init_verbs and input_mux */ |
| 70 | struct auto_pin_cfg autocfg; |
| 71 | unsigned int num_kctl_alloc, num_kctl_used; |
| 72 | struct snd_kcontrol_new *kctl_alloc; |
| 73 | struct hda_input_mux private_imux; |
| 74 | hda_nid_t private_dac_nids[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 77 | /* |
| 78 | * input MUX handling (common part) |
| 79 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 80 | 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] | 81 | { |
| 82 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 83 | struct ad198x_spec *spec = codec->spec; |
| 84 | |
| 85 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 86 | } |
| 87 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 88 | 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] | 89 | { |
| 90 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 91 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 92 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 93 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 94 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 98 | 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] | 99 | { |
| 100 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 101 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 102 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 103 | |
| 104 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 105 | spec->capsrc_nids[adc_idx], |
| 106 | &spec->cur_mux[adc_idx]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* |
| 110 | * initialization (common callbacks) |
| 111 | */ |
| 112 | static int ad198x_init(struct hda_codec *codec) |
| 113 | { |
| 114 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 115 | int i; |
| 116 | |
| 117 | for (i = 0; i < spec->num_init_verbs; i++) |
| 118 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | static int ad198x_build_controls(struct hda_codec *codec) |
| 123 | { |
| 124 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 125 | unsigned int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 126 | int err; |
| 127 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 128 | for (i = 0; i < spec->num_mixers; i++) { |
| 129 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 130 | if (err < 0) |
| 131 | return err; |
| 132 | } |
| 133 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 134 | 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] | 135 | if (err < 0) |
| 136 | return err; |
| 137 | } |
| 138 | if (spec->dig_in_nid) { |
| 139 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 140 | if (err < 0) |
| 141 | return err; |
| 142 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | * Analog playback callbacks |
| 148 | */ |
| 149 | static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 150 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 151 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 152 | { |
| 153 | struct ad198x_spec *spec = codec->spec; |
| 154 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 155 | } |
| 156 | |
| 157 | static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 158 | struct hda_codec *codec, |
| 159 | unsigned int stream_tag, |
| 160 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 161 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 162 | { |
| 163 | struct ad198x_spec *spec = codec->spec; |
| 164 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, |
| 165 | format, substream); |
| 166 | } |
| 167 | |
| 168 | static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 169 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 170 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 171 | { |
| 172 | struct ad198x_spec *spec = codec->spec; |
| 173 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 174 | } |
| 175 | |
| 176 | /* |
| 177 | * Digital out |
| 178 | */ |
| 179 | static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 180 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 181 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 182 | { |
| 183 | struct ad198x_spec *spec = codec->spec; |
| 184 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 185 | } |
| 186 | |
| 187 | static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 188 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 189 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 190 | { |
| 191 | struct ad198x_spec *spec = codec->spec; |
| 192 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 193 | } |
| 194 | |
| 195 | /* |
| 196 | * Analog capture |
| 197 | */ |
| 198 | static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 199 | struct hda_codec *codec, |
| 200 | unsigned int stream_tag, |
| 201 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 202 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 203 | { |
| 204 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 205 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 206 | stream_tag, 0, format); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 211 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 212 | struct snd_pcm_substream *substream) |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 213 | { |
| 214 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 215 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 216 | 0, 0, 0); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | |
| 221 | /* |
| 222 | */ |
| 223 | static struct hda_pcm_stream ad198x_pcm_analog_playback = { |
| 224 | .substreams = 1, |
| 225 | .channels_min = 2, |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 226 | .channels_max = 6, /* changed later */ |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 227 | .nid = 0, /* fill later */ |
| 228 | .ops = { |
| 229 | .open = ad198x_playback_pcm_open, |
| 230 | .prepare = ad198x_playback_pcm_prepare, |
| 231 | .cleanup = ad198x_playback_pcm_cleanup |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static struct hda_pcm_stream ad198x_pcm_analog_capture = { |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 236 | .substreams = 1, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 237 | .channels_min = 2, |
| 238 | .channels_max = 2, |
| 239 | .nid = 0, /* fill later */ |
| 240 | .ops = { |
| 241 | .prepare = ad198x_capture_pcm_prepare, |
| 242 | .cleanup = ad198x_capture_pcm_cleanup |
| 243 | }, |
| 244 | }; |
| 245 | |
| 246 | static struct hda_pcm_stream ad198x_pcm_digital_playback = { |
| 247 | .substreams = 1, |
| 248 | .channels_min = 2, |
| 249 | .channels_max = 2, |
| 250 | .nid = 0, /* fill later */ |
| 251 | .ops = { |
| 252 | .open = ad198x_dig_playback_pcm_open, |
| 253 | .close = ad198x_dig_playback_pcm_close |
| 254 | }, |
| 255 | }; |
| 256 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 257 | static struct hda_pcm_stream ad198x_pcm_digital_capture = { |
| 258 | .substreams = 1, |
| 259 | .channels_min = 2, |
| 260 | .channels_max = 2, |
| 261 | /* NID is set in alc_build_pcms */ |
| 262 | }; |
| 263 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 264 | static int ad198x_build_pcms(struct hda_codec *codec) |
| 265 | { |
| 266 | struct ad198x_spec *spec = codec->spec; |
| 267 | struct hda_pcm *info = spec->pcm_rec; |
| 268 | |
| 269 | codec->num_pcms = 1; |
| 270 | codec->pcm_info = info; |
| 271 | |
| 272 | info->name = "AD198x Analog"; |
| 273 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; |
| 274 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; |
| 275 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 276 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 277 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; |
| 278 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 279 | |
| 280 | if (spec->multiout.dig_out_nid) { |
| 281 | info++; |
| 282 | codec->num_pcms++; |
| 283 | info->name = "AD198x Digital"; |
| 284 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; |
| 285 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 286 | if (spec->dig_in_nid) { |
| 287 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture; |
| 288 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 289 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | static void ad198x_free(struct hda_codec *codec) |
| 296 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 297 | struct ad198x_spec *spec = codec->spec; |
| 298 | unsigned int i; |
| 299 | |
| 300 | if (spec->kctl_alloc) { |
| 301 | for (i = 0; i < spec->num_kctl_used; i++) |
| 302 | kfree(spec->kctl_alloc[i].name); |
| 303 | kfree(spec->kctl_alloc); |
| 304 | } |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 305 | kfree(codec->spec); |
| 306 | } |
| 307 | |
| 308 | #ifdef CONFIG_PM |
| 309 | static int ad198x_resume(struct hda_codec *codec) |
| 310 | { |
| 311 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 312 | int i; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 313 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 314 | codec->patch_ops.init(codec); |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 315 | for (i = 0; i < spec->num_mixers; i++) |
| 316 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
| 317 | if (spec->multiout.dig_out_nid) |
| 318 | snd_hda_resume_spdif_out(codec); |
| 319 | if (spec->dig_in_nid) |
| 320 | snd_hda_resume_spdif_in(codec); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | #endif |
| 324 | |
| 325 | static struct hda_codec_ops ad198x_patch_ops = { |
| 326 | .build_controls = ad198x_build_controls, |
| 327 | .build_pcms = ad198x_build_pcms, |
| 328 | .init = ad198x_init, |
| 329 | .free = ad198x_free, |
| 330 | #ifdef CONFIG_PM |
| 331 | .resume = ad198x_resume, |
| 332 | #endif |
| 333 | }; |
| 334 | |
| 335 | |
| 336 | /* |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 337 | * EAPD control |
| 338 | * the private value = nid | (invert << 8) |
| 339 | */ |
| 340 | static int ad198x_eapd_info(struct snd_kcontrol *kcontrol, |
| 341 | struct snd_ctl_elem_info *uinfo) |
| 342 | { |
| 343 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 344 | uinfo->count = 1; |
| 345 | uinfo->value.integer.min = 0; |
| 346 | uinfo->value.integer.max = 1; |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | static int ad198x_eapd_get(struct snd_kcontrol *kcontrol, |
| 351 | struct snd_ctl_elem_value *ucontrol) |
| 352 | { |
| 353 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 354 | struct ad198x_spec *spec = codec->spec; |
| 355 | int invert = (kcontrol->private_value >> 8) & 1; |
| 356 | if (invert) |
| 357 | ucontrol->value.integer.value[0] = ! spec->cur_eapd; |
| 358 | else |
| 359 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | static int ad198x_eapd_put(struct snd_kcontrol *kcontrol, |
| 364 | struct snd_ctl_elem_value *ucontrol) |
| 365 | { |
| 366 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 367 | struct ad198x_spec *spec = codec->spec; |
| 368 | int invert = (kcontrol->private_value >> 8) & 1; |
| 369 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 370 | unsigned int eapd; |
| 371 | eapd = ucontrol->value.integer.value[0]; |
| 372 | if (invert) |
| 373 | eapd = !eapd; |
| 374 | if (eapd == spec->cur_eapd && ! codec->in_resume) |
| 375 | return 0; |
| 376 | spec->cur_eapd = eapd; |
| 377 | snd_hda_codec_write(codec, nid, |
| 378 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 379 | eapd ? 0x02 : 0x00); |
| 380 | return 1; |
| 381 | } |
| 382 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 383 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 384 | struct snd_ctl_elem_info *uinfo); |
| 385 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 386 | struct snd_ctl_elem_value *ucontrol); |
| 387 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 388 | struct snd_ctl_elem_value *ucontrol); |
| 389 | |
| 390 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 391 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 392 | * AD1986A specific |
| 393 | */ |
| 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | #define AD1986A_SPDIF_OUT 0x02 |
| 396 | #define AD1986A_FRONT_DAC 0x03 |
| 397 | #define AD1986A_SURR_DAC 0x04 |
| 398 | #define AD1986A_CLFE_DAC 0x05 |
| 399 | #define AD1986A_ADC 0x06 |
| 400 | |
| 401 | static hda_nid_t ad1986a_dac_nids[3] = { |
| 402 | AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC |
| 403 | }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 404 | static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 405 | static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
| 407 | static struct hda_input_mux ad1986a_capture_source = { |
| 408 | .num_items = 7, |
| 409 | .items = { |
| 410 | { "Mic", 0x0 }, |
| 411 | { "CD", 0x1 }, |
| 412 | { "Aux", 0x3 }, |
| 413 | { "Line", 0x4 }, |
| 414 | { "Mix", 0x5 }, |
| 415 | { "Mono", 0x6 }, |
| 416 | { "Phone", 0x7 }, |
| 417 | }, |
| 418 | }; |
| 419 | |
| 420 | /* |
| 421 | * PCM control |
| 422 | * |
| 423 | * bind volumes/mutes of 3 DACs as a single PCM control for simplicity |
| 424 | */ |
| 425 | |
| 426 | #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info |
| 427 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 428 | static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | { |
| 430 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 431 | struct ad198x_spec *ad = codec->spec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 433 | mutex_lock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 435 | mutex_unlock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | return 0; |
| 437 | } |
| 438 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 439 | static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | { |
| 441 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 442 | struct ad198x_spec *ad = codec->spec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | int i, change = 0; |
| 444 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 445 | mutex_lock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) { |
| 447 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT); |
| 448 | change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 449 | } |
| 450 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT); |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 451 | mutex_unlock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | return change; |
| 453 | } |
| 454 | |
Takashi Iwai | ead9b7c | 2005-06-08 14:48:19 +0200 | [diff] [blame] | 455 | #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 457 | static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | { |
| 459 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 460 | struct ad198x_spec *ad = codec->spec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 462 | mutex_lock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 464 | mutex_unlock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | return 0; |
| 466 | } |
| 467 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 468 | static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | { |
| 470 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 471 | struct ad198x_spec *ad = codec->spec; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | int i, change = 0; |
| 473 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 474 | mutex_lock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) { |
| 476 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT); |
| 477 | change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
| 478 | } |
| 479 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT); |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 480 | mutex_unlock(&ad->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | return change; |
| 482 | } |
| 483 | |
| 484 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | * mixers |
| 486 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 487 | static struct snd_kcontrol_new ad1986a_mixers[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
| 489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 490 | .name = "PCM Playback Volume", |
| 491 | .info = ad1986a_pcm_amp_vol_info, |
| 492 | .get = ad1986a_pcm_amp_vol_get, |
| 493 | .put = ad1986a_pcm_amp_vol_put, |
| 494 | .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT) |
| 495 | }, |
| 496 | { |
| 497 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 498 | .name = "PCM Playback Switch", |
| 499 | .info = ad1986a_pcm_amp_sw_info, |
| 500 | .get = ad1986a_pcm_amp_sw_get, |
| 501 | .put = ad1986a_pcm_amp_sw_put, |
| 502 | .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT) |
| 503 | }, |
| 504 | HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 505 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 506 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 507 | HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 508 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 509 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 510 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT), |
| 511 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT), |
| 512 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 513 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), |
| 514 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 515 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 516 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 517 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 518 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 519 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 520 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 521 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 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", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 531 | .info = ad198x_mux_enum_info, |
| 532 | .get = ad198x_mux_enum_get, |
| 533 | .put = ad198x_mux_enum_put, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | }, |
| 535 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), |
| 536 | { } /* end */ |
| 537 | }; |
| 538 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 539 | /* additional mixers for 3stack mode */ |
| 540 | static struct snd_kcontrol_new ad1986a_3st_mixers[] = { |
| 541 | { |
| 542 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 543 | .name = "Channel Mode", |
| 544 | .info = ad198x_ch_mode_info, |
| 545 | .get = ad198x_ch_mode_get, |
| 546 | .put = ad198x_ch_mode_put, |
| 547 | }, |
| 548 | { } /* end */ |
| 549 | }; |
| 550 | |
| 551 | /* laptop model - 2ch only */ |
| 552 | static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC }; |
| 553 | |
| 554 | static struct snd_kcontrol_new ad1986a_laptop_mixers[] = { |
| 555 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 556 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 557 | HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 558 | HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 559 | /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), |
| 560 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */ |
| 561 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 562 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
| 563 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 564 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 565 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), |
| 566 | HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), |
| 567 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 568 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 569 | /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), |
| 570 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), |
| 571 | HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), |
| 572 | HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ |
| 573 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 574 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 575 | { |
| 576 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 577 | .name = "Capture Source", |
| 578 | .info = ad198x_mux_enum_info, |
| 579 | .get = ad198x_mux_enum_get, |
| 580 | .put = ad198x_mux_enum_put, |
| 581 | }, |
| 582 | { } /* end */ |
| 583 | }; |
| 584 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 585 | /* laptop-eapd model - 2ch only */ |
| 586 | |
| 587 | /* master controls both pins 0x1a and 0x1b */ |
| 588 | static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol, |
| 589 | struct snd_ctl_elem_value *ucontrol) |
| 590 | { |
| 591 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 592 | long *valp = ucontrol->value.integer.value; |
| 593 | int change; |
| 594 | |
| 595 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 596 | 0x7f, valp[0] & 0x7f); |
| 597 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 598 | 0x7f, valp[1] & 0x7f); |
| 599 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
| 600 | 0x7f, valp[0] & 0x7f); |
| 601 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
| 602 | 0x7f, valp[1] & 0x7f); |
| 603 | return change; |
| 604 | } |
| 605 | |
| 606 | static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol, |
| 607 | struct snd_ctl_elem_value *ucontrol) |
| 608 | { |
| 609 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 610 | long *valp = ucontrol->value.integer.value; |
| 611 | int change; |
| 612 | |
| 613 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 614 | 0x80, valp[0] ? 0 : 0x80); |
| 615 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 616 | 0x80, valp[1] ? 0 : 0x80); |
| 617 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
| 618 | 0x80, valp[0] ? 0 : 0x80); |
| 619 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
| 620 | 0x80, valp[1] ? 0 : 0x80); |
| 621 | return change; |
| 622 | } |
| 623 | |
| 624 | static struct hda_input_mux ad1986a_laptop_eapd_capture_source = { |
| 625 | .num_items = 3, |
| 626 | .items = { |
| 627 | { "Mic", 0x0 }, |
| 628 | { "Internal Mic", 0x4 }, |
| 629 | { "Mix", 0x5 }, |
| 630 | }, |
| 631 | }; |
| 632 | |
| 633 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
| 634 | { |
| 635 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 636 | .name = "Master Playback Volume", |
| 637 | .info = snd_hda_mixer_amp_volume_info, |
| 638 | .get = snd_hda_mixer_amp_volume_get, |
| 639 | .put = ad1986a_laptop_master_vol_put, |
| 640 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 641 | }, |
| 642 | { |
| 643 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 644 | .name = "Master Playback Switch", |
| 645 | .info = snd_hda_mixer_amp_switch_info, |
| 646 | .get = snd_hda_mixer_amp_switch_get, |
| 647 | .put = ad1986a_laptop_master_sw_put, |
| 648 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 649 | }, |
| 650 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 651 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 652 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 653 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 654 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 655 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 656 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 657 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 658 | { |
| 659 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 660 | .name = "Capture Source", |
| 661 | .info = ad198x_mux_enum_info, |
| 662 | .get = ad198x_mux_enum_get, |
| 663 | .put = ad198x_mux_enum_put, |
| 664 | }, |
| 665 | { |
| 666 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 667 | .name = "External Amplifier", |
| 668 | .info = ad198x_eapd_info, |
| 669 | .get = ad198x_eapd_get, |
| 670 | .put = ad198x_eapd_put, |
| 671 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ |
| 672 | }, |
| 673 | { } /* end */ |
| 674 | }; |
| 675 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | /* |
| 677 | * initialization verbs |
| 678 | */ |
| 679 | static struct hda_verb ad1986a_init_verbs[] = { |
| 680 | /* Front, Surround, CLFE DAC; mute as default */ |
| 681 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 682 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 683 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 684 | /* Downmix - off */ |
| 685 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 686 | /* HP, Line-Out, Surround, CLFE selectors */ |
| 687 | {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 688 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 689 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 690 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 691 | /* Mono selector */ |
| 692 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 693 | /* Mic selector: Mic 1/2 pin */ |
| 694 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 695 | /* Line-in selector: Line-in */ |
| 696 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 697 | /* Mic 1/2 swap */ |
| 698 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 699 | /* Record selector: mic */ |
| 700 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 701 | /* Mic, Phone, CD, Aux, Line-In amp; mute as default */ |
| 702 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 703 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 704 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 705 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 706 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 707 | /* PC beep */ |
| 708 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 709 | /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */ |
| 710 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 711 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 712 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 713 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 714 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 715 | /* HP Pin */ |
| 716 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 717 | /* Front, Surround, CLFE Pins */ |
| 718 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 719 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 720 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 721 | /* Mono Pin */ |
| 722 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 723 | /* Mic Pin */ |
| 724 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 725 | /* Line, Aux, CD, Beep-In Pin */ |
| 726 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 727 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 728 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 729 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 730 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | { } /* end */ |
| 732 | }; |
| 733 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 734 | /* additional verbs for 3-stack model */ |
| 735 | static struct hda_verb ad1986a_3st_init_verbs[] = { |
| 736 | /* Mic and line-in selectors */ |
| 737 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
| 738 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 739 | { } /* end */ |
| 740 | }; |
| 741 | |
| 742 | static struct hda_verb ad1986a_ch2_init[] = { |
| 743 | /* Surround out -> Line In */ |
| 744 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 745 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 746 | /* CLFE -> Mic in */ |
| 747 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 748 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 749 | { } /* end */ |
| 750 | }; |
| 751 | |
| 752 | static struct hda_verb ad1986a_ch4_init[] = { |
| 753 | /* Surround out -> Surround */ |
| 754 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 755 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 756 | /* CLFE -> Mic in */ |
| 757 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 758 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 759 | { } /* end */ |
| 760 | }; |
| 761 | |
| 762 | static struct hda_verb ad1986a_ch6_init[] = { |
| 763 | /* Surround out -> Surround out */ |
| 764 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 765 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 766 | /* CLFE -> CLFE */ |
| 767 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 768 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 769 | { } /* end */ |
| 770 | }; |
| 771 | |
| 772 | static struct hda_channel_mode ad1986a_modes[3] = { |
| 773 | { 2, ad1986a_ch2_init }, |
| 774 | { 4, ad1986a_ch4_init }, |
| 775 | { 6, ad1986a_ch6_init }, |
| 776 | }; |
| 777 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 778 | /* eapd initialization */ |
| 779 | static struct hda_verb ad1986a_eapd_init_verbs[] = { |
| 780 | {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, |
| 781 | {} |
| 782 | }; |
| 783 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 784 | /* models */ |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 785 | enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 786 | |
| 787 | static struct hda_board_config ad1986a_cfg_tbl[] = { |
| 788 | { .modelname = "6stack", .config = AD1986A_6STACK }, |
| 789 | { .modelname = "3stack", .config = AD1986A_3STACK }, |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 790 | { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84, |
| 791 | .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */ |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 792 | { .modelname = "laptop", .config = AD1986A_LAPTOP }, |
| 793 | { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e, |
| 794 | .config = AD1986A_LAPTOP }, /* FSC V2060 */ |
| 795 | { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017, |
| 796 | .config = AD1986A_LAPTOP }, /* Samsung M50 */ |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 797 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f, |
| 798 | .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */ |
| 799 | { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD }, |
| 800 | { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024, |
| 801 | .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */ |
| 802 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213, |
| 803 | .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */ |
Takashi Iwai | e092228 | 2006-04-10 19:09:01 +0200 | [diff] [blame] | 804 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7, |
| 805 | .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */ |
Coywolf Qi Hunt | be28e7c | 2006-04-10 10:47:11 +0200 | [diff] [blame] | 806 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af, |
| 807 | .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */ |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 808 | {} |
| 809 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | static int patch_ad1986a(struct hda_codec *codec) |
| 812 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 813 | struct ad198x_spec *spec; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 814 | int board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 816 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | if (spec == NULL) |
| 818 | return -ENOMEM; |
| 819 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 820 | mutex_init(&spec->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | codec->spec = spec; |
| 822 | |
| 823 | spec->multiout.max_channels = 6; |
| 824 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); |
| 825 | spec->multiout.dac_nids = ad1986a_dac_nids; |
| 826 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 827 | spec->num_adc_nids = 1; |
| 828 | spec->adc_nids = ad1986a_adc_nids; |
Takashi Iwai | a7ee820 | 2006-03-01 20:05:39 +0100 | [diff] [blame] | 829 | spec->capsrc_nids = ad1986a_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 830 | spec->input_mux = &ad1986a_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 831 | spec->num_mixers = 1; |
| 832 | spec->mixers[0] = ad1986a_mixers; |
| 833 | spec->num_init_verbs = 1; |
| 834 | spec->init_verbs[0] = ad1986a_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 836 | codec->patch_ops = ad198x_patch_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 838 | /* override some parameters */ |
| 839 | board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl); |
| 840 | switch (board_config) { |
| 841 | case AD1986A_3STACK: |
| 842 | spec->num_mixers = 2; |
| 843 | spec->mixers[1] = ad1986a_3st_mixers; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 844 | spec->num_init_verbs = 3; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 845 | spec->init_verbs[1] = ad1986a_3st_init_verbs; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 846 | spec->init_verbs[2] = ad1986a_ch2_init; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 847 | spec->channel_mode = ad1986a_modes; |
| 848 | spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 849 | spec->need_dac_fix = 1; |
| 850 | spec->multiout.max_channels = 2; |
| 851 | spec->multiout.num_dacs = 1; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 852 | break; |
| 853 | case AD1986A_LAPTOP: |
| 854 | spec->mixers[0] = ad1986a_laptop_mixers; |
| 855 | spec->multiout.max_channels = 2; |
| 856 | spec->multiout.num_dacs = 1; |
| 857 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 858 | break; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame] | 859 | case AD1986A_LAPTOP_EAPD: |
| 860 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 861 | spec->num_init_verbs = 2; |
| 862 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 863 | spec->multiout.max_channels = 2; |
| 864 | spec->multiout.num_dacs = 1; |
| 865 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 866 | spec->multiout.dig_out_nid = 0; |
| 867 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 868 | break; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 869 | } |
| 870 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | return 0; |
| 872 | } |
| 873 | |
| 874 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 875 | * AD1983 specific |
| 876 | */ |
| 877 | |
| 878 | #define AD1983_SPDIF_OUT 0x02 |
| 879 | #define AD1983_DAC 0x03 |
| 880 | #define AD1983_ADC 0x04 |
| 881 | |
| 882 | static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 883 | static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 884 | static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 885 | |
| 886 | static struct hda_input_mux ad1983_capture_source = { |
| 887 | .num_items = 4, |
| 888 | .items = { |
| 889 | { "Mic", 0x0 }, |
| 890 | { "Line", 0x1 }, |
| 891 | { "Mix", 0x2 }, |
| 892 | { "Mix Mono", 0x3 }, |
| 893 | }, |
| 894 | }; |
| 895 | |
| 896 | /* |
| 897 | * SPDIF playback route |
| 898 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 899 | 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] | 900 | { |
| 901 | static char *texts[] = { "PCM", "ADC" }; |
| 902 | |
| 903 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 904 | uinfo->count = 1; |
| 905 | uinfo->value.enumerated.items = 2; |
| 906 | if (uinfo->value.enumerated.item > 1) |
| 907 | uinfo->value.enumerated.item = 1; |
| 908 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 909 | return 0; |
| 910 | } |
| 911 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 912 | 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] | 913 | { |
| 914 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 915 | struct ad198x_spec *spec = codec->spec; |
| 916 | |
| 917 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
| 918 | return 0; |
| 919 | } |
| 920 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 921 | 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] | 922 | { |
| 923 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 924 | struct ad198x_spec *spec = codec->spec; |
| 925 | |
| 926 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { |
| 927 | spec->spdif_route = ucontrol->value.enumerated.item[0]; |
| 928 | snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, |
| 929 | AC_VERB_SET_CONNECT_SEL, spec->spdif_route); |
| 930 | return 1; |
| 931 | } |
| 932 | return 0; |
| 933 | } |
| 934 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 935 | static struct snd_kcontrol_new ad1983_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 936 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 937 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 938 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 939 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 940 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 941 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 942 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 943 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 944 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 945 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 946 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 947 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 948 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT), |
| 949 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT), |
| 950 | HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), |
| 951 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 952 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 953 | { |
| 954 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 955 | .name = "Capture Source", |
| 956 | .info = ad198x_mux_enum_info, |
| 957 | .get = ad198x_mux_enum_get, |
| 958 | .put = ad198x_mux_enum_put, |
| 959 | }, |
| 960 | { |
| 961 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Clemens Ladisch | 10e8d78 | 2005-08-03 13:40:08 +0200 | [diff] [blame] | 962 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 963 | .info = ad1983_spdif_route_info, |
| 964 | .get = ad1983_spdif_route_get, |
| 965 | .put = ad1983_spdif_route_put, |
| 966 | }, |
| 967 | { } /* end */ |
| 968 | }; |
| 969 | |
| 970 | static struct hda_verb ad1983_init_verbs[] = { |
| 971 | /* Front, HP, Mono; mute as default */ |
| 972 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 973 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 974 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 975 | /* Beep, PCM, Mic, Line-In: mute */ |
| 976 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 977 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 978 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 979 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 980 | /* Front, HP selectors; from Mix */ |
| 981 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 982 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 983 | /* Mono selector; from Mix */ |
| 984 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 985 | /* Mic selector; Mic */ |
| 986 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 987 | /* Line-in selector: Line-in */ |
| 988 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 989 | /* Mic boost: 0dB */ |
| 990 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 991 | /* Record selector: mic */ |
| 992 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 993 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 994 | /* SPDIF route: PCM */ |
| 995 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 996 | /* Front Pin */ |
| 997 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 998 | /* HP Pin */ |
| 999 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1000 | /* Mono Pin */ |
| 1001 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1002 | /* Mic Pin */ |
| 1003 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1004 | /* Line Pin */ |
| 1005 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1006 | { } /* end */ |
| 1007 | }; |
| 1008 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1009 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1010 | static int patch_ad1983(struct hda_codec *codec) |
| 1011 | { |
| 1012 | struct ad198x_spec *spec; |
| 1013 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1014 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1015 | if (spec == NULL) |
| 1016 | return -ENOMEM; |
| 1017 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 1018 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1019 | codec->spec = spec; |
| 1020 | |
| 1021 | spec->multiout.max_channels = 2; |
| 1022 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); |
| 1023 | spec->multiout.dac_nids = ad1983_dac_nids; |
| 1024 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1025 | spec->num_adc_nids = 1; |
| 1026 | spec->adc_nids = ad1983_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1027 | spec->capsrc_nids = ad1983_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1028 | spec->input_mux = &ad1983_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1029 | spec->num_mixers = 1; |
| 1030 | spec->mixers[0] = ad1983_mixers; |
| 1031 | spec->num_init_verbs = 1; |
| 1032 | spec->init_verbs[0] = ad1983_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1033 | spec->spdif_route = 0; |
| 1034 | |
| 1035 | codec->patch_ops = ad198x_patch_ops; |
| 1036 | |
| 1037 | return 0; |
| 1038 | } |
| 1039 | |
| 1040 | |
| 1041 | /* |
| 1042 | * AD1981 HD specific |
| 1043 | */ |
| 1044 | |
| 1045 | #define AD1981_SPDIF_OUT 0x02 |
| 1046 | #define AD1981_DAC 0x03 |
| 1047 | #define AD1981_ADC 0x04 |
| 1048 | |
| 1049 | static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1050 | static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1051 | static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1052 | |
| 1053 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
| 1054 | static struct hda_input_mux ad1981_capture_source = { |
| 1055 | .num_items = 7, |
| 1056 | .items = { |
| 1057 | { "Front Mic", 0x0 }, |
| 1058 | { "Line", 0x1 }, |
| 1059 | { "Mix", 0x2 }, |
| 1060 | { "Mix Mono", 0x3 }, |
| 1061 | { "CD", 0x4 }, |
| 1062 | { "Mic", 0x6 }, |
| 1063 | { "Aux", 0x7 }, |
| 1064 | }, |
| 1065 | }; |
| 1066 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1067 | static struct snd_kcontrol_new ad1981_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1068 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1069 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1070 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1071 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1072 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1073 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1074 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1075 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1076 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1077 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1078 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1079 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1080 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1081 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 1082 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1083 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1084 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1085 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1086 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1087 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1088 | HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1089 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1090 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1091 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1092 | { |
| 1093 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1094 | .name = "Capture Source", |
| 1095 | .info = ad198x_mux_enum_info, |
| 1096 | .get = ad198x_mux_enum_get, |
| 1097 | .put = ad198x_mux_enum_put, |
| 1098 | }, |
| 1099 | /* identical with AD1983 */ |
| 1100 | { |
| 1101 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Clemens Ladisch | 10e8d78 | 2005-08-03 13:40:08 +0200 | [diff] [blame] | 1102 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1103 | .info = ad1983_spdif_route_info, |
| 1104 | .get = ad1983_spdif_route_get, |
| 1105 | .put = ad1983_spdif_route_put, |
| 1106 | }, |
| 1107 | { } /* end */ |
| 1108 | }; |
| 1109 | |
| 1110 | static struct hda_verb ad1981_init_verbs[] = { |
| 1111 | /* Front, HP, Mono; mute as default */ |
| 1112 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1113 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1114 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1115 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ |
| 1116 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1117 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1118 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1119 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1120 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1121 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1122 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1123 | /* Front, HP selectors; from Mix */ |
| 1124 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1125 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1126 | /* Mono selector; from Mix */ |
| 1127 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1128 | /* Mic Mixer; select Front Mic */ |
| 1129 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1130 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1131 | /* Mic boost: 0dB */ |
| 1132 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1133 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1134 | /* Record selector: Front mic */ |
| 1135 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1136 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1137 | /* SPDIF route: PCM */ |
| 1138 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1139 | /* Front Pin */ |
| 1140 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1141 | /* HP Pin */ |
| 1142 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1143 | /* Mono Pin */ |
| 1144 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1145 | /* Front & Rear Mic Pins */ |
| 1146 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1147 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1148 | /* Line Pin */ |
| 1149 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1150 | /* Digital Beep */ |
| 1151 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1152 | /* Line-Out as Input: disabled */ |
| 1153 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1154 | { } /* end */ |
| 1155 | }; |
| 1156 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1157 | /* |
| 1158 | * Patch for HP nx6320 |
| 1159 | * |
| 1160 | * nx6320 uses EAPD in the reserve way - EAPD-on means the internal |
| 1161 | * speaker output enabled _and_ mute-LED off. |
| 1162 | */ |
| 1163 | |
| 1164 | #define AD1981_HP_EVENT 0x37 |
| 1165 | #define AD1981_MIC_EVENT 0x38 |
| 1166 | |
| 1167 | static struct hda_verb ad1981_hp_init_verbs[] = { |
| 1168 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ |
| 1169 | /* pin sensing on HP and Mic jacks */ |
| 1170 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1171 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1172 | {} |
| 1173 | }; |
| 1174 | |
| 1175 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1176 | static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1177 | struct snd_ctl_elem_value *ucontrol) |
| 1178 | { |
| 1179 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1180 | struct ad198x_spec *spec = codec->spec; |
| 1181 | |
| 1182 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1183 | return 0; |
| 1184 | |
| 1185 | /* toggle HP mute appropriately */ |
| 1186 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1187 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1188 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1189 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1190 | return 1; |
| 1191 | } |
| 1192 | |
| 1193 | /* bind volumes of both NID 0x05 and 0x06 */ |
| 1194 | static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, |
| 1195 | struct snd_ctl_elem_value *ucontrol) |
| 1196 | { |
| 1197 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1198 | long *valp = ucontrol->value.integer.value; |
| 1199 | int change; |
| 1200 | |
| 1201 | change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1202 | 0x7f, valp[0] & 0x7f); |
| 1203 | change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1204 | 0x7f, valp[1] & 0x7f); |
| 1205 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1206 | 0x7f, valp[0] & 0x7f); |
| 1207 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1208 | 0x7f, valp[1] & 0x7f); |
| 1209 | return change; |
| 1210 | } |
| 1211 | |
| 1212 | /* mute internal speaker if HP is plugged */ |
| 1213 | static void ad1981_hp_automute(struct hda_codec *codec) |
| 1214 | { |
| 1215 | unsigned int present; |
| 1216 | |
| 1217 | present = snd_hda_codec_read(codec, 0x06, 0, |
| 1218 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1219 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1220 | 0x80, present ? 0x80 : 0); |
| 1221 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1222 | 0x80, present ? 0x80 : 0); |
| 1223 | } |
| 1224 | |
| 1225 | /* toggle input of built-in and mic jack appropriately */ |
| 1226 | static void ad1981_hp_automic(struct hda_codec *codec) |
| 1227 | { |
| 1228 | static struct hda_verb mic_jack_on[] = { |
| 1229 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1230 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1231 | {} |
| 1232 | }; |
| 1233 | static struct hda_verb mic_jack_off[] = { |
| 1234 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1235 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1236 | {} |
| 1237 | }; |
| 1238 | unsigned int present; |
| 1239 | |
| 1240 | present = snd_hda_codec_read(codec, 0x08, 0, |
| 1241 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1242 | if (present) |
| 1243 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1244 | else |
| 1245 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1246 | } |
| 1247 | |
| 1248 | /* unsolicited event for HP jack sensing */ |
| 1249 | static void ad1981_hp_unsol_event(struct hda_codec *codec, |
| 1250 | unsigned int res) |
| 1251 | { |
| 1252 | res >>= 26; |
| 1253 | switch (res) { |
| 1254 | case AD1981_HP_EVENT: |
| 1255 | ad1981_hp_automute(codec); |
| 1256 | break; |
| 1257 | case AD1981_MIC_EVENT: |
| 1258 | ad1981_hp_automic(codec); |
| 1259 | break; |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | static struct hda_input_mux ad1981_hp_capture_source = { |
| 1264 | .num_items = 3, |
| 1265 | .items = { |
| 1266 | { "Mic", 0x0 }, |
| 1267 | { "Docking-Station", 0x1 }, |
| 1268 | { "Mix", 0x2 }, |
| 1269 | }, |
| 1270 | }; |
| 1271 | |
| 1272 | static struct snd_kcontrol_new ad1981_hp_mixers[] = { |
| 1273 | { |
| 1274 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1275 | .name = "Master Playback Volume", |
| 1276 | .info = snd_hda_mixer_amp_volume_info, |
| 1277 | .get = snd_hda_mixer_amp_volume_get, |
| 1278 | .put = ad1981_hp_master_vol_put, |
| 1279 | .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 1280 | }, |
| 1281 | { |
| 1282 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1283 | .name = "Master Playback Switch", |
| 1284 | .info = ad198x_eapd_info, |
| 1285 | .get = ad198x_eapd_get, |
| 1286 | .put = ad1981_hp_master_sw_put, |
| 1287 | .private_value = 0x05, |
| 1288 | }, |
| 1289 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1290 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1291 | #if 0 |
| 1292 | /* FIXME: analog mic/line loopback doesn't work with my tests... |
| 1293 | * (although recording is OK) |
| 1294 | */ |
| 1295 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1296 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1297 | HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1298 | HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1299 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1300 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1301 | /* FIXME: does this laptop have analog CD connection? */ |
| 1302 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1303 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1304 | #endif |
| 1305 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1306 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1307 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1308 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1309 | { |
| 1310 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1311 | .name = "Capture Source", |
| 1312 | .info = ad198x_mux_enum_info, |
| 1313 | .get = ad198x_mux_enum_get, |
| 1314 | .put = ad198x_mux_enum_put, |
| 1315 | }, |
| 1316 | { } /* end */ |
| 1317 | }; |
| 1318 | |
| 1319 | /* initialize jack-sensing, too */ |
| 1320 | static int ad1981_hp_init(struct hda_codec *codec) |
| 1321 | { |
| 1322 | ad198x_init(codec); |
| 1323 | ad1981_hp_automute(codec); |
| 1324 | ad1981_hp_automic(codec); |
| 1325 | return 0; |
| 1326 | } |
| 1327 | |
| 1328 | /* models */ |
| 1329 | enum { AD1981_BASIC, AD1981_HP }; |
| 1330 | |
| 1331 | static struct hda_board_config ad1981_cfg_tbl[] = { |
| 1332 | { .modelname = "hp", .config = AD1981_HP }, |
Takashi Iwai | 8970ccd | 2006-04-18 12:50:40 +0200 | [diff] [blame^] | 1333 | /* All HP models */ |
| 1334 | { .pci_subvendor = 0x103c, .config = AD1981_HP }, |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1335 | { .modelname = "basic", .config = AD1981_BASIC }, |
| 1336 | {} |
| 1337 | }; |
| 1338 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1339 | static int patch_ad1981(struct hda_codec *codec) |
| 1340 | { |
| 1341 | struct ad198x_spec *spec; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1342 | int board_config; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1343 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1344 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1345 | if (spec == NULL) |
| 1346 | return -ENOMEM; |
| 1347 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 1348 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1349 | codec->spec = spec; |
| 1350 | |
| 1351 | spec->multiout.max_channels = 2; |
| 1352 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
| 1353 | spec->multiout.dac_nids = ad1981_dac_nids; |
| 1354 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1355 | spec->num_adc_nids = 1; |
| 1356 | spec->adc_nids = ad1981_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1357 | spec->capsrc_nids = ad1981_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1358 | spec->input_mux = &ad1981_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1359 | spec->num_mixers = 1; |
| 1360 | spec->mixers[0] = ad1981_mixers; |
| 1361 | spec->num_init_verbs = 1; |
| 1362 | spec->init_verbs[0] = ad1981_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1363 | spec->spdif_route = 0; |
| 1364 | |
| 1365 | codec->patch_ops = ad198x_patch_ops; |
| 1366 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1367 | /* override some parameters */ |
| 1368 | board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl); |
| 1369 | switch (board_config) { |
| 1370 | case AD1981_HP: |
| 1371 | spec->mixers[0] = ad1981_hp_mixers; |
| 1372 | spec->num_init_verbs = 2; |
| 1373 | spec->init_verbs[1] = ad1981_hp_init_verbs; |
| 1374 | spec->multiout.dig_out_nid = 0; |
| 1375 | spec->input_mux = &ad1981_hp_capture_source; |
| 1376 | |
| 1377 | codec->patch_ops.init = ad1981_hp_init; |
| 1378 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1379 | break; |
| 1380 | } |
| 1381 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1382 | return 0; |
| 1383 | } |
| 1384 | |
| 1385 | |
| 1386 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1387 | * AD1988 |
| 1388 | * |
| 1389 | * Output pins and routes |
| 1390 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1391 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1392 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 1393 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 1394 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 1395 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 1396 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 1397 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 1398 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 1399 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 1400 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 1401 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1402 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 1403 | * (*) 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] | 1404 | * |
| 1405 | * Input pins and routes |
| 1406 | * |
| 1407 | * pin boost mix input # / adc input # |
| 1408 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 1409 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 1410 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 1411 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 1412 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 1413 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 1414 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 1415 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 1416 | * |
| 1417 | * |
| 1418 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1419 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1420 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1421 | * |
| 1422 | * Inputs of Analog Mix (0x20) |
| 1423 | * 0:Port-B (front mic) |
| 1424 | * 1:Port-C/G/H (line-in) |
| 1425 | * 2:Port-A |
| 1426 | * 3:Port-D (line-in/2) |
| 1427 | * 4:Port-E/G/H (mic-in) |
| 1428 | * 5:Port-F (mic2-in) |
| 1429 | * 6:CD |
| 1430 | * 7:Beep |
| 1431 | * |
| 1432 | * ADC selection |
| 1433 | * 0:Port-A |
| 1434 | * 1:Port-B (front mic-in) |
| 1435 | * 2:Port-C (line-in) |
| 1436 | * 3:Port-F (mic2-in) |
| 1437 | * 4:Port-E (mic-in) |
| 1438 | * 5:CD |
| 1439 | * 6:Port-G |
| 1440 | * 7:Port-H |
| 1441 | * 8:Port-D (line-in/2) |
| 1442 | * 9:Mix |
| 1443 | * |
| 1444 | * Proposed pin assignments by the datasheet |
| 1445 | * |
| 1446 | * 6-stack |
| 1447 | * Port-A front headphone |
| 1448 | * B front mic-in |
| 1449 | * C rear line-in |
| 1450 | * D rear front-out |
| 1451 | * E rear mic-in |
| 1452 | * F rear surround |
| 1453 | * G rear CLFE |
| 1454 | * H rear side |
| 1455 | * |
| 1456 | * 3-stack |
| 1457 | * Port-A front headphone |
| 1458 | * B front mic |
| 1459 | * C rear line-in/surround |
| 1460 | * D rear front-out |
| 1461 | * E rear mic-in/CLFE |
| 1462 | * |
| 1463 | * laptop |
| 1464 | * Port-A headphone |
| 1465 | * B mic-in |
| 1466 | * C docking station |
| 1467 | * D internal speaker (with EAPD) |
| 1468 | * E/F quad mic array |
| 1469 | */ |
| 1470 | |
| 1471 | |
| 1472 | /* models */ |
| 1473 | enum { |
| 1474 | AD1988_6STACK, |
| 1475 | AD1988_6STACK_DIG, |
| 1476 | AD1988_3STACK, |
| 1477 | AD1988_3STACK_DIG, |
| 1478 | AD1988_LAPTOP, |
| 1479 | AD1988_LAPTOP_DIG, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1480 | AD1988_AUTO, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1481 | AD1988_MODEL_LAST, |
| 1482 | }; |
| 1483 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1484 | /* reivision id to check workarounds */ |
| 1485 | #define AD1988A_REV2 0x100200 |
| 1486 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1487 | |
| 1488 | /* |
| 1489 | * mixers |
| 1490 | */ |
| 1491 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1492 | static hda_nid_t ad1988_6stack_dac_nids[4] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1493 | 0x04, 0x06, 0x05, 0x0a |
| 1494 | }; |
| 1495 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1496 | static hda_nid_t ad1988_3stack_dac_nids[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1497 | 0x04, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1498 | }; |
| 1499 | |
| 1500 | /* for AD1988A revision-2, DAC2-4 are swapped */ |
| 1501 | static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { |
| 1502 | 0x04, 0x05, 0x0a, 0x06 |
| 1503 | }; |
| 1504 | |
| 1505 | static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1506 | 0x04, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1507 | }; |
| 1508 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1509 | static hda_nid_t ad1988_adc_nids[3] = { |
| 1510 | 0x08, 0x09, 0x0f |
| 1511 | }; |
| 1512 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1513 | static hda_nid_t ad1988_capsrc_nids[3] = { |
| 1514 | 0x0c, 0x0d, 0x0e |
| 1515 | }; |
| 1516 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1517 | #define AD1988_SPDIF_OUT 0x02 |
| 1518 | #define AD1988_SPDIF_IN 0x07 |
| 1519 | |
| 1520 | static struct hda_input_mux ad1988_6stack_capture_source = { |
| 1521 | .num_items = 5, |
| 1522 | .items = { |
| 1523 | { "Front Mic", 0x0 }, |
| 1524 | { "Line", 0x1 }, |
| 1525 | { "Mic", 0x4 }, |
| 1526 | { "CD", 0x5 }, |
| 1527 | { "Mix", 0x9 }, |
| 1528 | }, |
| 1529 | }; |
| 1530 | |
| 1531 | static struct hda_input_mux ad1988_laptop_capture_source = { |
| 1532 | .num_items = 3, |
| 1533 | .items = { |
| 1534 | { "Mic/Line", 0x0 }, |
| 1535 | { "CD", 0x5 }, |
| 1536 | { "Mix", 0x9 }, |
| 1537 | }, |
| 1538 | }; |
| 1539 | |
| 1540 | /* |
| 1541 | */ |
| 1542 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 1543 | struct snd_ctl_elem_info *uinfo) |
| 1544 | { |
| 1545 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1546 | struct ad198x_spec *spec = codec->spec; |
| 1547 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 1548 | spec->num_channel_mode); |
| 1549 | } |
| 1550 | |
| 1551 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 1552 | struct snd_ctl_elem_value *ucontrol) |
| 1553 | { |
| 1554 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1555 | struct ad198x_spec *spec = codec->spec; |
| 1556 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 1557 | spec->num_channel_mode, spec->multiout.max_channels); |
| 1558 | } |
| 1559 | |
| 1560 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 1561 | struct snd_ctl_elem_value *ucontrol) |
| 1562 | { |
| 1563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1564 | struct ad198x_spec *spec = codec->spec; |
Takashi Iwai | 2125cad | 2006-03-27 12:52:22 +0200 | [diff] [blame] | 1565 | if (spec->need_dac_fix) |
| 1566 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1567 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 1568 | spec->num_channel_mode, &spec->multiout.max_channels); |
| 1569 | } |
| 1570 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1571 | /* 6-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1572 | static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1573 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1574 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1575 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1576 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 1577 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1578 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1579 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1580 | static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { |
| 1581 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1582 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1583 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 1584 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), |
| 1585 | HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1586 | }; |
| 1587 | |
| 1588 | static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1589 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
| 1590 | HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), |
| 1591 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), |
| 1592 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), |
| 1593 | HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), |
| 1594 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1595 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1596 | |
| 1597 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1598 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1599 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1600 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1601 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1602 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1603 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1604 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1605 | |
| 1606 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1607 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1608 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1609 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1610 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1611 | |
| 1612 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1613 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1614 | |
| 1615 | { } /* end */ |
| 1616 | }; |
| 1617 | |
| 1618 | /* 3-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1619 | static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1620 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1621 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 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), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1624 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1625 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1626 | static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { |
| 1627 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1628 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
| 1629 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), |
| 1630 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1631 | }; |
| 1632 | |
| 1633 | static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1634 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1635 | HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), |
| 1636 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), |
| 1637 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1638 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1639 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1640 | |
| 1641 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1642 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1643 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1644 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1645 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1646 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1647 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1648 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1649 | |
| 1650 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1651 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1652 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1653 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1654 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1655 | |
| 1656 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1657 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1658 | { |
| 1659 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1660 | .name = "Channel Mode", |
| 1661 | .info = ad198x_ch_mode_info, |
| 1662 | .get = ad198x_ch_mode_get, |
| 1663 | .put = ad198x_ch_mode_put, |
| 1664 | }, |
| 1665 | |
| 1666 | { } /* end */ |
| 1667 | }; |
| 1668 | |
| 1669 | /* laptop mode */ |
| 1670 | static struct snd_kcontrol_new ad1988_laptop_mixers[] = { |
| 1671 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1672 | HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), |
| 1673 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1674 | |
| 1675 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1676 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1677 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1678 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1679 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1680 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1681 | |
| 1682 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1683 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1684 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1685 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1686 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1687 | |
| 1688 | HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1689 | |
| 1690 | { |
| 1691 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1692 | .name = "External Amplifier", |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1693 | .info = ad198x_eapd_info, |
| 1694 | .get = ad198x_eapd_get, |
| 1695 | .put = ad198x_eapd_put, |
| 1696 | .private_value = 0x12 | (1 << 8), /* port-D, inversed */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1697 | }, |
| 1698 | |
| 1699 | { } /* end */ |
| 1700 | }; |
| 1701 | |
| 1702 | /* capture */ |
| 1703 | static struct snd_kcontrol_new ad1988_capture_mixers[] = { |
| 1704 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1705 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 1706 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1707 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1708 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1709 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1710 | { |
| 1711 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1712 | /* The multiple "Capture Source" controls confuse alsamixer |
| 1713 | * So call somewhat different.. |
| 1714 | * FIXME: the controls appear in the "playback" view! |
| 1715 | */ |
| 1716 | /* .name = "Capture Source", */ |
| 1717 | .name = "Input Source", |
| 1718 | .count = 3, |
| 1719 | .info = ad198x_mux_enum_info, |
| 1720 | .get = ad198x_mux_enum_get, |
| 1721 | .put = ad198x_mux_enum_put, |
| 1722 | }, |
| 1723 | { } /* end */ |
| 1724 | }; |
| 1725 | |
| 1726 | static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, |
| 1727 | struct snd_ctl_elem_info *uinfo) |
| 1728 | { |
| 1729 | static char *texts[] = { |
| 1730 | "PCM", "ADC1", "ADC2", "ADC3" |
| 1731 | }; |
| 1732 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1733 | uinfo->count = 1; |
| 1734 | uinfo->value.enumerated.items = 4; |
| 1735 | if (uinfo->value.enumerated.item >= 4) |
| 1736 | uinfo->value.enumerated.item = 3; |
| 1737 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1738 | return 0; |
| 1739 | } |
| 1740 | |
| 1741 | static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, |
| 1742 | struct snd_ctl_elem_value *ucontrol) |
| 1743 | { |
| 1744 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1745 | unsigned int sel; |
| 1746 | |
| 1747 | sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1748 | if (sel > 0) { |
| 1749 | sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1750 | if (sel <= 3) |
| 1751 | sel++; |
| 1752 | else |
| 1753 | sel = 0; |
| 1754 | } |
| 1755 | ucontrol->value.enumerated.item[0] = sel; |
| 1756 | return 0; |
| 1757 | } |
| 1758 | |
| 1759 | static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, |
| 1760 | struct snd_ctl_elem_value *ucontrol) |
| 1761 | { |
| 1762 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1763 | unsigned int sel; |
| 1764 | int change; |
| 1765 | |
| 1766 | sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1767 | if (! ucontrol->value.enumerated.item[0]) { |
| 1768 | change = sel != 0; |
| 1769 | if (change) |
| 1770 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); |
| 1771 | } else { |
| 1772 | change = sel == 0; |
| 1773 | if (change) |
| 1774 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); |
| 1775 | sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; |
| 1776 | change |= sel == ucontrol->value.enumerated.item[0]; |
| 1777 | if (change) |
| 1778 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, |
| 1779 | ucontrol->value.enumerated.item[0] - 1); |
| 1780 | } |
| 1781 | return change; |
| 1782 | } |
| 1783 | |
| 1784 | static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { |
| 1785 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1786 | { |
| 1787 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1788 | .name = "IEC958 Playback Source", |
| 1789 | .info = ad1988_spdif_playback_source_info, |
| 1790 | .get = ad1988_spdif_playback_source_get, |
| 1791 | .put = ad1988_spdif_playback_source_put, |
| 1792 | }, |
| 1793 | { } /* end */ |
| 1794 | }; |
| 1795 | |
| 1796 | static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { |
| 1797 | HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), |
| 1798 | { } /* end */ |
| 1799 | }; |
| 1800 | |
| 1801 | |
| 1802 | /* |
| 1803 | * initialization verbs |
| 1804 | */ |
| 1805 | |
| 1806 | /* |
| 1807 | * for 6-stack (+dig) |
| 1808 | */ |
| 1809 | static struct hda_verb ad1988_6stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1810 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1811 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1812 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1813 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1814 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1815 | /* Port-A front headphon path */ |
| 1816 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 1817 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1818 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1819 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1820 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1821 | /* Port-D line-out path */ |
| 1822 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1823 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1824 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1825 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1826 | /* Port-F surround path */ |
| 1827 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1828 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1829 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1830 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1831 | /* Port-G CLFE path */ |
| 1832 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1833 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1834 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1835 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1836 | /* Port-H side path */ |
| 1837 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1838 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1839 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1840 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1841 | /* Mono out path */ |
| 1842 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 1843 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1844 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1845 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1846 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 1847 | /* Port-B front mic-in path */ |
| 1848 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1849 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1850 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1851 | /* Port-C line-in path */ |
| 1852 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1853 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1854 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1855 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1856 | /* Port-E mic-in path */ |
| 1857 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1858 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1859 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1860 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1861 | |
| 1862 | { } |
| 1863 | }; |
| 1864 | |
| 1865 | static struct hda_verb ad1988_capture_init_verbs[] = { |
| 1866 | /* mute analog mix */ |
| 1867 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1868 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1869 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1870 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1871 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 1872 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 1873 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 1874 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 1875 | /* select ADCs - front-mic */ |
| 1876 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1877 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1878 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1879 | /* ADCs; muted */ |
| 1880 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1881 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1882 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1883 | |
| 1884 | { } |
| 1885 | }; |
| 1886 | |
| 1887 | static struct hda_verb ad1988_spdif_init_verbs[] = { |
| 1888 | /* SPDIF out sel */ |
| 1889 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 1890 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ |
| 1891 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1892 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1893 | /* SPDIF out pin */ |
| 1894 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 1895 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */ |
| 1896 | |
| 1897 | { } |
| 1898 | }; |
| 1899 | |
| 1900 | /* |
| 1901 | * verbs for 3stack (+dig) |
| 1902 | */ |
| 1903 | static struct hda_verb ad1988_3stack_ch2_init[] = { |
| 1904 | /* set port-C to line-in */ |
| 1905 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1906 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1907 | /* set port-E to mic-in */ |
| 1908 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1909 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1910 | { } /* end */ |
| 1911 | }; |
| 1912 | |
| 1913 | static struct hda_verb ad1988_3stack_ch6_init[] = { |
| 1914 | /* set port-C to surround out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1915 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1916 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1917 | /* set port-E to CLFE out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1918 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1919 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1920 | { } /* end */ |
| 1921 | }; |
| 1922 | |
| 1923 | static struct hda_channel_mode ad1988_3stack_modes[2] = { |
| 1924 | { 2, ad1988_3stack_ch2_init }, |
| 1925 | { 6, ad1988_3stack_ch6_init }, |
| 1926 | }; |
| 1927 | |
| 1928 | static struct hda_verb ad1988_3stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1929 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1930 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1931 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1932 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1933 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1934 | /* Port-A front headphon path */ |
| 1935 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 1936 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1937 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1938 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1939 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1940 | /* Port-D line-out path */ |
| 1941 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1942 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1943 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1944 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1945 | /* Mono out path */ |
| 1946 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 1947 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1948 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1949 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1950 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 1951 | /* Port-B front mic-in path */ |
| 1952 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1953 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1954 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1955 | /* Port-C line-in/surround path - 6ch mode as default */ |
| 1956 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1957 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1958 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1959 | {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1960 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1961 | /* Port-E mic-in/CLFE path - 6ch mode as default */ |
| 1962 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1963 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1964 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1965 | {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1966 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1967 | /* mute analog mix */ |
| 1968 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1969 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1970 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1971 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1972 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 1973 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 1974 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 1975 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 1976 | /* select ADCs - front-mic */ |
| 1977 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1978 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1979 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1980 | /* ADCs; muted */ |
| 1981 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1982 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1983 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1984 | { } |
| 1985 | }; |
| 1986 | |
| 1987 | /* |
| 1988 | * verbs for laptop mode (+dig) |
| 1989 | */ |
| 1990 | static struct hda_verb ad1988_laptop_hp_on[] = { |
| 1991 | /* unmute port-A and mute port-D */ |
| 1992 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 1993 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1994 | { } /* end */ |
| 1995 | }; |
| 1996 | static struct hda_verb ad1988_laptop_hp_off[] = { |
| 1997 | /* mute port-A and unmute port-D */ |
| 1998 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1999 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 2000 | { } /* end */ |
| 2001 | }; |
| 2002 | |
| 2003 | #define AD1988_HP_EVENT 0x01 |
| 2004 | |
| 2005 | static struct hda_verb ad1988_laptop_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 2006 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 2007 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2008 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2009 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2010 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2011 | /* Port-A front headphon path */ |
| 2012 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2013 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2014 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2015 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2016 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2017 | /* unsolicited event for pin-sense */ |
| 2018 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, |
| 2019 | /* Port-D line-out path + EAPD */ |
| 2020 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2021 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2022 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2023 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2024 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ |
| 2025 | /* Mono out path */ |
| 2026 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2027 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2028 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2029 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2030 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2031 | /* Port-B mic-in path */ |
| 2032 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2033 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2034 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2035 | /* Port-C docking station - try to output */ |
| 2036 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2037 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2038 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2039 | {0x33, 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 - 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 | static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2061 | { |
| 2062 | if ((res >> 26) != AD1988_HP_EVENT) |
| 2063 | return; |
| 2064 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) |
| 2065 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
| 2066 | else |
| 2067 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
| 2068 | } |
| 2069 | |
| 2070 | |
| 2071 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2072 | * Automatic parse of I/O pins from the BIOS configuration |
| 2073 | */ |
| 2074 | |
| 2075 | #define NUM_CONTROL_ALLOC 32 |
| 2076 | #define NUM_VERB_ALLOC 32 |
| 2077 | |
| 2078 | enum { |
| 2079 | AD_CTL_WIDGET_VOL, |
| 2080 | AD_CTL_WIDGET_MUTE, |
| 2081 | AD_CTL_BIND_MUTE, |
| 2082 | }; |
| 2083 | static struct snd_kcontrol_new ad1988_control_templates[] = { |
| 2084 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2085 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
| 2086 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
| 2087 | }; |
| 2088 | |
| 2089 | /* add dynamic controls */ |
| 2090 | static int add_control(struct ad198x_spec *spec, int type, const char *name, |
| 2091 | unsigned long val) |
| 2092 | { |
| 2093 | struct snd_kcontrol_new *knew; |
| 2094 | |
| 2095 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2096 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2097 | |
| 2098 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2099 | if (! knew) |
| 2100 | return -ENOMEM; |
| 2101 | if (spec->kctl_alloc) { |
| 2102 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2103 | kfree(spec->kctl_alloc); |
| 2104 | } |
| 2105 | spec->kctl_alloc = knew; |
| 2106 | spec->num_kctl_alloc = num; |
| 2107 | } |
| 2108 | |
| 2109 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2110 | *knew = ad1988_control_templates[type]; |
| 2111 | knew->name = kstrdup(name, GFP_KERNEL); |
| 2112 | if (! knew->name) |
| 2113 | return -ENOMEM; |
| 2114 | knew->private_value = val; |
| 2115 | spec->num_kctl_used++; |
| 2116 | return 0; |
| 2117 | } |
| 2118 | |
| 2119 | #define AD1988_PIN_CD_NID 0x18 |
| 2120 | #define AD1988_PIN_BEEP_NID 0x10 |
| 2121 | |
| 2122 | static hda_nid_t ad1988_mixer_nids[8] = { |
| 2123 | /* A B C D E F G H */ |
| 2124 | 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 |
| 2125 | }; |
| 2126 | |
| 2127 | static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) |
| 2128 | { |
| 2129 | static hda_nid_t idx_to_dac[8] = { |
| 2130 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2131 | 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2132 | }; |
| 2133 | static hda_nid_t idx_to_dac_rev2[8] = { |
| 2134 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2135 | 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2136 | }; |
| 2137 | if (codec->revision_id == AD1988A_REV2) |
| 2138 | return idx_to_dac_rev2[idx]; |
| 2139 | else |
| 2140 | return idx_to_dac[idx]; |
| 2141 | } |
| 2142 | |
| 2143 | static hda_nid_t ad1988_boost_nids[8] = { |
| 2144 | 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 |
| 2145 | }; |
| 2146 | |
| 2147 | static int ad1988_pin_idx(hda_nid_t nid) |
| 2148 | { |
| 2149 | static hda_nid_t ad1988_io_pins[8] = { |
| 2150 | 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 |
| 2151 | }; |
| 2152 | int i; |
| 2153 | for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) |
| 2154 | if (ad1988_io_pins[i] == nid) |
| 2155 | return i; |
| 2156 | return 0; /* should be -1 */ |
| 2157 | } |
| 2158 | |
| 2159 | static int ad1988_pin_to_loopback_idx(hda_nid_t nid) |
| 2160 | { |
| 2161 | static int loopback_idx[8] = { |
| 2162 | 2, 0, 1, 3, 4, 5, 1, 4 |
| 2163 | }; |
| 2164 | switch (nid) { |
| 2165 | case AD1988_PIN_CD_NID: |
| 2166 | return 6; |
| 2167 | default: |
| 2168 | return loopback_idx[ad1988_pin_idx(nid)]; |
| 2169 | } |
| 2170 | } |
| 2171 | |
| 2172 | static int ad1988_pin_to_adc_idx(hda_nid_t nid) |
| 2173 | { |
| 2174 | static int adc_idx[8] = { |
| 2175 | 0, 1, 2, 8, 4, 3, 6, 7 |
| 2176 | }; |
| 2177 | switch (nid) { |
| 2178 | case AD1988_PIN_CD_NID: |
| 2179 | return 5; |
| 2180 | default: |
| 2181 | return adc_idx[ad1988_pin_idx(nid)]; |
| 2182 | } |
| 2183 | } |
| 2184 | |
| 2185 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2186 | static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, |
| 2187 | const struct auto_pin_cfg *cfg) |
| 2188 | { |
| 2189 | struct ad198x_spec *spec = codec->spec; |
| 2190 | int i, idx; |
| 2191 | |
| 2192 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2193 | |
| 2194 | /* check the pins hardwired to audio widget */ |
| 2195 | for (i = 0; i < cfg->line_outs; i++) { |
| 2196 | idx = ad1988_pin_idx(cfg->line_out_pins[i]); |
| 2197 | spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); |
| 2198 | } |
| 2199 | spec->multiout.num_dacs = cfg->line_outs; |
| 2200 | return 0; |
| 2201 | } |
| 2202 | |
| 2203 | /* add playback controls from the parsed DAC table */ |
| 2204 | static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, |
| 2205 | const struct auto_pin_cfg *cfg) |
| 2206 | { |
| 2207 | char name[32]; |
| 2208 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2209 | hda_nid_t nid; |
| 2210 | int i, err; |
| 2211 | |
| 2212 | for (i = 0; i < cfg->line_outs; i++) { |
| 2213 | hda_nid_t dac = spec->multiout.dac_nids[i]; |
| 2214 | if (! dac) |
| 2215 | continue; |
| 2216 | nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; |
| 2217 | if (i == 2) { |
| 2218 | /* Center/LFE */ |
| 2219 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2220 | "Center Playback Volume", |
| 2221 | HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); |
| 2222 | if (err < 0) |
| 2223 | return err; |
| 2224 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2225 | "LFE Playback Volume", |
| 2226 | HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); |
| 2227 | if (err < 0) |
| 2228 | return err; |
| 2229 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2230 | "Center Playback Switch", |
| 2231 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); |
| 2232 | if (err < 0) |
| 2233 | return err; |
| 2234 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2235 | "LFE Playback Switch", |
| 2236 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); |
| 2237 | if (err < 0) |
| 2238 | return err; |
| 2239 | } else { |
| 2240 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2241 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2242 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); |
| 2243 | if (err < 0) |
| 2244 | return err; |
| 2245 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2246 | err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2247 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
| 2248 | if (err < 0) |
| 2249 | return err; |
| 2250 | } |
| 2251 | } |
| 2252 | return 0; |
| 2253 | } |
| 2254 | |
| 2255 | /* add playback controls for speaker and HP outputs */ |
| 2256 | static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
| 2257 | const char *pfx) |
| 2258 | { |
| 2259 | struct ad198x_spec *spec = codec->spec; |
| 2260 | hda_nid_t nid; |
| 2261 | int idx, err; |
| 2262 | char name[32]; |
| 2263 | |
| 2264 | if (! pin) |
| 2265 | return 0; |
| 2266 | |
| 2267 | idx = ad1988_pin_idx(pin); |
| 2268 | nid = ad1988_idx_to_dac(codec, idx); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2269 | /* specify the DAC as the extra output */ |
| 2270 | if (! spec->multiout.hp_nid) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2271 | spec->multiout.hp_nid = nid; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2272 | else |
| 2273 | spec->multiout.extra_out_nid[0] = nid; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2274 | /* control HP volume/switch on the output mixer amp */ |
| 2275 | sprintf(name, "%s Playback Volume", pfx); |
| 2276 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2277 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2278 | return err; |
| 2279 | nid = ad1988_mixer_nids[idx]; |
| 2280 | sprintf(name, "%s Playback Switch", pfx); |
| 2281 | if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2282 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2283 | return err; |
| 2284 | return 0; |
| 2285 | } |
| 2286 | |
| 2287 | /* create input playback/capture controls for the given pin */ |
| 2288 | static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, |
| 2289 | const char *ctlname, int boost) |
| 2290 | { |
| 2291 | char name[32]; |
| 2292 | int err, idx; |
| 2293 | |
| 2294 | sprintf(name, "%s Playback Volume", ctlname); |
| 2295 | idx = ad1988_pin_to_loopback_idx(pin); |
| 2296 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2297 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2298 | return err; |
| 2299 | sprintf(name, "%s Playback Switch", ctlname); |
| 2300 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, |
| 2301 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2302 | return err; |
| 2303 | if (boost) { |
| 2304 | hda_nid_t bnid; |
| 2305 | idx = ad1988_pin_idx(pin); |
| 2306 | bnid = ad1988_boost_nids[idx]; |
| 2307 | if (bnid) { |
| 2308 | sprintf(name, "%s Boost", ctlname); |
| 2309 | return add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2310 | HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); |
| 2311 | |
| 2312 | } |
| 2313 | } |
| 2314 | return 0; |
| 2315 | } |
| 2316 | |
| 2317 | /* create playback/capture controls for input pins */ |
| 2318 | static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, |
| 2319 | const struct auto_pin_cfg *cfg) |
| 2320 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2321 | struct hda_input_mux *imux = &spec->private_imux; |
| 2322 | int i, err; |
| 2323 | |
| 2324 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2325 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2326 | auto_pin_cfg_labels[i], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2327 | i <= AUTO_PIN_FRONT_MIC); |
| 2328 | if (err < 0) |
| 2329 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2330 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2331 | imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); |
| 2332 | imux->num_items++; |
| 2333 | } |
| 2334 | imux->items[imux->num_items].label = "Mix"; |
| 2335 | imux->items[imux->num_items].index = 9; |
| 2336 | imux->num_items++; |
| 2337 | |
| 2338 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2339 | "Analog Mix Playback Volume", |
| 2340 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2341 | return err; |
| 2342 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, |
| 2343 | "Analog Mix Playback Switch", |
| 2344 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2345 | return err; |
| 2346 | |
| 2347 | return 0; |
| 2348 | } |
| 2349 | |
| 2350 | static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2351 | hda_nid_t nid, int pin_type, |
| 2352 | int dac_idx) |
| 2353 | { |
| 2354 | /* set as output */ |
| 2355 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2356 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2357 | switch (nid) { |
| 2358 | case 0x11: /* port-A - DAC 04 */ |
| 2359 | snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2360 | break; |
| 2361 | case 0x14: /* port-B - DAC 06 */ |
| 2362 | snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); |
| 2363 | break; |
| 2364 | case 0x15: /* port-C - DAC 05 */ |
| 2365 | snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); |
| 2366 | break; |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2367 | case 0x17: /* port-E - DAC 0a */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2368 | snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2369 | break; |
| 2370 | case 0x13: /* mono - DAC 04 */ |
| 2371 | snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2372 | break; |
| 2373 | } |
| 2374 | } |
| 2375 | |
| 2376 | static void ad1988_auto_init_multi_out(struct hda_codec *codec) |
| 2377 | { |
| 2378 | struct ad198x_spec *spec = codec->spec; |
| 2379 | int i; |
| 2380 | |
| 2381 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2382 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2383 | ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2384 | } |
| 2385 | } |
| 2386 | |
| 2387 | static void ad1988_auto_init_extra_out(struct hda_codec *codec) |
| 2388 | { |
| 2389 | struct ad198x_spec *spec = codec->spec; |
| 2390 | hda_nid_t pin; |
| 2391 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2392 | pin = spec->autocfg.speaker_pins[0]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2393 | if (pin) /* connect to front */ |
| 2394 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
| 2395 | pin = spec->autocfg.hp_pin; |
| 2396 | if (pin) /* connect to front */ |
| 2397 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2398 | } |
| 2399 | |
| 2400 | static void ad1988_auto_init_analog_input(struct hda_codec *codec) |
| 2401 | { |
| 2402 | struct ad198x_spec *spec = codec->spec; |
| 2403 | int i, idx; |
| 2404 | |
| 2405 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2406 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2407 | if (! nid) |
| 2408 | continue; |
| 2409 | switch (nid) { |
| 2410 | case 0x15: /* port-C */ |
| 2411 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2412 | break; |
| 2413 | case 0x17: /* port-E */ |
| 2414 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2415 | break; |
| 2416 | } |
| 2417 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2418 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2419 | if (nid != AD1988_PIN_CD_NID) |
| 2420 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2421 | AMP_OUT_MUTE); |
| 2422 | idx = ad1988_pin_idx(nid); |
| 2423 | if (ad1988_boost_nids[idx]) |
| 2424 | snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, |
| 2425 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2426 | AMP_OUT_ZERO); |
| 2427 | } |
| 2428 | } |
| 2429 | |
| 2430 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2431 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2432 | static int ad1988_parse_auto_config(struct hda_codec *codec) |
| 2433 | { |
| 2434 | struct ad198x_spec *spec = codec->spec; |
| 2435 | int err; |
| 2436 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2437 | 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] | 2438 | return err; |
| 2439 | if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 2440 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2441 | if (! spec->autocfg.line_outs) |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2442 | return 0; /* can't find valid BIOS pin config */ |
| 2443 | if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2444 | (err = ad1988_auto_create_extra_out(codec, |
| 2445 | spec->autocfg.speaker_pins[0], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2446 | "Speaker")) < 0 || |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2447 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pin, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2448 | "Headphone")) < 0 || |
| 2449 | (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2450 | return err; |
| 2451 | |
| 2452 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2453 | |
| 2454 | if (spec->autocfg.dig_out_pin) |
| 2455 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2456 | if (spec->autocfg.dig_in_pin) |
| 2457 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2458 | |
| 2459 | if (spec->kctl_alloc) |
| 2460 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2461 | |
| 2462 | spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; |
| 2463 | |
| 2464 | spec->input_mux = &spec->private_imux; |
| 2465 | |
| 2466 | return 1; |
| 2467 | } |
| 2468 | |
| 2469 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2470 | static int ad1988_auto_init(struct hda_codec *codec) |
| 2471 | { |
| 2472 | ad198x_init(codec); |
| 2473 | ad1988_auto_init_multi_out(codec); |
| 2474 | ad1988_auto_init_extra_out(codec); |
| 2475 | ad1988_auto_init_analog_input(codec); |
| 2476 | return 0; |
| 2477 | } |
| 2478 | |
| 2479 | |
| 2480 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2481 | */ |
| 2482 | |
| 2483 | static struct hda_board_config ad1988_cfg_tbl[] = { |
| 2484 | { .modelname = "6stack", .config = AD1988_6STACK }, |
| 2485 | { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG }, |
| 2486 | { .modelname = "3stack", .config = AD1988_3STACK }, |
| 2487 | { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, |
| 2488 | { .modelname = "laptop", .config = AD1988_LAPTOP }, |
| 2489 | { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2490 | { .modelname = "auto", .config = AD1988_AUTO }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2491 | {} |
| 2492 | }; |
| 2493 | |
| 2494 | static int patch_ad1988(struct hda_codec *codec) |
| 2495 | { |
| 2496 | struct ad198x_spec *spec; |
| 2497 | int board_config; |
| 2498 | |
| 2499 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2500 | if (spec == NULL) |
| 2501 | return -ENOMEM; |
| 2502 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 2503 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2504 | codec->spec = spec; |
| 2505 | |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2506 | if (codec->revision_id == AD1988A_REV2) |
| 2507 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
| 2508 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2509 | board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); |
| 2510 | if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2511 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); |
| 2512 | board_config = AD1988_AUTO; |
| 2513 | } |
| 2514 | |
| 2515 | if (board_config == AD1988_AUTO) { |
| 2516 | /* automatic parse from the BIOS config */ |
| 2517 | int err = ad1988_parse_auto_config(codec); |
| 2518 | if (err < 0) { |
| 2519 | ad198x_free(codec); |
| 2520 | return err; |
| 2521 | } else if (! err) { |
| 2522 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); |
| 2523 | board_config = AD1988_6STACK; |
| 2524 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2525 | } |
| 2526 | |
| 2527 | switch (board_config) { |
| 2528 | case AD1988_6STACK: |
| 2529 | case AD1988_6STACK_DIG: |
| 2530 | spec->multiout.max_channels = 8; |
| 2531 | spec->multiout.num_dacs = 4; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2532 | if (codec->revision_id == AD1988A_REV2) |
| 2533 | spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; |
| 2534 | else |
| 2535 | spec->multiout.dac_nids = ad1988_6stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2536 | spec->input_mux = &ad1988_6stack_capture_source; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2537 | spec->num_mixers = 2; |
| 2538 | if (codec->revision_id == AD1988A_REV2) |
| 2539 | spec->mixers[0] = ad1988_6stack_mixers1_rev2; |
| 2540 | else |
| 2541 | spec->mixers[0] = ad1988_6stack_mixers1; |
| 2542 | spec->mixers[1] = ad1988_6stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2543 | spec->num_init_verbs = 1; |
| 2544 | spec->init_verbs[0] = ad1988_6stack_init_verbs; |
| 2545 | if (board_config == AD1988_6STACK_DIG) { |
| 2546 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2547 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2548 | } |
| 2549 | break; |
| 2550 | case AD1988_3STACK: |
| 2551 | case AD1988_3STACK_DIG: |
| 2552 | spec->multiout.max_channels = 6; |
| 2553 | spec->multiout.num_dacs = 3; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2554 | if (codec->revision_id == AD1988A_REV2) |
| 2555 | spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; |
| 2556 | else |
| 2557 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2558 | spec->input_mux = &ad1988_6stack_capture_source; |
| 2559 | spec->channel_mode = ad1988_3stack_modes; |
| 2560 | spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2561 | spec->num_mixers = 2; |
| 2562 | if (codec->revision_id == AD1988A_REV2) |
| 2563 | spec->mixers[0] = ad1988_3stack_mixers1_rev2; |
| 2564 | else |
| 2565 | spec->mixers[0] = ad1988_3stack_mixers1; |
| 2566 | spec->mixers[1] = ad1988_3stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2567 | spec->num_init_verbs = 1; |
| 2568 | spec->init_verbs[0] = ad1988_3stack_init_verbs; |
| 2569 | if (board_config == AD1988_3STACK_DIG) |
| 2570 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2571 | break; |
| 2572 | case AD1988_LAPTOP: |
| 2573 | case AD1988_LAPTOP_DIG: |
| 2574 | spec->multiout.max_channels = 2; |
| 2575 | spec->multiout.num_dacs = 1; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2576 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2577 | spec->input_mux = &ad1988_laptop_capture_source; |
| 2578 | spec->num_mixers = 1; |
| 2579 | spec->mixers[0] = ad1988_laptop_mixers; |
| 2580 | spec->num_init_verbs = 1; |
| 2581 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
| 2582 | if (board_config == AD1988_LAPTOP_DIG) |
| 2583 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2584 | break; |
| 2585 | } |
| 2586 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2587 | spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); |
| 2588 | spec->adc_nids = ad1988_adc_nids; |
| 2589 | spec->capsrc_nids = ad1988_capsrc_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2590 | spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; |
| 2591 | spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; |
| 2592 | if (spec->multiout.dig_out_nid) { |
| 2593 | spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; |
| 2594 | spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; |
| 2595 | } |
| 2596 | if (spec->dig_in_nid) |
| 2597 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
| 2598 | |
| 2599 | codec->patch_ops = ad198x_patch_ops; |
| 2600 | switch (board_config) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2601 | case AD1988_AUTO: |
| 2602 | codec->patch_ops.init = ad1988_auto_init; |
| 2603 | break; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2604 | case AD1988_LAPTOP: |
| 2605 | case AD1988_LAPTOP_DIG: |
| 2606 | codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; |
| 2607 | break; |
| 2608 | } |
| 2609 | |
| 2610 | return 0; |
| 2611 | } |
| 2612 | |
| 2613 | |
| 2614 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | * patch entries |
| 2616 | */ |
| 2617 | struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 2618 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 2619 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2621 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | {} /* terminator */ |
| 2623 | }; |