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 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame^] | 584 | /* laptop-eapd model - 2ch only */ |
| 585 | |
| 586 | /* master controls both pins 0x1a and 0x1b */ |
| 587 | static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol, |
| 588 | struct snd_ctl_elem_value *ucontrol) |
| 589 | { |
| 590 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 591 | long *valp = ucontrol->value.integer.value; |
| 592 | int change; |
| 593 | |
| 594 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 595 | 0x7f, valp[0] & 0x7f); |
| 596 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 597 | 0x7f, valp[1] & 0x7f); |
| 598 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
| 599 | 0x7f, valp[0] & 0x7f); |
| 600 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
| 601 | 0x7f, valp[1] & 0x7f); |
| 602 | return change; |
| 603 | } |
| 604 | |
| 605 | static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol, |
| 606 | struct snd_ctl_elem_value *ucontrol) |
| 607 | { |
| 608 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 609 | long *valp = ucontrol->value.integer.value; |
| 610 | int change; |
| 611 | |
| 612 | change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, |
| 613 | 0x80, valp[0] ? 0 : 0x80); |
| 614 | change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, |
| 615 | 0x80, valp[1] ? 0 : 0x80); |
| 616 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
| 617 | 0x80, valp[0] ? 0 : 0x80); |
| 618 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
| 619 | 0x80, valp[1] ? 0 : 0x80); |
| 620 | return change; |
| 621 | } |
| 622 | |
| 623 | static struct hda_input_mux ad1986a_laptop_eapd_capture_source = { |
| 624 | .num_items = 3, |
| 625 | .items = { |
| 626 | { "Mic", 0x0 }, |
| 627 | { "Internal Mic", 0x4 }, |
| 628 | { "Mix", 0x5 }, |
| 629 | }, |
| 630 | }; |
| 631 | |
| 632 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
| 633 | { |
| 634 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 635 | .name = "Master Playback Volume", |
| 636 | .info = snd_hda_mixer_amp_volume_info, |
| 637 | .get = snd_hda_mixer_amp_volume_get, |
| 638 | .put = ad1986a_laptop_master_vol_put, |
| 639 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 640 | }, |
| 641 | { |
| 642 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 643 | .name = "Master Playback Switch", |
| 644 | .info = snd_hda_mixer_amp_switch_info, |
| 645 | .get = snd_hda_mixer_amp_switch_get, |
| 646 | .put = ad1986a_laptop_master_sw_put, |
| 647 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
| 648 | }, |
| 649 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
| 650 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
| 651 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), |
| 652 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), |
| 653 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 654 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 655 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 656 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), |
| 657 | { |
| 658 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 659 | .name = "Capture Source", |
| 660 | .info = ad198x_mux_enum_info, |
| 661 | .get = ad198x_mux_enum_get, |
| 662 | .put = ad198x_mux_enum_put, |
| 663 | }, |
| 664 | { |
| 665 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 666 | .name = "External Amplifier", |
| 667 | .info = ad198x_eapd_info, |
| 668 | .get = ad198x_eapd_get, |
| 669 | .put = ad198x_eapd_put, |
| 670 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ |
| 671 | }, |
| 672 | { } /* end */ |
| 673 | }; |
| 674 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | /* |
| 676 | * initialization verbs |
| 677 | */ |
| 678 | static struct hda_verb ad1986a_init_verbs[] = { |
| 679 | /* Front, Surround, CLFE DAC; mute as default */ |
| 680 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 681 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 682 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 683 | /* Downmix - off */ |
| 684 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 685 | /* HP, Line-Out, Surround, CLFE selectors */ |
| 686 | {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 687 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 688 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 689 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 690 | /* Mono selector */ |
| 691 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 692 | /* Mic selector: Mic 1/2 pin */ |
| 693 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 694 | /* Line-in selector: Line-in */ |
| 695 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 696 | /* Mic 1/2 swap */ |
| 697 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 698 | /* Record selector: mic */ |
| 699 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 700 | /* Mic, Phone, CD, Aux, Line-In amp; mute as default */ |
| 701 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 702 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 703 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 704 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 705 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 706 | /* PC beep */ |
| 707 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 708 | /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */ |
| 709 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 710 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 711 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 712 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 713 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 714 | /* HP Pin */ |
| 715 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 716 | /* Front, Surround, CLFE Pins */ |
| 717 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 718 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 719 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 720 | /* Mono Pin */ |
| 721 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 722 | /* Mic Pin */ |
| 723 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 724 | /* Line, Aux, CD, Beep-In Pin */ |
| 725 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 726 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 727 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 728 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 729 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | { } /* end */ |
| 731 | }; |
| 732 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 733 | /* additional verbs for 3-stack model */ |
| 734 | static struct hda_verb ad1986a_3st_init_verbs[] = { |
| 735 | /* Mic and line-in selectors */ |
| 736 | {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
| 737 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 738 | { } /* end */ |
| 739 | }; |
| 740 | |
| 741 | static struct hda_verb ad1986a_ch2_init[] = { |
| 742 | /* Surround out -> Line In */ |
| 743 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 744 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 745 | /* CLFE -> Mic in */ |
| 746 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 747 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 748 | { } /* end */ |
| 749 | }; |
| 750 | |
| 751 | static struct hda_verb ad1986a_ch4_init[] = { |
| 752 | /* Surround out -> Surround */ |
| 753 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 754 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 755 | /* CLFE -> Mic in */ |
| 756 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 757 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 758 | { } /* end */ |
| 759 | }; |
| 760 | |
| 761 | static struct hda_verb ad1986a_ch6_init[] = { |
| 762 | /* Surround out -> Surround out */ |
| 763 | { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 764 | { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 765 | /* CLFE -> CLFE */ |
| 766 | { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 767 | { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 768 | { } /* end */ |
| 769 | }; |
| 770 | |
| 771 | static struct hda_channel_mode ad1986a_modes[3] = { |
| 772 | { 2, ad1986a_ch2_init }, |
| 773 | { 4, ad1986a_ch4_init }, |
| 774 | { 6, ad1986a_ch6_init }, |
| 775 | }; |
| 776 | |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame^] | 777 | /* eapd initialization */ |
| 778 | static struct hda_verb ad1986a_eapd_init_verbs[] = { |
| 779 | {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, |
| 780 | {} |
| 781 | }; |
| 782 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 783 | /* models */ |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame^] | 784 | enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD }; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 785 | |
| 786 | static struct hda_board_config ad1986a_cfg_tbl[] = { |
| 787 | { .modelname = "6stack", .config = AD1986A_6STACK }, |
| 788 | { .modelname = "3stack", .config = AD1986A_3STACK }, |
| 789 | { .modelname = "laptop", .config = AD1986A_LAPTOP }, |
| 790 | { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e, |
| 791 | .config = AD1986A_LAPTOP }, /* FSC V2060 */ |
| 792 | { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017, |
| 793 | .config = AD1986A_LAPTOP }, /* Samsung M50 */ |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame^] | 794 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f, |
| 795 | .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */ |
| 796 | { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD }, |
| 797 | { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024, |
| 798 | .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */ |
| 799 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213, |
| 800 | .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */ |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 801 | {} |
| 802 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | static int patch_ad1986a(struct hda_codec *codec) |
| 805 | { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 806 | struct ad198x_spec *spec; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 807 | int board_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 809 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | if (spec == NULL) |
| 811 | return -ENOMEM; |
| 812 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 813 | mutex_init(&spec->amp_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | codec->spec = spec; |
| 815 | |
| 816 | spec->multiout.max_channels = 6; |
| 817 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); |
| 818 | spec->multiout.dac_nids = ad1986a_dac_nids; |
| 819 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 820 | spec->num_adc_nids = 1; |
| 821 | spec->adc_nids = ad1986a_adc_nids; |
Takashi Iwai | a7ee820 | 2006-03-01 20:05:39 +0100 | [diff] [blame] | 822 | spec->capsrc_nids = ad1986a_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 823 | spec->input_mux = &ad1986a_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 824 | spec->num_mixers = 1; |
| 825 | spec->mixers[0] = ad1986a_mixers; |
| 826 | spec->num_init_verbs = 1; |
| 827 | spec->init_verbs[0] = ad1986a_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 829 | codec->patch_ops = ad198x_patch_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 831 | /* override some parameters */ |
| 832 | board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl); |
| 833 | switch (board_config) { |
| 834 | case AD1986A_3STACK: |
| 835 | spec->num_mixers = 2; |
| 836 | spec->mixers[1] = ad1986a_3st_mixers; |
| 837 | spec->num_init_verbs = 2; |
| 838 | spec->init_verbs[1] = ad1986a_3st_init_verbs; |
| 839 | spec->channel_mode = ad1986a_modes; |
| 840 | spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); |
| 841 | break; |
| 842 | case AD1986A_LAPTOP: |
| 843 | spec->mixers[0] = ad1986a_laptop_mixers; |
| 844 | spec->multiout.max_channels = 2; |
| 845 | spec->multiout.num_dacs = 1; |
| 846 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 847 | break; |
Takashi Iwai | 825aa97 | 2006-03-17 10:50:49 +0100 | [diff] [blame^] | 848 | case AD1986A_LAPTOP_EAPD: |
| 849 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
| 850 | spec->num_init_verbs = 2; |
| 851 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
| 852 | spec->multiout.max_channels = 2; |
| 853 | spec->multiout.num_dacs = 1; |
| 854 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
| 855 | spec->multiout.dig_out_nid = 0; |
| 856 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
| 857 | break; |
Takashi Iwai | 9230d21 | 2006-03-13 13:49:49 +0100 | [diff] [blame] | 858 | } |
| 859 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | /* |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 864 | * AD1983 specific |
| 865 | */ |
| 866 | |
| 867 | #define AD1983_SPDIF_OUT 0x02 |
| 868 | #define AD1983_DAC 0x03 |
| 869 | #define AD1983_ADC 0x04 |
| 870 | |
| 871 | static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 872 | static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 873 | static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 874 | |
| 875 | static struct hda_input_mux ad1983_capture_source = { |
| 876 | .num_items = 4, |
| 877 | .items = { |
| 878 | { "Mic", 0x0 }, |
| 879 | { "Line", 0x1 }, |
| 880 | { "Mix", 0x2 }, |
| 881 | { "Mix Mono", 0x3 }, |
| 882 | }, |
| 883 | }; |
| 884 | |
| 885 | /* |
| 886 | * SPDIF playback route |
| 887 | */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 888 | 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] | 889 | { |
| 890 | static char *texts[] = { "PCM", "ADC" }; |
| 891 | |
| 892 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 893 | uinfo->count = 1; |
| 894 | uinfo->value.enumerated.items = 2; |
| 895 | if (uinfo->value.enumerated.item > 1) |
| 896 | uinfo->value.enumerated.item = 1; |
| 897 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 898 | return 0; |
| 899 | } |
| 900 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 901 | 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] | 902 | { |
| 903 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 904 | struct ad198x_spec *spec = codec->spec; |
| 905 | |
| 906 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
| 907 | return 0; |
| 908 | } |
| 909 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 910 | 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] | 911 | { |
| 912 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 913 | struct ad198x_spec *spec = codec->spec; |
| 914 | |
| 915 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { |
| 916 | spec->spdif_route = ucontrol->value.enumerated.item[0]; |
| 917 | snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, |
| 918 | AC_VERB_SET_CONNECT_SEL, spec->spdif_route); |
| 919 | return 1; |
| 920 | } |
| 921 | return 0; |
| 922 | } |
| 923 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 924 | static struct snd_kcontrol_new ad1983_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 925 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 926 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 927 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 928 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 929 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 930 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 931 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 932 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 933 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 934 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 935 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 936 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 937 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT), |
| 938 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT), |
| 939 | HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), |
| 940 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 941 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 942 | { |
| 943 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 944 | .name = "Capture Source", |
| 945 | .info = ad198x_mux_enum_info, |
| 946 | .get = ad198x_mux_enum_get, |
| 947 | .put = ad198x_mux_enum_put, |
| 948 | }, |
| 949 | { |
| 950 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Clemens Ladisch | 10e8d78 | 2005-08-03 13:40:08 +0200 | [diff] [blame] | 951 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 952 | .info = ad1983_spdif_route_info, |
| 953 | .get = ad1983_spdif_route_get, |
| 954 | .put = ad1983_spdif_route_put, |
| 955 | }, |
| 956 | { } /* end */ |
| 957 | }; |
| 958 | |
| 959 | static struct hda_verb ad1983_init_verbs[] = { |
| 960 | /* Front, HP, Mono; mute as default */ |
| 961 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 962 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 963 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 964 | /* Beep, PCM, Mic, Line-In: mute */ |
| 965 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 966 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 967 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 968 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 969 | /* Front, HP selectors; from Mix */ |
| 970 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 971 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 972 | /* Mono selector; from Mix */ |
| 973 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 974 | /* Mic selector; Mic */ |
| 975 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 976 | /* Line-in selector: Line-in */ |
| 977 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 978 | /* Mic boost: 0dB */ |
| 979 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 980 | /* Record selector: mic */ |
| 981 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 982 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 983 | /* SPDIF route: PCM */ |
| 984 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 985 | /* Front Pin */ |
| 986 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 987 | /* HP Pin */ |
| 988 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 989 | /* Mono Pin */ |
| 990 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 991 | /* Mic Pin */ |
| 992 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 993 | /* Line Pin */ |
| 994 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 995 | { } /* end */ |
| 996 | }; |
| 997 | |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 998 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 999 | static int patch_ad1983(struct hda_codec *codec) |
| 1000 | { |
| 1001 | struct ad198x_spec *spec; |
| 1002 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1003 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1004 | if (spec == NULL) |
| 1005 | return -ENOMEM; |
| 1006 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 1007 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1008 | codec->spec = spec; |
| 1009 | |
| 1010 | spec->multiout.max_channels = 2; |
| 1011 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); |
| 1012 | spec->multiout.dac_nids = ad1983_dac_nids; |
| 1013 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1014 | spec->num_adc_nids = 1; |
| 1015 | spec->adc_nids = ad1983_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1016 | spec->capsrc_nids = ad1983_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1017 | spec->input_mux = &ad1983_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1018 | spec->num_mixers = 1; |
| 1019 | spec->mixers[0] = ad1983_mixers; |
| 1020 | spec->num_init_verbs = 1; |
| 1021 | spec->init_verbs[0] = ad1983_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1022 | spec->spdif_route = 0; |
| 1023 | |
| 1024 | codec->patch_ops = ad198x_patch_ops; |
| 1025 | |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
| 1029 | |
| 1030 | /* |
| 1031 | * AD1981 HD specific |
| 1032 | */ |
| 1033 | |
| 1034 | #define AD1981_SPDIF_OUT 0x02 |
| 1035 | #define AD1981_DAC 0x03 |
| 1036 | #define AD1981_ADC 0x04 |
| 1037 | |
| 1038 | static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1039 | static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1040 | static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 }; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1041 | |
| 1042 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
| 1043 | static struct hda_input_mux ad1981_capture_source = { |
| 1044 | .num_items = 7, |
| 1045 | .items = { |
| 1046 | { "Front Mic", 0x0 }, |
| 1047 | { "Line", 0x1 }, |
| 1048 | { "Mix", 0x2 }, |
| 1049 | { "Mix Mono", 0x3 }, |
| 1050 | { "CD", 0x4 }, |
| 1051 | { "Mic", 0x6 }, |
| 1052 | { "Aux", 0x7 }, |
| 1053 | }, |
| 1054 | }; |
| 1055 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1056 | static struct snd_kcontrol_new ad1981_mixers[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1057 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1058 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
| 1059 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1060 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
| 1061 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1062 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
| 1063 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1064 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1065 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1066 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1067 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1068 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1069 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1070 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 1071 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1072 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1073 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1074 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1075 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1076 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), |
| 1077 | HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1078 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1079 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1080 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1081 | { |
| 1082 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1083 | .name = "Capture Source", |
| 1084 | .info = ad198x_mux_enum_info, |
| 1085 | .get = ad198x_mux_enum_get, |
| 1086 | .put = ad198x_mux_enum_put, |
| 1087 | }, |
| 1088 | /* identical with AD1983 */ |
| 1089 | { |
| 1090 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Clemens Ladisch | 10e8d78 | 2005-08-03 13:40:08 +0200 | [diff] [blame] | 1091 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1092 | .info = ad1983_spdif_route_info, |
| 1093 | .get = ad1983_spdif_route_get, |
| 1094 | .put = ad1983_spdif_route_put, |
| 1095 | }, |
| 1096 | { } /* end */ |
| 1097 | }; |
| 1098 | |
| 1099 | static struct hda_verb ad1981_init_verbs[] = { |
| 1100 | /* Front, HP, Mono; mute as default */ |
| 1101 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1102 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1103 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1104 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ |
| 1105 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1106 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1107 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1108 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1109 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1110 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1111 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1112 | /* Front, HP selectors; from Mix */ |
| 1113 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1114 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1115 | /* Mono selector; from Mix */ |
| 1116 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1117 | /* Mic Mixer; select Front Mic */ |
| 1118 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1119 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1120 | /* Mic boost: 0dB */ |
| 1121 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1122 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1123 | /* Record selector: Front mic */ |
| 1124 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1125 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1126 | /* SPDIF route: PCM */ |
| 1127 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1128 | /* Front Pin */ |
| 1129 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1130 | /* HP Pin */ |
| 1131 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, |
| 1132 | /* Mono Pin */ |
| 1133 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, |
| 1134 | /* Front & Rear Mic Pins */ |
| 1135 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1136 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
| 1137 | /* Line Pin */ |
| 1138 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, |
| 1139 | /* Digital Beep */ |
| 1140 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1141 | /* Line-Out as Input: disabled */ |
| 1142 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1143 | { } /* end */ |
| 1144 | }; |
| 1145 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1146 | /* |
| 1147 | * Patch for HP nx6320 |
| 1148 | * |
| 1149 | * nx6320 uses EAPD in the reserve way - EAPD-on means the internal |
| 1150 | * speaker output enabled _and_ mute-LED off. |
| 1151 | */ |
| 1152 | |
| 1153 | #define AD1981_HP_EVENT 0x37 |
| 1154 | #define AD1981_MIC_EVENT 0x38 |
| 1155 | |
| 1156 | static struct hda_verb ad1981_hp_init_verbs[] = { |
| 1157 | {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */ |
| 1158 | /* pin sensing on HP and Mic jacks */ |
| 1159 | {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT}, |
| 1160 | {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT}, |
| 1161 | {} |
| 1162 | }; |
| 1163 | |
| 1164 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1165 | static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1166 | struct snd_ctl_elem_value *ucontrol) |
| 1167 | { |
| 1168 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1169 | struct ad198x_spec *spec = codec->spec; |
| 1170 | |
| 1171 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
| 1172 | return 0; |
| 1173 | |
| 1174 | /* toggle HP mute appropriately */ |
| 1175 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1176 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1177 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1178 | 0x80, spec->cur_eapd ? 0 : 0x80); |
| 1179 | return 1; |
| 1180 | } |
| 1181 | |
| 1182 | /* bind volumes of both NID 0x05 and 0x06 */ |
| 1183 | static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, |
| 1184 | struct snd_ctl_elem_value *ucontrol) |
| 1185 | { |
| 1186 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1187 | long *valp = ucontrol->value.integer.value; |
| 1188 | int change; |
| 1189 | |
| 1190 | change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1191 | 0x7f, valp[0] & 0x7f); |
| 1192 | change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1193 | 0x7f, valp[1] & 0x7f); |
| 1194 | snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0, |
| 1195 | 0x7f, valp[0] & 0x7f); |
| 1196 | snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0, |
| 1197 | 0x7f, valp[1] & 0x7f); |
| 1198 | return change; |
| 1199 | } |
| 1200 | |
| 1201 | /* mute internal speaker if HP is plugged */ |
| 1202 | static void ad1981_hp_automute(struct hda_codec *codec) |
| 1203 | { |
| 1204 | unsigned int present; |
| 1205 | |
| 1206 | present = snd_hda_codec_read(codec, 0x06, 0, |
| 1207 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1208 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1209 | 0x80, present ? 0x80 : 0); |
| 1210 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1211 | 0x80, present ? 0x80 : 0); |
| 1212 | } |
| 1213 | |
| 1214 | /* toggle input of built-in and mic jack appropriately */ |
| 1215 | static void ad1981_hp_automic(struct hda_codec *codec) |
| 1216 | { |
| 1217 | static struct hda_verb mic_jack_on[] = { |
| 1218 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1219 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1220 | {} |
| 1221 | }; |
| 1222 | static struct hda_verb mic_jack_off[] = { |
| 1223 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 1224 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1225 | {} |
| 1226 | }; |
| 1227 | unsigned int present; |
| 1228 | |
| 1229 | present = snd_hda_codec_read(codec, 0x08, 0, |
| 1230 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 1231 | if (present) |
| 1232 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1233 | else |
| 1234 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1235 | } |
| 1236 | |
| 1237 | /* unsolicited event for HP jack sensing */ |
| 1238 | static void ad1981_hp_unsol_event(struct hda_codec *codec, |
| 1239 | unsigned int res) |
| 1240 | { |
| 1241 | res >>= 26; |
| 1242 | switch (res) { |
| 1243 | case AD1981_HP_EVENT: |
| 1244 | ad1981_hp_automute(codec); |
| 1245 | break; |
| 1246 | case AD1981_MIC_EVENT: |
| 1247 | ad1981_hp_automic(codec); |
| 1248 | break; |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | static struct hda_input_mux ad1981_hp_capture_source = { |
| 1253 | .num_items = 3, |
| 1254 | .items = { |
| 1255 | { "Mic", 0x0 }, |
| 1256 | { "Docking-Station", 0x1 }, |
| 1257 | { "Mix", 0x2 }, |
| 1258 | }, |
| 1259 | }; |
| 1260 | |
| 1261 | static struct snd_kcontrol_new ad1981_hp_mixers[] = { |
| 1262 | { |
| 1263 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1264 | .name = "Master Playback Volume", |
| 1265 | .info = snd_hda_mixer_amp_volume_info, |
| 1266 | .get = snd_hda_mixer_amp_volume_get, |
| 1267 | .put = ad1981_hp_master_vol_put, |
| 1268 | .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 1269 | }, |
| 1270 | { |
| 1271 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1272 | .name = "Master Playback Switch", |
| 1273 | .info = ad198x_eapd_info, |
| 1274 | .get = ad198x_eapd_get, |
| 1275 | .put = ad1981_hp_master_sw_put, |
| 1276 | .private_value = 0x05, |
| 1277 | }, |
| 1278 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 1279 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 1280 | #if 0 |
| 1281 | /* FIXME: analog mic/line loopback doesn't work with my tests... |
| 1282 | * (although recording is OK) |
| 1283 | */ |
| 1284 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 1285 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
| 1286 | HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1287 | HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
| 1288 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1289 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), |
| 1290 | /* FIXME: does this laptop have analog CD connection? */ |
| 1291 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1292 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1293 | #endif |
| 1294 | HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT), |
| 1295 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT), |
| 1296 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1297 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), |
| 1298 | { |
| 1299 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1300 | .name = "Capture Source", |
| 1301 | .info = ad198x_mux_enum_info, |
| 1302 | .get = ad198x_mux_enum_get, |
| 1303 | .put = ad198x_mux_enum_put, |
| 1304 | }, |
| 1305 | { } /* end */ |
| 1306 | }; |
| 1307 | |
| 1308 | /* initialize jack-sensing, too */ |
| 1309 | static int ad1981_hp_init(struct hda_codec *codec) |
| 1310 | { |
| 1311 | ad198x_init(codec); |
| 1312 | ad1981_hp_automute(codec); |
| 1313 | ad1981_hp_automic(codec); |
| 1314 | return 0; |
| 1315 | } |
| 1316 | |
| 1317 | /* models */ |
| 1318 | enum { AD1981_BASIC, AD1981_HP }; |
| 1319 | |
| 1320 | static struct hda_board_config ad1981_cfg_tbl[] = { |
| 1321 | { .modelname = "hp", .config = AD1981_HP }, |
| 1322 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x30aa, |
| 1323 | .config = AD1981_HP }, |
| 1324 | { .modelname = "basic", .config = AD1981_BASIC }, |
| 1325 | {} |
| 1326 | }; |
| 1327 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1328 | static int patch_ad1981(struct hda_codec *codec) |
| 1329 | { |
| 1330 | struct ad198x_spec *spec; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1331 | int board_config; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1332 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1333 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1334 | if (spec == NULL) |
| 1335 | return -ENOMEM; |
| 1336 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 1337 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1338 | codec->spec = spec; |
| 1339 | |
| 1340 | spec->multiout.max_channels = 2; |
| 1341 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
| 1342 | spec->multiout.dac_nids = ad1981_dac_nids; |
| 1343 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1344 | spec->num_adc_nids = 1; |
| 1345 | spec->adc_nids = ad1981_adc_nids; |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1346 | spec->capsrc_nids = ad1981_capsrc_nids; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1347 | spec->input_mux = &ad1981_capture_source; |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 1348 | spec->num_mixers = 1; |
| 1349 | spec->mixers[0] = ad1981_mixers; |
| 1350 | spec->num_init_verbs = 1; |
| 1351 | spec->init_verbs[0] = ad1981_init_verbs; |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1352 | spec->spdif_route = 0; |
| 1353 | |
| 1354 | codec->patch_ops = ad198x_patch_ops; |
| 1355 | |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1356 | /* override some parameters */ |
| 1357 | board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl); |
| 1358 | switch (board_config) { |
| 1359 | case AD1981_HP: |
| 1360 | spec->mixers[0] = ad1981_hp_mixers; |
| 1361 | spec->num_init_verbs = 2; |
| 1362 | spec->init_verbs[1] = ad1981_hp_init_verbs; |
| 1363 | spec->multiout.dig_out_nid = 0; |
| 1364 | spec->input_mux = &ad1981_hp_capture_source; |
| 1365 | |
| 1366 | codec->patch_ops.init = ad1981_hp_init; |
| 1367 | codec->patch_ops.unsol_event = ad1981_hp_unsol_event; |
| 1368 | break; |
| 1369 | } |
| 1370 | |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 1371 | return 0; |
| 1372 | } |
| 1373 | |
| 1374 | |
| 1375 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1376 | * AD1988 |
| 1377 | * |
| 1378 | * Output pins and routes |
| 1379 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1380 | * Pin Mix Sel DAC (*) |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1381 | * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 |
| 1382 | * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 |
| 1383 | * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a |
| 1384 | * port-D 0x12 (mute/hp) <- 0x29 <- 04 |
| 1385 | * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a |
| 1386 | * port-F 0x16 (mute) <- 0x2a <- 06 |
| 1387 | * port-G 0x24 (mute) <- 0x27 <- 05 |
| 1388 | * port-H 0x25 (mute) <- 0x28 <- 0a |
| 1389 | * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 |
| 1390 | * |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1391 | * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah |
| 1392 | * (*) 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] | 1393 | * |
| 1394 | * Input pins and routes |
| 1395 | * |
| 1396 | * pin boost mix input # / adc input # |
| 1397 | * port-A 0x11 -> 0x38 -> mix 2, ADC 0 |
| 1398 | * port-B 0x14 -> 0x39 -> mix 0, ADC 1 |
| 1399 | * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 |
| 1400 | * port-D 0x12 -> 0x3d -> mix 3, ADC 8 |
| 1401 | * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 |
| 1402 | * port-F 0x16 -> 0x3b -> mix 5, ADC 3 |
| 1403 | * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 |
| 1404 | * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 |
| 1405 | * |
| 1406 | * |
| 1407 | * DAC assignment |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1408 | * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1409 | * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1410 | * |
| 1411 | * Inputs of Analog Mix (0x20) |
| 1412 | * 0:Port-B (front mic) |
| 1413 | * 1:Port-C/G/H (line-in) |
| 1414 | * 2:Port-A |
| 1415 | * 3:Port-D (line-in/2) |
| 1416 | * 4:Port-E/G/H (mic-in) |
| 1417 | * 5:Port-F (mic2-in) |
| 1418 | * 6:CD |
| 1419 | * 7:Beep |
| 1420 | * |
| 1421 | * ADC selection |
| 1422 | * 0:Port-A |
| 1423 | * 1:Port-B (front mic-in) |
| 1424 | * 2:Port-C (line-in) |
| 1425 | * 3:Port-F (mic2-in) |
| 1426 | * 4:Port-E (mic-in) |
| 1427 | * 5:CD |
| 1428 | * 6:Port-G |
| 1429 | * 7:Port-H |
| 1430 | * 8:Port-D (line-in/2) |
| 1431 | * 9:Mix |
| 1432 | * |
| 1433 | * Proposed pin assignments by the datasheet |
| 1434 | * |
| 1435 | * 6-stack |
| 1436 | * Port-A front headphone |
| 1437 | * B front mic-in |
| 1438 | * C rear line-in |
| 1439 | * D rear front-out |
| 1440 | * E rear mic-in |
| 1441 | * F rear surround |
| 1442 | * G rear CLFE |
| 1443 | * H rear side |
| 1444 | * |
| 1445 | * 3-stack |
| 1446 | * Port-A front headphone |
| 1447 | * B front mic |
| 1448 | * C rear line-in/surround |
| 1449 | * D rear front-out |
| 1450 | * E rear mic-in/CLFE |
| 1451 | * |
| 1452 | * laptop |
| 1453 | * Port-A headphone |
| 1454 | * B mic-in |
| 1455 | * C docking station |
| 1456 | * D internal speaker (with EAPD) |
| 1457 | * E/F quad mic array |
| 1458 | */ |
| 1459 | |
| 1460 | |
| 1461 | /* models */ |
| 1462 | enum { |
| 1463 | AD1988_6STACK, |
| 1464 | AD1988_6STACK_DIG, |
| 1465 | AD1988_3STACK, |
| 1466 | AD1988_3STACK_DIG, |
| 1467 | AD1988_LAPTOP, |
| 1468 | AD1988_LAPTOP_DIG, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1469 | AD1988_AUTO, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1470 | AD1988_MODEL_LAST, |
| 1471 | }; |
| 1472 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1473 | /* reivision id to check workarounds */ |
| 1474 | #define AD1988A_REV2 0x100200 |
| 1475 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1476 | |
| 1477 | /* |
| 1478 | * mixers |
| 1479 | */ |
| 1480 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1481 | static hda_nid_t ad1988_6stack_dac_nids[4] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1482 | 0x04, 0x06, 0x05, 0x0a |
| 1483 | }; |
| 1484 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1485 | static hda_nid_t ad1988_3stack_dac_nids[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1486 | 0x04, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1487 | }; |
| 1488 | |
| 1489 | /* for AD1988A revision-2, DAC2-4 are swapped */ |
| 1490 | static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { |
| 1491 | 0x04, 0x05, 0x0a, 0x06 |
| 1492 | }; |
| 1493 | |
| 1494 | static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1495 | 0x04, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1496 | }; |
| 1497 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1498 | static hda_nid_t ad1988_adc_nids[3] = { |
| 1499 | 0x08, 0x09, 0x0f |
| 1500 | }; |
| 1501 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1502 | static hda_nid_t ad1988_capsrc_nids[3] = { |
| 1503 | 0x0c, 0x0d, 0x0e |
| 1504 | }; |
| 1505 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1506 | #define AD1988_SPDIF_OUT 0x02 |
| 1507 | #define AD1988_SPDIF_IN 0x07 |
| 1508 | |
| 1509 | static struct hda_input_mux ad1988_6stack_capture_source = { |
| 1510 | .num_items = 5, |
| 1511 | .items = { |
| 1512 | { "Front Mic", 0x0 }, |
| 1513 | { "Line", 0x1 }, |
| 1514 | { "Mic", 0x4 }, |
| 1515 | { "CD", 0x5 }, |
| 1516 | { "Mix", 0x9 }, |
| 1517 | }, |
| 1518 | }; |
| 1519 | |
| 1520 | static struct hda_input_mux ad1988_laptop_capture_source = { |
| 1521 | .num_items = 3, |
| 1522 | .items = { |
| 1523 | { "Mic/Line", 0x0 }, |
| 1524 | { "CD", 0x5 }, |
| 1525 | { "Mix", 0x9 }, |
| 1526 | }, |
| 1527 | }; |
| 1528 | |
| 1529 | /* |
| 1530 | */ |
| 1531 | static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 1532 | struct snd_ctl_elem_info *uinfo) |
| 1533 | { |
| 1534 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1535 | struct ad198x_spec *spec = codec->spec; |
| 1536 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 1537 | spec->num_channel_mode); |
| 1538 | } |
| 1539 | |
| 1540 | static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 1541 | struct snd_ctl_elem_value *ucontrol) |
| 1542 | { |
| 1543 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1544 | struct ad198x_spec *spec = codec->spec; |
| 1545 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 1546 | spec->num_channel_mode, spec->multiout.max_channels); |
| 1547 | } |
| 1548 | |
| 1549 | static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 1550 | struct snd_ctl_elem_value *ucontrol) |
| 1551 | { |
| 1552 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1553 | struct ad198x_spec *spec = codec->spec; |
| 1554 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 1555 | spec->num_channel_mode, &spec->multiout.max_channels); |
| 1556 | } |
| 1557 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1558 | /* 6-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1559 | static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1560 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1561 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1562 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1563 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
| 1564 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1565 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1566 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1567 | static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { |
| 1568 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1569 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
| 1570 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
| 1571 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), |
| 1572 | HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
| 1573 | }; |
| 1574 | |
| 1575 | static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1576 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
| 1577 | HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), |
| 1578 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), |
| 1579 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), |
| 1580 | HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), |
| 1581 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1582 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1583 | |
| 1584 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1585 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1586 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1587 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1588 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1589 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1590 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1591 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1592 | |
| 1593 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1594 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1595 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1596 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1597 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1598 | |
| 1599 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1600 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1601 | |
| 1602 | { } /* end */ |
| 1603 | }; |
| 1604 | |
| 1605 | /* 3-stack mode */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1606 | static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1607 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1608 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1609 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), |
| 1610 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1611 | }; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1612 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1613 | static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { |
| 1614 | HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1615 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), |
| 1616 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), |
| 1617 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1618 | }; |
| 1619 | |
| 1620 | static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1621 | HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1622 | HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), |
| 1623 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), |
| 1624 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1625 | HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), |
| 1626 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1627 | |
| 1628 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1629 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1630 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1631 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1632 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1633 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1634 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), |
| 1635 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), |
| 1636 | |
| 1637 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1638 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1639 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1640 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1641 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1642 | |
| 1643 | HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1644 | HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), |
| 1645 | { |
| 1646 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1647 | .name = "Channel Mode", |
| 1648 | .info = ad198x_ch_mode_info, |
| 1649 | .get = ad198x_ch_mode_get, |
| 1650 | .put = ad198x_ch_mode_put, |
| 1651 | }, |
| 1652 | |
| 1653 | { } /* end */ |
| 1654 | }; |
| 1655 | |
| 1656 | /* laptop mode */ |
| 1657 | static struct snd_kcontrol_new ad1988_laptop_mixers[] = { |
| 1658 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), |
| 1659 | HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), |
| 1660 | HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), |
| 1661 | |
| 1662 | HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), |
| 1663 | HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), |
| 1664 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), |
| 1665 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), |
| 1666 | HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), |
| 1667 | HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), |
| 1668 | |
| 1669 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1670 | HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
| 1671 | |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1672 | HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1673 | HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
| 1674 | |
| 1675 | HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), |
| 1676 | |
| 1677 | { |
| 1678 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1679 | .name = "External Amplifier", |
Takashi Iwai | 18a815d | 2006-03-01 19:54:39 +0100 | [diff] [blame] | 1680 | .info = ad198x_eapd_info, |
| 1681 | .get = ad198x_eapd_get, |
| 1682 | .put = ad198x_eapd_put, |
| 1683 | .private_value = 0x12 | (1 << 8), /* port-D, inversed */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1684 | }, |
| 1685 | |
| 1686 | { } /* end */ |
| 1687 | }; |
| 1688 | |
| 1689 | /* capture */ |
| 1690 | static struct snd_kcontrol_new ad1988_capture_mixers[] = { |
| 1691 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
| 1692 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
| 1693 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1694 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), |
| 1695 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1696 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), |
| 1697 | { |
| 1698 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1699 | /* The multiple "Capture Source" controls confuse alsamixer |
| 1700 | * So call somewhat different.. |
| 1701 | * FIXME: the controls appear in the "playback" view! |
| 1702 | */ |
| 1703 | /* .name = "Capture Source", */ |
| 1704 | .name = "Input Source", |
| 1705 | .count = 3, |
| 1706 | .info = ad198x_mux_enum_info, |
| 1707 | .get = ad198x_mux_enum_get, |
| 1708 | .put = ad198x_mux_enum_put, |
| 1709 | }, |
| 1710 | { } /* end */ |
| 1711 | }; |
| 1712 | |
| 1713 | static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, |
| 1714 | struct snd_ctl_elem_info *uinfo) |
| 1715 | { |
| 1716 | static char *texts[] = { |
| 1717 | "PCM", "ADC1", "ADC2", "ADC3" |
| 1718 | }; |
| 1719 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1720 | uinfo->count = 1; |
| 1721 | uinfo->value.enumerated.items = 4; |
| 1722 | if (uinfo->value.enumerated.item >= 4) |
| 1723 | uinfo->value.enumerated.item = 3; |
| 1724 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); |
| 1725 | return 0; |
| 1726 | } |
| 1727 | |
| 1728 | static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, |
| 1729 | struct snd_ctl_elem_value *ucontrol) |
| 1730 | { |
| 1731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1732 | unsigned int sel; |
| 1733 | |
| 1734 | sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1735 | if (sel > 0) { |
| 1736 | sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1737 | if (sel <= 3) |
| 1738 | sel++; |
| 1739 | else |
| 1740 | sel = 0; |
| 1741 | } |
| 1742 | ucontrol->value.enumerated.item[0] = sel; |
| 1743 | return 0; |
| 1744 | } |
| 1745 | |
| 1746 | static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, |
| 1747 | struct snd_ctl_elem_value *ucontrol) |
| 1748 | { |
| 1749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1750 | unsigned int sel; |
| 1751 | int change; |
| 1752 | |
| 1753 | sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); |
| 1754 | if (! ucontrol->value.enumerated.item[0]) { |
| 1755 | change = sel != 0; |
| 1756 | if (change) |
| 1757 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); |
| 1758 | } else { |
| 1759 | change = sel == 0; |
| 1760 | if (change) |
| 1761 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); |
| 1762 | sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; |
| 1763 | change |= sel == ucontrol->value.enumerated.item[0]; |
| 1764 | if (change) |
| 1765 | snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, |
| 1766 | ucontrol->value.enumerated.item[0] - 1); |
| 1767 | } |
| 1768 | return change; |
| 1769 | } |
| 1770 | |
| 1771 | static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { |
| 1772 | HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), |
| 1773 | { |
| 1774 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1775 | .name = "IEC958 Playback Source", |
| 1776 | .info = ad1988_spdif_playback_source_info, |
| 1777 | .get = ad1988_spdif_playback_source_get, |
| 1778 | .put = ad1988_spdif_playback_source_put, |
| 1779 | }, |
| 1780 | { } /* end */ |
| 1781 | }; |
| 1782 | |
| 1783 | static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { |
| 1784 | HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), |
| 1785 | { } /* end */ |
| 1786 | }; |
| 1787 | |
| 1788 | |
| 1789 | /* |
| 1790 | * initialization verbs |
| 1791 | */ |
| 1792 | |
| 1793 | /* |
| 1794 | * for 6-stack (+dig) |
| 1795 | */ |
| 1796 | static struct hda_verb ad1988_6stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1797 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1798 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1799 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1800 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1801 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1802 | /* Port-A front headphon path */ |
| 1803 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 1804 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1805 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1806 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1807 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1808 | /* Port-D line-out path */ |
| 1809 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1810 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1811 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1812 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1813 | /* Port-F surround path */ |
| 1814 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1815 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1816 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1817 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1818 | /* Port-G CLFE path */ |
| 1819 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1820 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1821 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1822 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1823 | /* Port-H side path */ |
| 1824 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1825 | {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1826 | {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1827 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1828 | /* Mono out path */ |
| 1829 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 1830 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1831 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1832 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1833 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 1834 | /* Port-B front mic-in path */ |
| 1835 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1836 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1837 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1838 | /* Port-C line-in path */ |
| 1839 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1840 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1841 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1842 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1843 | /* Port-E mic-in path */ |
| 1844 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1845 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1846 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1847 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1848 | |
| 1849 | { } |
| 1850 | }; |
| 1851 | |
| 1852 | static struct hda_verb ad1988_capture_init_verbs[] = { |
| 1853 | /* mute analog mix */ |
| 1854 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1855 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1856 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1857 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1858 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 1859 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 1860 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 1861 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 1862 | /* select ADCs - front-mic */ |
| 1863 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1864 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1865 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1866 | /* ADCs; muted */ |
| 1867 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1868 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1869 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1870 | |
| 1871 | { } |
| 1872 | }; |
| 1873 | |
| 1874 | static struct hda_verb ad1988_spdif_init_verbs[] = { |
| 1875 | /* SPDIF out sel */ |
| 1876 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ |
| 1877 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ |
| 1878 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1879 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1880 | /* SPDIF out pin */ |
| 1881 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ |
| 1882 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */ |
| 1883 | |
| 1884 | { } |
| 1885 | }; |
| 1886 | |
| 1887 | /* |
| 1888 | * verbs for 3stack (+dig) |
| 1889 | */ |
| 1890 | static struct hda_verb ad1988_3stack_ch2_init[] = { |
| 1891 | /* set port-C to line-in */ |
| 1892 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1893 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1894 | /* set port-E to mic-in */ |
| 1895 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1896 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
| 1897 | { } /* end */ |
| 1898 | }; |
| 1899 | |
| 1900 | static struct hda_verb ad1988_3stack_ch6_init[] = { |
| 1901 | /* set port-C to surround out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1902 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1903 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1904 | /* set port-E to CLFE out */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1905 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1906 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1907 | { } /* end */ |
| 1908 | }; |
| 1909 | |
| 1910 | static struct hda_channel_mode ad1988_3stack_modes[2] = { |
| 1911 | { 2, ad1988_3stack_ch2_init }, |
| 1912 | { 6, ad1988_3stack_ch6_init }, |
| 1913 | }; |
| 1914 | |
| 1915 | static struct hda_verb ad1988_3stack_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1916 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1917 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1918 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1919 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1920 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1921 | /* Port-A front headphon path */ |
| 1922 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 1923 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1924 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1925 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1926 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1927 | /* Port-D line-out path */ |
| 1928 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1929 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1930 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1931 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1932 | /* Mono out path */ |
| 1933 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 1934 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1935 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1936 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1937 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 1938 | /* Port-B front mic-in path */ |
| 1939 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1940 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1941 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1942 | /* Port-C line-in/surround path - 6ch mode as default */ |
| 1943 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1944 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1945 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1946 | {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1947 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 1948 | /* Port-E mic-in/CLFE path - 6ch mode as default */ |
| 1949 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1950 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1951 | {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 1952 | {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1953 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1954 | /* mute analog mix */ |
| 1955 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1956 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1957 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 1958 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 1959 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 1960 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 1961 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 1962 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 1963 | /* select ADCs - front-mic */ |
| 1964 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1965 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1966 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1967 | /* ADCs; muted */ |
| 1968 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1969 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1970 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1971 | { } |
| 1972 | }; |
| 1973 | |
| 1974 | /* |
| 1975 | * verbs for laptop mode (+dig) |
| 1976 | */ |
| 1977 | static struct hda_verb ad1988_laptop_hp_on[] = { |
| 1978 | /* unmute port-A and mute port-D */ |
| 1979 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 1980 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1981 | { } /* end */ |
| 1982 | }; |
| 1983 | static struct hda_verb ad1988_laptop_hp_off[] = { |
| 1984 | /* mute port-A and unmute port-D */ |
| 1985 | { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 1986 | { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, |
| 1987 | { } /* end */ |
| 1988 | }; |
| 1989 | |
| 1990 | #define AD1988_HP_EVENT 0x01 |
| 1991 | |
| 1992 | static struct hda_verb ad1988_laptop_init_verbs[] = { |
Takashi Iwai | 2e5b956 | 2005-11-21 16:36:15 +0100 | [diff] [blame] | 1993 | /* Front, Surround, CLFE, side DAC; unmute as default */ |
| 1994 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1995 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1996 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1997 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 1998 | /* Port-A front headphon path */ |
| 1999 | {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ |
| 2000 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2001 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2002 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2003 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2004 | /* unsolicited event for pin-sense */ |
| 2005 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, |
| 2006 | /* Port-D line-out path + EAPD */ |
| 2007 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2008 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2009 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2010 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2011 | {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ |
| 2012 | /* Mono out path */ |
| 2013 | {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ |
| 2014 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2015 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2016 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2017 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ |
| 2018 | /* Port-B mic-in path */ |
| 2019 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2020 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2021 | {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2022 | /* Port-C docking station - try to output */ |
| 2023 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2024 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2025 | {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2026 | {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2027 | /* mute analog mix */ |
| 2028 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2029 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2030 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2031 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2032 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2033 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, |
| 2034 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
| 2035 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
| 2036 | /* select ADCs - mic */ |
| 2037 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2038 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2039 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 2040 | /* ADCs; muted */ |
| 2041 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2042 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2043 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2044 | { } |
| 2045 | }; |
| 2046 | |
| 2047 | static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2048 | { |
| 2049 | if ((res >> 26) != AD1988_HP_EVENT) |
| 2050 | return; |
| 2051 | if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) |
| 2052 | snd_hda_sequence_write(codec, ad1988_laptop_hp_on); |
| 2053 | else |
| 2054 | snd_hda_sequence_write(codec, ad1988_laptop_hp_off); |
| 2055 | } |
| 2056 | |
| 2057 | |
| 2058 | /* |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2059 | * Automatic parse of I/O pins from the BIOS configuration |
| 2060 | */ |
| 2061 | |
| 2062 | #define NUM_CONTROL_ALLOC 32 |
| 2063 | #define NUM_VERB_ALLOC 32 |
| 2064 | |
| 2065 | enum { |
| 2066 | AD_CTL_WIDGET_VOL, |
| 2067 | AD_CTL_WIDGET_MUTE, |
| 2068 | AD_CTL_BIND_MUTE, |
| 2069 | }; |
| 2070 | static struct snd_kcontrol_new ad1988_control_templates[] = { |
| 2071 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2072 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
| 2073 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
| 2074 | }; |
| 2075 | |
| 2076 | /* add dynamic controls */ |
| 2077 | static int add_control(struct ad198x_spec *spec, int type, const char *name, |
| 2078 | unsigned long val) |
| 2079 | { |
| 2080 | struct snd_kcontrol_new *knew; |
| 2081 | |
| 2082 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2083 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2084 | |
| 2085 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2086 | if (! knew) |
| 2087 | return -ENOMEM; |
| 2088 | if (spec->kctl_alloc) { |
| 2089 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2090 | kfree(spec->kctl_alloc); |
| 2091 | } |
| 2092 | spec->kctl_alloc = knew; |
| 2093 | spec->num_kctl_alloc = num; |
| 2094 | } |
| 2095 | |
| 2096 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2097 | *knew = ad1988_control_templates[type]; |
| 2098 | knew->name = kstrdup(name, GFP_KERNEL); |
| 2099 | if (! knew->name) |
| 2100 | return -ENOMEM; |
| 2101 | knew->private_value = val; |
| 2102 | spec->num_kctl_used++; |
| 2103 | return 0; |
| 2104 | } |
| 2105 | |
| 2106 | #define AD1988_PIN_CD_NID 0x18 |
| 2107 | #define AD1988_PIN_BEEP_NID 0x10 |
| 2108 | |
| 2109 | static hda_nid_t ad1988_mixer_nids[8] = { |
| 2110 | /* A B C D E F G H */ |
| 2111 | 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 |
| 2112 | }; |
| 2113 | |
| 2114 | static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) |
| 2115 | { |
| 2116 | static hda_nid_t idx_to_dac[8] = { |
| 2117 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2118 | 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2119 | }; |
| 2120 | static hda_nid_t idx_to_dac_rev2[8] = { |
| 2121 | /* A B C D E F G H */ |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2122 | 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2123 | }; |
| 2124 | if (codec->revision_id == AD1988A_REV2) |
| 2125 | return idx_to_dac_rev2[idx]; |
| 2126 | else |
| 2127 | return idx_to_dac[idx]; |
| 2128 | } |
| 2129 | |
| 2130 | static hda_nid_t ad1988_boost_nids[8] = { |
| 2131 | 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 |
| 2132 | }; |
| 2133 | |
| 2134 | static int ad1988_pin_idx(hda_nid_t nid) |
| 2135 | { |
| 2136 | static hda_nid_t ad1988_io_pins[8] = { |
| 2137 | 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 |
| 2138 | }; |
| 2139 | int i; |
| 2140 | for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) |
| 2141 | if (ad1988_io_pins[i] == nid) |
| 2142 | return i; |
| 2143 | return 0; /* should be -1 */ |
| 2144 | } |
| 2145 | |
| 2146 | static int ad1988_pin_to_loopback_idx(hda_nid_t nid) |
| 2147 | { |
| 2148 | static int loopback_idx[8] = { |
| 2149 | 2, 0, 1, 3, 4, 5, 1, 4 |
| 2150 | }; |
| 2151 | switch (nid) { |
| 2152 | case AD1988_PIN_CD_NID: |
| 2153 | return 6; |
| 2154 | default: |
| 2155 | return loopback_idx[ad1988_pin_idx(nid)]; |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | static int ad1988_pin_to_adc_idx(hda_nid_t nid) |
| 2160 | { |
| 2161 | static int adc_idx[8] = { |
| 2162 | 0, 1, 2, 8, 4, 3, 6, 7 |
| 2163 | }; |
| 2164 | switch (nid) { |
| 2165 | case AD1988_PIN_CD_NID: |
| 2166 | return 5; |
| 2167 | default: |
| 2168 | return adc_idx[ad1988_pin_idx(nid)]; |
| 2169 | } |
| 2170 | } |
| 2171 | |
| 2172 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 2173 | static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, |
| 2174 | const struct auto_pin_cfg *cfg) |
| 2175 | { |
| 2176 | struct ad198x_spec *spec = codec->spec; |
| 2177 | int i, idx; |
| 2178 | |
| 2179 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2180 | |
| 2181 | /* check the pins hardwired to audio widget */ |
| 2182 | for (i = 0; i < cfg->line_outs; i++) { |
| 2183 | idx = ad1988_pin_idx(cfg->line_out_pins[i]); |
| 2184 | spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); |
| 2185 | } |
| 2186 | spec->multiout.num_dacs = cfg->line_outs; |
| 2187 | return 0; |
| 2188 | } |
| 2189 | |
| 2190 | /* add playback controls from the parsed DAC table */ |
| 2191 | static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, |
| 2192 | const struct auto_pin_cfg *cfg) |
| 2193 | { |
| 2194 | char name[32]; |
| 2195 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 2196 | hda_nid_t nid; |
| 2197 | int i, err; |
| 2198 | |
| 2199 | for (i = 0; i < cfg->line_outs; i++) { |
| 2200 | hda_nid_t dac = spec->multiout.dac_nids[i]; |
| 2201 | if (! dac) |
| 2202 | continue; |
| 2203 | nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; |
| 2204 | if (i == 2) { |
| 2205 | /* Center/LFE */ |
| 2206 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2207 | "Center Playback Volume", |
| 2208 | HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); |
| 2209 | if (err < 0) |
| 2210 | return err; |
| 2211 | err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2212 | "LFE Playback Volume", |
| 2213 | HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); |
| 2214 | if (err < 0) |
| 2215 | return err; |
| 2216 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2217 | "Center Playback Switch", |
| 2218 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); |
| 2219 | if (err < 0) |
| 2220 | return err; |
| 2221 | err = add_control(spec, AD_CTL_BIND_MUTE, |
| 2222 | "LFE Playback Switch", |
| 2223 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); |
| 2224 | if (err < 0) |
| 2225 | return err; |
| 2226 | } else { |
| 2227 | sprintf(name, "%s Playback Volume", chname[i]); |
| 2228 | err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2229 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); |
| 2230 | if (err < 0) |
| 2231 | return err; |
| 2232 | sprintf(name, "%s Playback Switch", chname[i]); |
| 2233 | err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2234 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
| 2235 | if (err < 0) |
| 2236 | return err; |
| 2237 | } |
| 2238 | } |
| 2239 | return 0; |
| 2240 | } |
| 2241 | |
| 2242 | /* add playback controls for speaker and HP outputs */ |
| 2243 | static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
| 2244 | const char *pfx) |
| 2245 | { |
| 2246 | struct ad198x_spec *spec = codec->spec; |
| 2247 | hda_nid_t nid; |
| 2248 | int idx, err; |
| 2249 | char name[32]; |
| 2250 | |
| 2251 | if (! pin) |
| 2252 | return 0; |
| 2253 | |
| 2254 | idx = ad1988_pin_idx(pin); |
| 2255 | nid = ad1988_idx_to_dac(codec, idx); |
| 2256 | if (! spec->multiout.dac_nids[0]) { |
| 2257 | /* use this as the primary output */ |
| 2258 | spec->multiout.dac_nids[0] = nid; |
| 2259 | if (! spec->multiout.num_dacs) |
| 2260 | spec->multiout.num_dacs = 1; |
| 2261 | } else |
| 2262 | /* specify the DAC as the extra output */ |
| 2263 | spec->multiout.hp_nid = nid; |
| 2264 | /* control HP volume/switch on the output mixer amp */ |
| 2265 | sprintf(name, "%s Playback Volume", pfx); |
| 2266 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2267 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 2268 | return err; |
| 2269 | nid = ad1988_mixer_nids[idx]; |
| 2270 | sprintf(name, "%s Playback Switch", pfx); |
| 2271 | if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, |
| 2272 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
| 2273 | return err; |
| 2274 | return 0; |
| 2275 | } |
| 2276 | |
| 2277 | /* create input playback/capture controls for the given pin */ |
| 2278 | static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, |
| 2279 | const char *ctlname, int boost) |
| 2280 | { |
| 2281 | char name[32]; |
| 2282 | int err, idx; |
| 2283 | |
| 2284 | sprintf(name, "%s Playback Volume", ctlname); |
| 2285 | idx = ad1988_pin_to_loopback_idx(pin); |
| 2286 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2287 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2288 | return err; |
| 2289 | sprintf(name, "%s Playback Switch", ctlname); |
| 2290 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, |
| 2291 | HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) |
| 2292 | return err; |
| 2293 | if (boost) { |
| 2294 | hda_nid_t bnid; |
| 2295 | idx = ad1988_pin_idx(pin); |
| 2296 | bnid = ad1988_boost_nids[idx]; |
| 2297 | if (bnid) { |
| 2298 | sprintf(name, "%s Boost", ctlname); |
| 2299 | return add_control(spec, AD_CTL_WIDGET_VOL, name, |
| 2300 | HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); |
| 2301 | |
| 2302 | } |
| 2303 | } |
| 2304 | return 0; |
| 2305 | } |
| 2306 | |
| 2307 | /* create playback/capture controls for input pins */ |
| 2308 | static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, |
| 2309 | const struct auto_pin_cfg *cfg) |
| 2310 | { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2311 | struct hda_input_mux *imux = &spec->private_imux; |
| 2312 | int i, err; |
| 2313 | |
| 2314 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2315 | err = new_analog_input(spec, cfg->input_pins[i], |
| 2316 | auto_pin_cfg_labels[i], |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2317 | i <= AUTO_PIN_FRONT_MIC); |
| 2318 | if (err < 0) |
| 2319 | return err; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2320 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2321 | imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); |
| 2322 | imux->num_items++; |
| 2323 | } |
| 2324 | imux->items[imux->num_items].label = "Mix"; |
| 2325 | imux->items[imux->num_items].index = 9; |
| 2326 | imux->num_items++; |
| 2327 | |
| 2328 | if ((err = add_control(spec, AD_CTL_WIDGET_VOL, |
| 2329 | "Analog Mix Playback Volume", |
| 2330 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2331 | return err; |
| 2332 | if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, |
| 2333 | "Analog Mix Playback Switch", |
| 2334 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) |
| 2335 | return err; |
| 2336 | |
| 2337 | return 0; |
| 2338 | } |
| 2339 | |
| 2340 | static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, |
| 2341 | hda_nid_t nid, int pin_type, |
| 2342 | int dac_idx) |
| 2343 | { |
| 2344 | /* set as output */ |
| 2345 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 2346 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
| 2347 | switch (nid) { |
| 2348 | case 0x11: /* port-A - DAC 04 */ |
| 2349 | snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2350 | break; |
| 2351 | case 0x14: /* port-B - DAC 06 */ |
| 2352 | snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); |
| 2353 | break; |
| 2354 | case 0x15: /* port-C - DAC 05 */ |
| 2355 | snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); |
| 2356 | break; |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2357 | case 0x17: /* port-E - DAC 0a */ |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2358 | snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2359 | break; |
| 2360 | case 0x13: /* mono - DAC 04 */ |
| 2361 | snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); |
| 2362 | break; |
| 2363 | } |
| 2364 | } |
| 2365 | |
| 2366 | static void ad1988_auto_init_multi_out(struct hda_codec *codec) |
| 2367 | { |
| 2368 | struct ad198x_spec *spec = codec->spec; |
| 2369 | int i; |
| 2370 | |
| 2371 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2372 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2373 | ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 2374 | } |
| 2375 | } |
| 2376 | |
| 2377 | static void ad1988_auto_init_extra_out(struct hda_codec *codec) |
| 2378 | { |
| 2379 | struct ad198x_spec *spec = codec->spec; |
| 2380 | hda_nid_t pin; |
| 2381 | |
| 2382 | pin = spec->autocfg.speaker_pin; |
| 2383 | if (pin) /* connect to front */ |
| 2384 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
| 2385 | pin = spec->autocfg.hp_pin; |
| 2386 | if (pin) /* connect to front */ |
| 2387 | ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 2388 | } |
| 2389 | |
| 2390 | static void ad1988_auto_init_analog_input(struct hda_codec *codec) |
| 2391 | { |
| 2392 | struct ad198x_spec *spec = codec->spec; |
| 2393 | int i, idx; |
| 2394 | |
| 2395 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 2396 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
| 2397 | if (! nid) |
| 2398 | continue; |
| 2399 | switch (nid) { |
| 2400 | case 0x15: /* port-C */ |
| 2401 | snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2402 | break; |
| 2403 | case 0x17: /* port-E */ |
| 2404 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
| 2405 | break; |
| 2406 | } |
| 2407 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2408 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); |
| 2409 | if (nid != AD1988_PIN_CD_NID) |
| 2410 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 2411 | AMP_OUT_MUTE); |
| 2412 | idx = ad1988_pin_idx(nid); |
| 2413 | if (ad1988_boost_nids[idx]) |
| 2414 | snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, |
| 2415 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2416 | AMP_OUT_ZERO); |
| 2417 | } |
| 2418 | } |
| 2419 | |
| 2420 | /* parse the BIOS configuration and set up the alc_spec */ |
| 2421 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ |
| 2422 | static int ad1988_parse_auto_config(struct hda_codec *codec) |
| 2423 | { |
| 2424 | struct ad198x_spec *spec = codec->spec; |
| 2425 | int err; |
| 2426 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2427 | 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] | 2428 | return err; |
| 2429 | if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 2430 | return err; |
| 2431 | if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && |
| 2432 | ! spec->autocfg.hp_pin) |
| 2433 | return 0; /* can't find valid BIOS pin config */ |
| 2434 | if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 2435 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, |
| 2436 | "Speaker")) < 0 || |
| 2437 | (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, |
| 2438 | "Headphone")) < 0 || |
| 2439 | (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
| 2440 | return err; |
| 2441 | |
| 2442 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2443 | |
| 2444 | if (spec->autocfg.dig_out_pin) |
| 2445 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2446 | if (spec->autocfg.dig_in_pin) |
| 2447 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2448 | |
| 2449 | if (spec->kctl_alloc) |
| 2450 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2451 | |
| 2452 | spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; |
| 2453 | |
| 2454 | spec->input_mux = &spec->private_imux; |
| 2455 | |
| 2456 | return 1; |
| 2457 | } |
| 2458 | |
| 2459 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2460 | static int ad1988_auto_init(struct hda_codec *codec) |
| 2461 | { |
| 2462 | ad198x_init(codec); |
| 2463 | ad1988_auto_init_multi_out(codec); |
| 2464 | ad1988_auto_init_extra_out(codec); |
| 2465 | ad1988_auto_init_analog_input(codec); |
| 2466 | return 0; |
| 2467 | } |
| 2468 | |
| 2469 | |
| 2470 | /* |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2471 | */ |
| 2472 | |
| 2473 | static struct hda_board_config ad1988_cfg_tbl[] = { |
| 2474 | { .modelname = "6stack", .config = AD1988_6STACK }, |
| 2475 | { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG }, |
| 2476 | { .modelname = "3stack", .config = AD1988_3STACK }, |
| 2477 | { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, |
| 2478 | { .modelname = "laptop", .config = AD1988_LAPTOP }, |
| 2479 | { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2480 | { .modelname = "auto", .config = AD1988_AUTO }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2481 | {} |
| 2482 | }; |
| 2483 | |
| 2484 | static int patch_ad1988(struct hda_codec *codec) |
| 2485 | { |
| 2486 | struct ad198x_spec *spec; |
| 2487 | int board_config; |
| 2488 | |
| 2489 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2490 | if (spec == NULL) |
| 2491 | return -ENOMEM; |
| 2492 | |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 2493 | mutex_init(&spec->amp_mutex); |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2494 | codec->spec = spec; |
| 2495 | |
Takashi Iwai | f8c7c7b | 2005-11-24 16:17:20 +0100 | [diff] [blame] | 2496 | if (codec->revision_id == AD1988A_REV2) |
| 2497 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
| 2498 | |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2499 | board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); |
| 2500 | if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2501 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); |
| 2502 | board_config = AD1988_AUTO; |
| 2503 | } |
| 2504 | |
| 2505 | if (board_config == AD1988_AUTO) { |
| 2506 | /* automatic parse from the BIOS config */ |
| 2507 | int err = ad1988_parse_auto_config(codec); |
| 2508 | if (err < 0) { |
| 2509 | ad198x_free(codec); |
| 2510 | return err; |
| 2511 | } else if (! err) { |
| 2512 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); |
| 2513 | board_config = AD1988_6STACK; |
| 2514 | } |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2515 | } |
| 2516 | |
| 2517 | switch (board_config) { |
| 2518 | case AD1988_6STACK: |
| 2519 | case AD1988_6STACK_DIG: |
| 2520 | spec->multiout.max_channels = 8; |
| 2521 | spec->multiout.num_dacs = 4; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2522 | if (codec->revision_id == AD1988A_REV2) |
| 2523 | spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; |
| 2524 | else |
| 2525 | spec->multiout.dac_nids = ad1988_6stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2526 | spec->input_mux = &ad1988_6stack_capture_source; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2527 | spec->num_mixers = 2; |
| 2528 | if (codec->revision_id == AD1988A_REV2) |
| 2529 | spec->mixers[0] = ad1988_6stack_mixers1_rev2; |
| 2530 | else |
| 2531 | spec->mixers[0] = ad1988_6stack_mixers1; |
| 2532 | spec->mixers[1] = ad1988_6stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2533 | spec->num_init_verbs = 1; |
| 2534 | spec->init_verbs[0] = ad1988_6stack_init_verbs; |
| 2535 | if (board_config == AD1988_6STACK_DIG) { |
| 2536 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2537 | spec->dig_in_nid = AD1988_SPDIF_IN; |
| 2538 | } |
| 2539 | break; |
| 2540 | case AD1988_3STACK: |
| 2541 | case AD1988_3STACK_DIG: |
| 2542 | spec->multiout.max_channels = 6; |
| 2543 | spec->multiout.num_dacs = 3; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2544 | if (codec->revision_id == AD1988A_REV2) |
| 2545 | spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; |
| 2546 | else |
| 2547 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2548 | spec->input_mux = &ad1988_6stack_capture_source; |
| 2549 | spec->channel_mode = ad1988_3stack_modes; |
| 2550 | spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2551 | spec->num_mixers = 2; |
| 2552 | if (codec->revision_id == AD1988A_REV2) |
| 2553 | spec->mixers[0] = ad1988_3stack_mixers1_rev2; |
| 2554 | else |
| 2555 | spec->mixers[0] = ad1988_3stack_mixers1; |
| 2556 | spec->mixers[1] = ad1988_3stack_mixers2; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2557 | spec->num_init_verbs = 1; |
| 2558 | spec->init_verbs[0] = ad1988_3stack_init_verbs; |
| 2559 | if (board_config == AD1988_3STACK_DIG) |
| 2560 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2561 | break; |
| 2562 | case AD1988_LAPTOP: |
| 2563 | case AD1988_LAPTOP_DIG: |
| 2564 | spec->multiout.max_channels = 2; |
| 2565 | spec->multiout.num_dacs = 1; |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2566 | spec->multiout.dac_nids = ad1988_3stack_dac_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2567 | spec->input_mux = &ad1988_laptop_capture_source; |
| 2568 | spec->num_mixers = 1; |
| 2569 | spec->mixers[0] = ad1988_laptop_mixers; |
| 2570 | spec->num_init_verbs = 1; |
| 2571 | spec->init_verbs[0] = ad1988_laptop_init_verbs; |
| 2572 | if (board_config == AD1988_LAPTOP_DIG) |
| 2573 | spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; |
| 2574 | break; |
| 2575 | } |
| 2576 | |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2577 | spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); |
| 2578 | spec->adc_nids = ad1988_adc_nids; |
| 2579 | spec->capsrc_nids = ad1988_capsrc_nids; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2580 | spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; |
| 2581 | spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; |
| 2582 | if (spec->multiout.dig_out_nid) { |
| 2583 | spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; |
| 2584 | spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; |
| 2585 | } |
| 2586 | if (spec->dig_in_nid) |
| 2587 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
| 2588 | |
| 2589 | codec->patch_ops = ad198x_patch_ops; |
| 2590 | switch (board_config) { |
Takashi Iwai | d32410b1 | 2005-11-24 16:06:23 +0100 | [diff] [blame] | 2591 | case AD1988_AUTO: |
| 2592 | codec->patch_ops.init = ad1988_auto_init; |
| 2593 | break; |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2594 | case AD1988_LAPTOP: |
| 2595 | case AD1988_LAPTOP_DIG: |
| 2596 | codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; |
| 2597 | break; |
| 2598 | } |
| 2599 | |
| 2600 | return 0; |
| 2601 | } |
| 2602 | |
| 2603 | |
| 2604 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2605 | * patch entries |
| 2606 | */ |
| 2607 | struct hda_codec_preset snd_hda_preset_analog[] = { |
Takashi Iwai | 4a3fdf3 | 2005-04-14 13:35:51 +0200 | [diff] [blame] | 2608 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, |
| 2609 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
Takashi Iwai | fd66e0d | 2005-11-17 15:31:34 +0100 | [diff] [blame] | 2611 | { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | {} /* terminator */ |
| 2613 | }; |