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