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