Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1 | /* |
| 2 | * HD audio interface patch for Conexant HDA audio codec |
| 3 | * |
| 4 | * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> |
| 5 | * Takashi Iwai <tiwai@suse.de> |
| 6 | * Tobin Davis <tdavis@dsl-only.net> |
| 7 | * |
| 8 | * This driver is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This driver is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 23 | #include <linux/init.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 27 | #include <linux/module.h> |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 28 | #include <sound/core.h> |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 29 | #include <sound/jack.h> |
| 30 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 31 | #include "hda_codec.h" |
| 32 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 33 | #include "hda_auto_parser.h" |
Einar Rünkaru | c0f8faf | 2009-12-16 22:41:36 +0200 | [diff] [blame] | 34 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 35 | #include "hda_jack.h" |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 36 | #include "hda_generic.h" |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 37 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 38 | #define ENABLE_CXT_STATIC_QUIRKS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 39 | |
| 40 | #define CXT_PIN_DIR_IN 0x00 |
| 41 | #define CXT_PIN_DIR_OUT 0x01 |
| 42 | #define CXT_PIN_DIR_INOUT 0x02 |
| 43 | #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 |
| 44 | #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 |
| 45 | |
| 46 | #define CONEXANT_HP_EVENT 0x37 |
| 47 | #define CONEXANT_MIC_EVENT 0x38 |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 48 | #define CONEXANT_LINE_EVENT 0x39 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 49 | |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 50 | /* Conexant 5051 specific */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 51 | |
Takashi Iwai | ecda0cf | 2010-01-24 11:14:36 +0100 | [diff] [blame] | 52 | #define CXT5051_SPDIF_OUT 0x12 |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 53 | #define CXT5051_PORTB_EVENT 0x38 |
| 54 | #define CXT5051_PORTC_EVENT 0x39 |
| 55 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 56 | #define AUTO_MIC_PORTB (1 << 1) |
| 57 | #define AUTO_MIC_PORTC (1 << 2) |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 58 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 59 | struct conexant_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 60 | struct hda_gen_spec gen; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 61 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 62 | unsigned int beep_amp; |
| 63 | |
| 64 | /* extra EAPD pins */ |
| 65 | unsigned int num_eapds; |
| 66 | hda_nid_t eapds[4]; |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 67 | bool dynamic_eapd; |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 68 | |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 69 | unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ |
| 70 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 71 | #ifdef ENABLE_CXT_STATIC_QUIRKS |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 72 | const struct snd_kcontrol_new *mixers[5]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 73 | int num_mixers; |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 74 | hda_nid_t vmaster_nid; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 75 | |
| 76 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
| 77 | * don't forget NULL |
| 78 | * termination! |
| 79 | */ |
| 80 | unsigned int num_init_verbs; |
| 81 | |
| 82 | /* playback */ |
| 83 | struct hda_multi_out multiout; /* playback set-up |
| 84 | * max_channels, dacs must be set |
| 85 | * dig_out_nid and hp_nid are optional |
| 86 | */ |
| 87 | unsigned int cur_eapd; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 88 | unsigned int hp_present; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 89 | unsigned int line_present; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 90 | unsigned int auto_mic; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 91 | |
| 92 | /* capture */ |
| 93 | unsigned int num_adc_nids; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 94 | const hda_nid_t *adc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 95 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 96 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 97 | unsigned int cur_adc_idx; |
| 98 | hda_nid_t cur_adc; |
| 99 | unsigned int cur_adc_stream_tag; |
| 100 | unsigned int cur_adc_format; |
| 101 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 102 | const struct hda_pcm_stream *capture_stream; |
| 103 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 104 | /* capture source */ |
| 105 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 106 | const hda_nid_t *capsrc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 107 | unsigned int cur_mux[3]; |
| 108 | |
| 109 | /* channel model */ |
| 110 | const struct hda_channel_mode *channel_mode; |
| 111 | int num_channel_mode; |
| 112 | |
| 113 | /* PCM information */ |
| 114 | struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ |
| 115 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 116 | unsigned int spdif_route; |
| 117 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 118 | unsigned int port_d_mode; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 119 | unsigned int dell_automute:1; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 120 | unsigned int dell_vostro:1; |
| 121 | unsigned int ideapad:1; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 122 | unsigned int thinkpad:1; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 123 | unsigned int hp_laptop:1; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 124 | unsigned int asus:1; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 125 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 126 | unsigned int ext_mic_present; |
| 127 | unsigned int recording; |
| 128 | void (*capture_prepare)(struct hda_codec *codec); |
| 129 | void (*capture_cleanup)(struct hda_codec *codec); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 130 | |
| 131 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) |
| 132 | * through the microphone jack. |
| 133 | * When the user enables this through a mixer switch, both internal and |
| 134 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, |
| 135 | * we also allow the bias to be configured through a separate mixer |
| 136 | * control. */ |
| 137 | unsigned int dc_enable; |
| 138 | unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ |
| 139 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 140 | #endif /* ENABLE_CXT_STATIC_QUIRKS */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 141 | }; |
| 142 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 143 | |
| 144 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 7504b6c | 2013-03-18 11:25:51 +0100 | [diff] [blame] | 145 | static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, |
| 146 | int idx, int dir) |
| 147 | { |
| 148 | spec->gen.beep_nid = nid; |
| 149 | spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); |
| 150 | } |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 151 | /* additional beep mixers; the actual parameters are overwritten at build */ |
| 152 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { |
| 153 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), |
| 154 | HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), |
| 155 | { } /* end */ |
| 156 | }; |
| 157 | |
| 158 | /* create beep controls if needed */ |
| 159 | static int add_beep_ctls(struct hda_codec *codec) |
| 160 | { |
| 161 | struct conexant_spec *spec = codec->spec; |
| 162 | int err; |
| 163 | |
| 164 | if (spec->beep_amp) { |
| 165 | const struct snd_kcontrol_new *knew; |
| 166 | for (knew = cxt_beep_mixer; knew->name; knew++) { |
| 167 | struct snd_kcontrol *kctl; |
| 168 | kctl = snd_ctl_new1(knew, codec); |
| 169 | if (!kctl) |
| 170 | return -ENOMEM; |
| 171 | kctl->private_value = spec->beep_amp; |
| 172 | err = snd_hda_ctl_add(codec, 0, kctl); |
| 173 | if (err < 0) |
| 174 | return err; |
| 175 | } |
| 176 | } |
| 177 | return 0; |
| 178 | } |
| 179 | #else |
| 180 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 181 | #define add_beep_ctls(codec) 0 |
| 182 | #endif |
| 183 | |
| 184 | |
| 185 | #ifdef ENABLE_CXT_STATIC_QUIRKS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 186 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 187 | struct hda_codec *codec, |
| 188 | struct snd_pcm_substream *substream) |
| 189 | { |
| 190 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 191 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 192 | hinfo); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | static int conexant_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 conexant_spec *spec = codec->spec; |
| 202 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 203 | stream_tag, |
| 204 | format, substream); |
| 205 | } |
| 206 | |
| 207 | static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 208 | struct hda_codec *codec, |
| 209 | struct snd_pcm_substream *substream) |
| 210 | { |
| 211 | struct conexant_spec *spec = codec->spec; |
| 212 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | * Digital out |
| 217 | */ |
| 218 | static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 219 | struct hda_codec *codec, |
| 220 | struct snd_pcm_substream *substream) |
| 221 | { |
| 222 | struct conexant_spec *spec = codec->spec; |
| 223 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 224 | } |
| 225 | |
| 226 | static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 227 | struct hda_codec *codec, |
| 228 | struct snd_pcm_substream *substream) |
| 229 | { |
| 230 | struct conexant_spec *spec = codec->spec; |
| 231 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 232 | } |
| 233 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 234 | static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 235 | struct hda_codec *codec, |
| 236 | unsigned int stream_tag, |
| 237 | unsigned int format, |
| 238 | struct snd_pcm_substream *substream) |
| 239 | { |
| 240 | struct conexant_spec *spec = codec->spec; |
| 241 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 242 | stream_tag, |
| 243 | format, substream); |
| 244 | } |
| 245 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 246 | /* |
| 247 | * Analog capture |
| 248 | */ |
| 249 | static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 250 | struct hda_codec *codec, |
| 251 | unsigned int stream_tag, |
| 252 | unsigned int format, |
| 253 | struct snd_pcm_substream *substream) |
| 254 | { |
| 255 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 256 | if (spec->capture_prepare) |
| 257 | spec->capture_prepare(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 258 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 259 | stream_tag, 0, format); |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 264 | struct hda_codec *codec, |
| 265 | struct snd_pcm_substream *substream) |
| 266 | { |
| 267 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 268 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 269 | if (spec->capture_cleanup) |
| 270 | spec->capture_cleanup(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | |
| 275 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 276 | static const struct hda_pcm_stream conexant_pcm_analog_playback = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 277 | .substreams = 1, |
| 278 | .channels_min = 2, |
| 279 | .channels_max = 2, |
| 280 | .nid = 0, /* fill later */ |
| 281 | .ops = { |
| 282 | .open = conexant_playback_pcm_open, |
| 283 | .prepare = conexant_playback_pcm_prepare, |
| 284 | .cleanup = conexant_playback_pcm_cleanup |
| 285 | }, |
| 286 | }; |
| 287 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 288 | static const struct hda_pcm_stream conexant_pcm_analog_capture = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 289 | .substreams = 1, |
| 290 | .channels_min = 2, |
| 291 | .channels_max = 2, |
| 292 | .nid = 0, /* fill later */ |
| 293 | .ops = { |
| 294 | .prepare = conexant_capture_pcm_prepare, |
| 295 | .cleanup = conexant_capture_pcm_cleanup |
| 296 | }, |
| 297 | }; |
| 298 | |
| 299 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 300 | static const struct hda_pcm_stream conexant_pcm_digital_playback = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 301 | .substreams = 1, |
| 302 | .channels_min = 2, |
| 303 | .channels_max = 2, |
| 304 | .nid = 0, /* fill later */ |
| 305 | .ops = { |
| 306 | .open = conexant_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 307 | .close = conexant_dig_playback_pcm_close, |
| 308 | .prepare = conexant_dig_playback_pcm_prepare |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 309 | }, |
| 310 | }; |
| 311 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 312 | static const struct hda_pcm_stream conexant_pcm_digital_capture = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 313 | .substreams = 1, |
| 314 | .channels_min = 2, |
| 315 | .channels_max = 2, |
| 316 | /* NID is set in alc_build_pcms */ |
| 317 | }; |
| 318 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 319 | static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 320 | struct hda_codec *codec, |
| 321 | unsigned int stream_tag, |
| 322 | unsigned int format, |
| 323 | struct snd_pcm_substream *substream) |
| 324 | { |
| 325 | struct conexant_spec *spec = codec->spec; |
| 326 | spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; |
| 327 | spec->cur_adc_stream_tag = stream_tag; |
| 328 | spec->cur_adc_format = format; |
| 329 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 334 | struct hda_codec *codec, |
| 335 | struct snd_pcm_substream *substream) |
| 336 | { |
| 337 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 338 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 339 | spec->cur_adc = 0; |
| 340 | return 0; |
| 341 | } |
| 342 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 343 | static const struct hda_pcm_stream cx5051_pcm_analog_capture = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 344 | .substreams = 1, |
| 345 | .channels_min = 2, |
| 346 | .channels_max = 2, |
| 347 | .nid = 0, /* fill later */ |
| 348 | .ops = { |
| 349 | .prepare = cx5051_capture_pcm_prepare, |
| 350 | .cleanup = cx5051_capture_pcm_cleanup |
| 351 | }, |
| 352 | }; |
| 353 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 354 | static int conexant_build_pcms(struct hda_codec *codec) |
| 355 | { |
| 356 | struct conexant_spec *spec = codec->spec; |
| 357 | struct hda_pcm *info = spec->pcm_rec; |
| 358 | |
| 359 | codec->num_pcms = 1; |
| 360 | codec->pcm_info = info; |
| 361 | |
| 362 | info->name = "CONEXANT Analog"; |
| 363 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; |
| 364 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 365 | spec->multiout.max_channels; |
| 366 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 367 | spec->multiout.dac_nids[0]; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 368 | if (spec->capture_stream) |
| 369 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; |
| 370 | else { |
| 371 | if (codec->vendor_id == 0x14f15051) |
| 372 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 373 | cx5051_pcm_analog_capture; |
| 374 | else { |
| 375 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 376 | conexant_pcm_analog_capture; |
| 377 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 378 | spec->num_adc_nids; |
| 379 | } |
| 380 | } |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 381 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 382 | |
| 383 | if (spec->multiout.dig_out_nid) { |
| 384 | info++; |
| 385 | codec->num_pcms++; |
| 386 | info->name = "Conexant Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 387 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 388 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 389 | conexant_pcm_digital_playback; |
| 390 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 391 | spec->multiout.dig_out_nid; |
| 392 | if (spec->dig_in_nid) { |
| 393 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 394 | conexant_pcm_digital_capture; |
| 395 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 396 | spec->dig_in_nid; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 404 | struct snd_ctl_elem_info *uinfo) |
| 405 | { |
| 406 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 407 | struct conexant_spec *spec = codec->spec; |
| 408 | |
| 409 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 410 | } |
| 411 | |
| 412 | static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 413 | struct snd_ctl_elem_value *ucontrol) |
| 414 | { |
| 415 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 416 | struct conexant_spec *spec = codec->spec; |
| 417 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 418 | |
| 419 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 424 | struct snd_ctl_elem_value *ucontrol) |
| 425 | { |
| 426 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 427 | struct conexant_spec *spec = codec->spec; |
| 428 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 429 | |
| 430 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
| 431 | spec->capsrc_nids[adc_idx], |
| 432 | &spec->cur_mux[adc_idx]); |
| 433 | } |
| 434 | |
Takashi Iwai | 4d7fbdb | 2011-07-26 10:33:10 +0200 | [diff] [blame] | 435 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, |
| 436 | unsigned int power_state) |
| 437 | { |
| 438 | if (power_state == AC_PWRST_D3) |
| 439 | msleep(100); |
| 440 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, |
| 441 | power_state); |
| 442 | /* partial workaround for "azx_get_response timeout" */ |
| 443 | if (power_state == AC_PWRST_D0) |
| 444 | msleep(10); |
Takashi Iwai | 9419ab6 | 2013-01-24 17:23:35 +0100 | [diff] [blame] | 445 | snd_hda_codec_set_power_to_all(codec, fg, power_state); |
Takashi Iwai | 4d7fbdb | 2011-07-26 10:33:10 +0200 | [diff] [blame] | 446 | } |
| 447 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 448 | static int conexant_init(struct hda_codec *codec) |
| 449 | { |
| 450 | struct conexant_spec *spec = codec->spec; |
| 451 | int i; |
| 452 | |
| 453 | for (i = 0; i < spec->num_init_verbs; i++) |
| 454 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | static void conexant_free(struct hda_codec *codec) |
| 459 | { |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 460 | struct conexant_spec *spec = codec->spec; |
Einar Rünkaru | c0f8faf | 2009-12-16 22:41:36 +0200 | [diff] [blame] | 461 | snd_hda_detach_beep_device(codec); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 462 | kfree(spec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 463 | } |
| 464 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 465 | static const struct snd_kcontrol_new cxt_capture_mixers[] = { |
Takashi Iwai | b880c74 | 2009-03-10 14:41:05 +0100 | [diff] [blame] | 466 | { |
| 467 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 468 | .name = "Capture Source", |
| 469 | .info = conexant_mux_enum_info, |
| 470 | .get = conexant_mux_enum_get, |
| 471 | .put = conexant_mux_enum_put |
| 472 | }, |
| 473 | {} |
| 474 | }; |
| 475 | |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 476 | static const char * const slave_pfxs[] = { |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 477 | "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 478 | NULL |
| 479 | }; |
| 480 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 481 | static int conexant_build_controls(struct hda_codec *codec) |
| 482 | { |
| 483 | struct conexant_spec *spec = codec->spec; |
| 484 | unsigned int i; |
| 485 | int err; |
| 486 | |
| 487 | for (i = 0; i < spec->num_mixers; i++) { |
| 488 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 489 | if (err < 0) |
| 490 | return err; |
| 491 | } |
| 492 | if (spec->multiout.dig_out_nid) { |
| 493 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 494 | spec->multiout.dig_out_nid, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 495 | spec->multiout.dig_out_nid); |
| 496 | if (err < 0) |
| 497 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 498 | err = snd_hda_create_spdif_share_sw(codec, |
| 499 | &spec->multiout); |
| 500 | if (err < 0) |
| 501 | return err; |
| 502 | spec->multiout.share_spdif = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 503 | } |
| 504 | if (spec->dig_in_nid) { |
| 505 | err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); |
| 506 | if (err < 0) |
| 507 | return err; |
| 508 | } |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 509 | |
| 510 | /* if we have no master control, let's create it */ |
| 511 | if (spec->vmaster_nid && |
| 512 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
| 513 | unsigned int vmaster_tlv[4]; |
| 514 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
| 515 | HDA_OUTPUT, vmaster_tlv); |
| 516 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 517 | vmaster_tlv, slave_pfxs, |
| 518 | "Playback Volume"); |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 519 | if (err < 0) |
| 520 | return err; |
| 521 | } |
| 522 | if (spec->vmaster_nid && |
| 523 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 524 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 525 | NULL, slave_pfxs, |
| 526 | "Playback Switch"); |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 527 | if (err < 0) |
| 528 | return err; |
| 529 | } |
| 530 | |
Takashi Iwai | b880c74 | 2009-03-10 14:41:05 +0100 | [diff] [blame] | 531 | if (spec->input_mux) { |
| 532 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); |
| 533 | if (err < 0) |
| 534 | return err; |
| 535 | } |
| 536 | |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 537 | err = add_beep_ctls(codec); |
| 538 | if (err < 0) |
| 539 | return err; |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 540 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 541 | return 0; |
| 542 | } |
| 543 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 544 | static const struct hda_codec_ops conexant_patch_ops = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 545 | .build_controls = conexant_build_controls, |
| 546 | .build_pcms = conexant_build_pcms, |
| 547 | .init = conexant_init, |
| 548 | .free = conexant_free, |
Takashi Iwai | 4d7fbdb | 2011-07-26 10:33:10 +0200 | [diff] [blame] | 549 | .set_power_state = conexant_set_power, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 550 | }; |
| 551 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 552 | static int patch_conexant_auto(struct hda_codec *codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 553 | /* |
| 554 | * EAPD control |
| 555 | * the private value = nid | (invert << 8) |
| 556 | */ |
| 557 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 558 | #define cxt_eapd_info snd_ctl_boolean_mono_info |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 559 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 560 | static int cxt_eapd_get(struct snd_kcontrol *kcontrol, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 561 | struct snd_ctl_elem_value *ucontrol) |
| 562 | { |
| 563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 564 | struct conexant_spec *spec = codec->spec; |
| 565 | int invert = (kcontrol->private_value >> 8) & 1; |
| 566 | if (invert) |
| 567 | ucontrol->value.integer.value[0] = !spec->cur_eapd; |
| 568 | else |
| 569 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 570 | return 0; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 571 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 572 | } |
| 573 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 574 | static int cxt_eapd_put(struct snd_kcontrol *kcontrol, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 575 | struct snd_ctl_elem_value *ucontrol) |
| 576 | { |
| 577 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 578 | struct conexant_spec *spec = codec->spec; |
| 579 | int invert = (kcontrol->private_value >> 8) & 1; |
| 580 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 581 | unsigned int eapd; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 582 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 583 | eapd = !!ucontrol->value.integer.value[0]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 584 | if (invert) |
| 585 | eapd = !eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 586 | if (eapd == spec->cur_eapd) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 587 | return 0; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 588 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 589 | spec->cur_eapd = eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 590 | snd_hda_codec_write_cache(codec, nid, |
| 591 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 592 | eapd ? 0x02 : 0x00); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 593 | return 1; |
| 594 | } |
| 595 | |
Takashi Iwai | 86d72bd | 2006-11-28 11:33:10 +0100 | [diff] [blame] | 596 | /* controls for test mode */ |
| 597 | #ifdef CONFIG_SND_DEBUG |
| 598 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 599 | #define CXT_EAPD_SWITCH(xname, nid, mask) \ |
| 600 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 601 | .info = cxt_eapd_info, \ |
| 602 | .get = cxt_eapd_get, \ |
| 603 | .put = cxt_eapd_put, \ |
| 604 | .private_value = nid | (mask<<16) } |
| 605 | |
| 606 | |
| 607 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 608 | static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 609 | struct snd_ctl_elem_info *uinfo) |
| 610 | { |
| 611 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 612 | struct conexant_spec *spec = codec->spec; |
| 613 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 614 | spec->num_channel_mode); |
| 615 | } |
| 616 | |
| 617 | static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 618 | struct snd_ctl_elem_value *ucontrol) |
| 619 | { |
| 620 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 621 | struct conexant_spec *spec = codec->spec; |
| 622 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 623 | spec->num_channel_mode, |
| 624 | spec->multiout.max_channels); |
| 625 | } |
| 626 | |
| 627 | static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 628 | struct snd_ctl_elem_value *ucontrol) |
| 629 | { |
| 630 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 631 | struct conexant_spec *spec = codec->spec; |
| 632 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 633 | spec->num_channel_mode, |
| 634 | &spec->multiout.max_channels); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 635 | return err; |
| 636 | } |
| 637 | |
| 638 | #define CXT_PIN_MODE(xname, nid, dir) \ |
| 639 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 640 | .info = conexant_ch_mode_info, \ |
| 641 | .get = conexant_ch_mode_get, \ |
| 642 | .put = conexant_ch_mode_put, \ |
| 643 | .private_value = nid | (dir<<16) } |
| 644 | |
Takashi Iwai | 86d72bd | 2006-11-28 11:33:10 +0100 | [diff] [blame] | 645 | #endif /* CONFIG_SND_DEBUG */ |
| 646 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 647 | /* Conexant 5045 specific */ |
| 648 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 649 | static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; |
| 650 | static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; |
| 651 | static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 652 | #define CXT5045_SPDIF_OUT 0x18 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 653 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 654 | static const struct hda_channel_mode cxt5045_modes[1] = { |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 655 | { 2, NULL }, |
| 656 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 657 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 658 | static const struct hda_input_mux cxt5045_capture_source = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 659 | .num_items = 2, |
| 660 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 661 | { "Internal Mic", 0x1 }, |
| 662 | { "Mic", 0x2 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 663 | } |
| 664 | }; |
| 665 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 666 | static const struct hda_input_mux cxt5045_capture_source_benq = { |
Michael Karcher | e6e03da | 2012-04-06 15:34:18 +0200 | [diff] [blame] | 667 | .num_items = 4, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 668 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 669 | { "Internal Mic", 0x1 }, |
| 670 | { "Mic", 0x2 }, |
| 671 | { "Line", 0x3 }, |
| 672 | { "Mixer", 0x0 }, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 673 | } |
| 674 | }; |
| 675 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 676 | static const struct hda_input_mux cxt5045_capture_source_hp530 = { |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 677 | .num_items = 2, |
| 678 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 679 | { "Mic", 0x1 }, |
| 680 | { "Internal Mic", 0x2 }, |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 681 | } |
| 682 | }; |
| 683 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 684 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 685 | static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 686 | struct snd_ctl_elem_value *ucontrol) |
| 687 | { |
| 688 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 689 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 690 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 691 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 692 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 693 | return 0; |
| 694 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 695 | /* toggle internal speakers mute depending of presence of |
| 696 | * the headphone jack |
| 697 | */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 698 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
| 699 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
| 700 | HDA_AMP_MUTE, bits); |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 701 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 702 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
| 703 | snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, |
| 704 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 705 | return 1; |
| 706 | } |
| 707 | |
| 708 | /* bind volumes of both NID 0x10 and 0x11 */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 709 | static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 710 | .ops = &snd_hda_bind_vol, |
| 711 | .values = { |
| 712 | HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), |
| 713 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), |
| 714 | 0 |
| 715 | }, |
| 716 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 717 | |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 718 | /* toggle input of built-in and mic jack appropriately */ |
| 719 | static void cxt5045_hp_automic(struct hda_codec *codec) |
| 720 | { |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 721 | static const struct hda_verb mic_jack_on[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 722 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 723 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 724 | {} |
| 725 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 726 | static const struct hda_verb mic_jack_off[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 727 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 728 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 729 | {} |
| 730 | }; |
| 731 | unsigned int present; |
| 732 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 733 | present = snd_hda_jack_detect(codec, 0x12); |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 734 | if (present) |
| 735 | snd_hda_sequence_write(codec, mic_jack_on); |
| 736 | else |
| 737 | snd_hda_sequence_write(codec, mic_jack_off); |
| 738 | } |
| 739 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 740 | |
| 741 | /* mute internal speaker if HP is plugged */ |
| 742 | static void cxt5045_hp_automute(struct hda_codec *codec) |
| 743 | { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 744 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 745 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 746 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 747 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 748 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 749 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
| 750 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
| 751 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | /* unsolicited event for HP jack sensing */ |
| 755 | static void cxt5045_hp_unsol_event(struct hda_codec *codec, |
| 756 | unsigned int res) |
| 757 | { |
| 758 | res >>= 26; |
| 759 | switch (res) { |
| 760 | case CONEXANT_HP_EVENT: |
| 761 | cxt5045_hp_automute(codec); |
| 762 | break; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 763 | case CONEXANT_MIC_EVENT: |
| 764 | cxt5045_hp_automic(codec); |
| 765 | break; |
| 766 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 770 | static const struct snd_kcontrol_new cxt5045_mixers[] = { |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 771 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), |
| 772 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Takashi Iwai | c8229c3 | 2007-10-19 08:06:21 +0200 | [diff] [blame] | 773 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
| 774 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 775 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
| 776 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 777 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
| 778 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 779 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 780 | { |
| 781 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 782 | .name = "Master Playback Switch", |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 783 | .info = cxt_eapd_info, |
| 784 | .get = cxt_eapd_get, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 785 | .put = cxt5045_hp_master_sw_put, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 786 | .private_value = 0x10, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 787 | }, |
| 788 | |
| 789 | {} |
| 790 | }; |
| 791 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 792 | static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 793 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), |
| 794 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), |
Lukasz Marcinowski | 22e1413 | 2009-09-22 21:42:40 +0200 | [diff] [blame] | 795 | |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 796 | {} |
| 797 | }; |
| 798 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 799 | static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 800 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), |
| 801 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 802 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
| 803 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 804 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
| 805 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 806 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
| 807 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 808 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
| 809 | { |
| 810 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 811 | .name = "Master Playback Switch", |
| 812 | .info = cxt_eapd_info, |
| 813 | .get = cxt_eapd_get, |
| 814 | .put = cxt5045_hp_master_sw_put, |
| 815 | .private_value = 0x10, |
| 816 | }, |
| 817 | |
| 818 | {} |
| 819 | }; |
| 820 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 821 | static const struct hda_verb cxt5045_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 822 | /* Line in, Mic */ |
Takashi Iwai | 4090dff | 2008-07-12 12:02:45 +0200 | [diff] [blame] | 823 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 824 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 825 | /* HP, Amp */ |
Takashi Iwai | c8229c3 | 2007-10-19 08:06:21 +0200 | [diff] [blame] | 826 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 827 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 828 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 829 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 830 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 831 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 832 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 833 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 834 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 835 | /* Record selector: Internal mic */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 836 | {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 837 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 838 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 839 | /* SPDIF route: PCM */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 840 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 841 | { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 842 | /* EAPD */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 843 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 844 | { } /* end */ |
| 845 | }; |
| 846 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 847 | static const struct hda_verb cxt5045_benq_init_verbs[] = { |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 848 | /* Internal Mic, Mic */ |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 849 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
| 850 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
| 851 | /* Line In,HP, Amp */ |
| 852 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 853 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 854 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 855 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 856 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 857 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 858 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 859 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 860 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 861 | /* Record selector: Internal mic */ |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 862 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 863 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
| 864 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 865 | /* SPDIF route: PCM */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 866 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 867 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 868 | /* EAPD */ |
| 869 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 870 | { } /* end */ |
| 871 | }; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 872 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 873 | static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 874 | /* pin sensing on HP jack */ |
| 875 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
Takashi Iwai | d3091fa | 2007-03-28 15:11:53 +0200 | [diff] [blame] | 876 | { } /* end */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 877 | }; |
| 878 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 879 | static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 880 | /* pin sensing on HP jack */ |
| 881 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
Takashi Iwai | d3091fa | 2007-03-28 15:11:53 +0200 | [diff] [blame] | 882 | { } /* end */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 883 | }; |
| 884 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 885 | #ifdef CONFIG_SND_DEBUG |
| 886 | /* Test configuration for debugging, modelled after the ALC260 test |
| 887 | * configuration. |
| 888 | */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 889 | static const struct hda_input_mux cxt5045_test_capture_source = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 890 | .num_items = 5, |
| 891 | .items = { |
| 892 | { "MIXER", 0x0 }, |
| 893 | { "MIC1 pin", 0x1 }, |
| 894 | { "LINE1 pin", 0x2 }, |
| 895 | { "HP-OUT pin", 0x3 }, |
| 896 | { "CD pin", 0x4 }, |
| 897 | }, |
| 898 | }; |
| 899 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 900 | static const struct snd_kcontrol_new cxt5045_test_mixer[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 901 | |
| 902 | /* Output controls */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 903 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 904 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 905 | HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 906 | HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 907 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 908 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 909 | |
| 910 | /* Modes for retasking pin widgets */ |
| 911 | CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), |
| 912 | CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), |
| 913 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 914 | /* EAPD Switch Control */ |
| 915 | CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), |
| 916 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 917 | /* Loopback mixer controls */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 918 | |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 919 | HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), |
| 920 | HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), |
| 921 | HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), |
| 922 | HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), |
| 923 | HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), |
| 924 | HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), |
| 925 | HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), |
| 926 | HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), |
| 927 | HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), |
| 928 | HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 929 | { |
| 930 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 931 | .name = "Input Source", |
| 932 | .info = conexant_mux_enum_info, |
| 933 | .get = conexant_mux_enum_get, |
| 934 | .put = conexant_mux_enum_put, |
| 935 | }, |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 936 | /* Audio input controls */ |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 937 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), |
| 938 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 939 | { } /* end */ |
| 940 | }; |
| 941 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 942 | static const struct hda_verb cxt5045_test_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 943 | /* Set connections */ |
| 944 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
| 945 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
| 946 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 947 | /* Enable retasking pins as output, initially without power amp */ |
| 948 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 949 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 950 | |
| 951 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 952 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 953 | * payload also sets the generation to 0, output to be in "consumer" |
| 954 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 955 | * control. |
| 956 | */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 957 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 958 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 959 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 960 | /* Unmute retasking pin widget output buffers since the default |
| 961 | * state appears to be output. As the pin mode is changed by the |
| 962 | * user the pin mode control will take care of enabling the pin's |
| 963 | * input/output buffers as needed. |
| 964 | */ |
| 965 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 966 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 967 | |
| 968 | /* Mute capture amp left and right */ |
| 969 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 970 | |
| 971 | /* Set ADC connection select to match default mixer setting (mic1 |
| 972 | * pin) |
| 973 | */ |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 974 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 975 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 976 | |
| 977 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 978 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 979 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ |
| 980 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ |
| 981 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ |
| 982 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 983 | |
| 984 | { } |
| 985 | }; |
| 986 | #endif |
| 987 | |
| 988 | |
| 989 | /* initialize jack-sensing, too */ |
| 990 | static int cxt5045_init(struct hda_codec *codec) |
| 991 | { |
| 992 | conexant_init(codec); |
| 993 | cxt5045_hp_automute(codec); |
| 994 | return 0; |
| 995 | } |
| 996 | |
| 997 | |
| 998 | enum { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 999 | CXT5045_LAPTOP_HPSENSE, |
| 1000 | CXT5045_LAPTOP_MICSENSE, |
| 1001 | CXT5045_LAPTOP_HPMICSENSE, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1002 | CXT5045_BENQ, |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1003 | CXT5045_LAPTOP_HP530, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1004 | #ifdef CONFIG_SND_DEBUG |
| 1005 | CXT5045_TEST, |
| 1006 | #endif |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1007 | CXT5045_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1008 | CXT5045_MODELS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1009 | }; |
| 1010 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1011 | static const char * const cxt5045_models[CXT5045_MODELS] = { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1012 | [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", |
| 1013 | [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", |
| 1014 | [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", |
| 1015 | [CXT5045_BENQ] = "benq", |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1016 | [CXT5045_LAPTOP_HP530] = "laptop-hp530", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1017 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1018 | [CXT5045_TEST] = "test", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1019 | #endif |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1020 | [CXT5045_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1021 | }; |
| 1022 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1023 | static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1024 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), |
Takashi Iwai | 6a9dccd | 2008-07-01 14:52:05 +0200 | [diff] [blame] | 1025 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1026 | SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1027 | SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), |
| 1028 | SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), |
Takashi Iwai | 9e46415 | 2008-07-12 12:05:25 +0200 | [diff] [blame] | 1029 | SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", |
| 1030 | CXT5045_LAPTOP_HPMICSENSE), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1031 | SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
| 1032 | SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
| 1033 | SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1034 | SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", |
| 1035 | CXT5045_LAPTOP_HPMICSENSE), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1036 | SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1037 | {} |
| 1038 | }; |
| 1039 | |
| 1040 | static int patch_cxt5045(struct hda_codec *codec) |
| 1041 | { |
| 1042 | struct conexant_spec *spec; |
| 1043 | int board_config; |
| 1044 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1045 | board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, |
| 1046 | cxt5045_models, |
| 1047 | cxt5045_cfg_tbl); |
| 1048 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1049 | board_config = CXT5045_AUTO; /* model=auto as default */ |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1050 | if (board_config == CXT5045_AUTO) |
| 1051 | return patch_conexant_auto(codec); |
| 1052 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1053 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1054 | if (!spec) |
| 1055 | return -ENOMEM; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1056 | codec->spec = spec; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 1057 | codec->single_adc_amp = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1058 | |
| 1059 | spec->multiout.max_channels = 2; |
| 1060 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); |
| 1061 | spec->multiout.dac_nids = cxt5045_dac_nids; |
| 1062 | spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; |
| 1063 | spec->num_adc_nids = 1; |
| 1064 | spec->adc_nids = cxt5045_adc_nids; |
| 1065 | spec->capsrc_nids = cxt5045_capsrc_nids; |
| 1066 | spec->input_mux = &cxt5045_capture_source; |
| 1067 | spec->num_mixers = 1; |
| 1068 | spec->mixers[0] = cxt5045_mixers; |
| 1069 | spec->num_init_verbs = 1; |
| 1070 | spec->init_verbs[0] = cxt5045_init_verbs; |
| 1071 | spec->spdif_route = 0; |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1072 | spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); |
| 1073 | spec->channel_mode = cxt5045_modes; |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1074 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1075 | set_beep_amp(spec, 0x16, 0, 1); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1076 | |
| 1077 | codec->patch_ops = conexant_patch_ops; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1078 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1079 | switch (board_config) { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1080 | case CXT5045_LAPTOP_HPSENSE: |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1081 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1082 | spec->input_mux = &cxt5045_capture_source; |
| 1083 | spec->num_init_verbs = 2; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1084 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1085 | spec->mixers[0] = cxt5045_mixers; |
| 1086 | codec->patch_ops.init = cxt5045_init; |
| 1087 | break; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1088 | case CXT5045_LAPTOP_MICSENSE: |
Takashi Iwai | 86376df | 2008-07-12 12:04:05 +0200 | [diff] [blame] | 1089 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1090 | spec->input_mux = &cxt5045_capture_source; |
| 1091 | spec->num_init_verbs = 2; |
| 1092 | spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1093 | spec->mixers[0] = cxt5045_mixers; |
| 1094 | codec->patch_ops.init = cxt5045_init; |
| 1095 | break; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1096 | default: |
| 1097 | case CXT5045_LAPTOP_HPMICSENSE: |
| 1098 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1099 | spec->input_mux = &cxt5045_capture_source; |
| 1100 | spec->num_init_verbs = 3; |
| 1101 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1102 | spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; |
| 1103 | spec->mixers[0] = cxt5045_mixers; |
| 1104 | codec->patch_ops.init = cxt5045_init; |
| 1105 | break; |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1106 | case CXT5045_BENQ: |
| 1107 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1108 | spec->input_mux = &cxt5045_capture_source_benq; |
| 1109 | spec->num_init_verbs = 1; |
| 1110 | spec->init_verbs[0] = cxt5045_benq_init_verbs; |
| 1111 | spec->mixers[0] = cxt5045_mixers; |
| 1112 | spec->mixers[1] = cxt5045_benq_mixers; |
| 1113 | spec->num_mixers = 2; |
| 1114 | codec->patch_ops.init = cxt5045_init; |
| 1115 | break; |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1116 | case CXT5045_LAPTOP_HP530: |
| 1117 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1118 | spec->input_mux = &cxt5045_capture_source_hp530; |
| 1119 | spec->num_init_verbs = 2; |
| 1120 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1121 | spec->mixers[0] = cxt5045_mixers_hp530; |
| 1122 | codec->patch_ops.init = cxt5045_init; |
| 1123 | break; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1124 | #ifdef CONFIG_SND_DEBUG |
| 1125 | case CXT5045_TEST: |
| 1126 | spec->input_mux = &cxt5045_test_capture_source; |
| 1127 | spec->mixers[0] = cxt5045_test_mixer; |
| 1128 | spec->init_verbs[0] = cxt5045_test_init_verbs; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1129 | break; |
| 1130 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1131 | #endif |
| 1132 | } |
Takashi Iwai | 48ecb7e | 2007-12-17 14:32:49 +0100 | [diff] [blame] | 1133 | |
Takashi Iwai | 031005f | 2008-06-26 14:49:58 +0200 | [diff] [blame] | 1134 | switch (codec->subsystem_id >> 16) { |
| 1135 | case 0x103c: |
Daniel T Chen | 8f0f5ff | 2010-04-28 18:00:11 -0400 | [diff] [blame] | 1136 | case 0x1631: |
Daniel T Chen | 0b587fc | 2009-11-25 18:27:20 -0500 | [diff] [blame] | 1137 | case 0x1734: |
Daniel T Chen | 0ebf9e3 | 2010-05-10 21:50:04 +0200 | [diff] [blame] | 1138 | case 0x17aa: |
| 1139 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have |
| 1140 | * really bad sound over 0dB on NID 0x17. Fix max PCM level to |
| 1141 | * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) |
Takashi Iwai | 031005f | 2008-06-26 14:49:58 +0200 | [diff] [blame] | 1142 | */ |
| 1143 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, |
| 1144 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1145 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1146 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1147 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 1148 | break; |
| 1149 | } |
Takashi Iwai | 48ecb7e | 2007-12-17 14:32:49 +0100 | [diff] [blame] | 1150 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1151 | if (spec->beep_amp) |
Takashi Iwai | a86b1a2c | 2013-03-18 11:00:44 +0100 | [diff] [blame] | 1152 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1153 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1154 | return 0; |
| 1155 | } |
| 1156 | |
| 1157 | |
| 1158 | /* Conexant 5047 specific */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1159 | #define CXT5047_SPDIF_OUT 0x11 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1160 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1161 | static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ |
| 1162 | static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; |
| 1163 | static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1164 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1165 | static const struct hda_channel_mode cxt5047_modes[1] = { |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1166 | { 2, NULL }, |
| 1167 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1168 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1169 | static const struct hda_input_mux cxt5047_toshiba_capture_source = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1170 | .num_items = 2, |
| 1171 | .items = { |
| 1172 | { "ExtMic", 0x2 }, |
| 1173 | { "Line-In", 0x1 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1174 | } |
| 1175 | }; |
| 1176 | |
| 1177 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1178 | static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1179 | struct snd_ctl_elem_value *ucontrol) |
| 1180 | { |
| 1181 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1182 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1183 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1184 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1185 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1186 | return 0; |
| 1187 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1188 | /* toggle internal speakers mute depending of presence of |
| 1189 | * the headphone jack |
| 1190 | */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1191 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1192 | /* NOTE: Conexat codec needs the index for *OUTPUT* amp of |
| 1193 | * pin widgets unlike other codecs. In this case, we need to |
| 1194 | * set index 0x01 for the volume from the mixer amp 0x19. |
| 1195 | */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1196 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1197 | HDA_AMP_MUTE, bits); |
| 1198 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
| 1199 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, |
| 1200 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1201 | return 1; |
| 1202 | } |
| 1203 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1204 | /* mute internal speaker if HP is plugged */ |
| 1205 | static void cxt5047_hp_automute(struct hda_codec *codec) |
| 1206 | { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1207 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 1208 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1209 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1210 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 1211 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1212 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1213 | /* See the note in cxt5047_hp_master_sw_put */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1214 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1215 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | /* toggle input of built-in and mic jack appropriately */ |
| 1219 | static void cxt5047_hp_automic(struct hda_codec *codec) |
| 1220 | { |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1221 | static const struct hda_verb mic_jack_on[] = { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1222 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1223 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1224 | {} |
| 1225 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1226 | static const struct hda_verb mic_jack_off[] = { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1227 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1228 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1229 | {} |
| 1230 | }; |
| 1231 | unsigned int present; |
| 1232 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1233 | present = snd_hda_jack_detect(codec, 0x15); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1234 | if (present) |
| 1235 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1236 | else |
| 1237 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1238 | } |
| 1239 | |
| 1240 | /* unsolicited event for HP jack sensing */ |
| 1241 | static void cxt5047_hp_unsol_event(struct hda_codec *codec, |
| 1242 | unsigned int res) |
| 1243 | { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1244 | switch (res >> 26) { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1245 | case CONEXANT_HP_EVENT: |
| 1246 | cxt5047_hp_automute(codec); |
| 1247 | break; |
| 1248 | case CONEXANT_MIC_EVENT: |
| 1249 | cxt5047_hp_automic(codec); |
| 1250 | break; |
| 1251 | } |
| 1252 | } |
| 1253 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1254 | static const struct snd_kcontrol_new cxt5047_base_mixers[] = { |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1255 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), |
| 1256 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1257 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1258 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
| 1259 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), |
| 1260 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), |
| 1261 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1262 | { |
| 1263 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1264 | .name = "Master Playback Switch", |
| 1265 | .info = cxt_eapd_info, |
| 1266 | .get = cxt_eapd_get, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1267 | .put = cxt5047_hp_master_sw_put, |
| 1268 | .private_value = 0x13, |
| 1269 | }, |
| 1270 | |
| 1271 | {} |
| 1272 | }; |
| 1273 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1274 | static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1275 | /* See the note in cxt5047_hp_master_sw_put */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1276 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1277 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
| 1278 | {} |
| 1279 | }; |
| 1280 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1281 | static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1282 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1283 | { } /* end */ |
| 1284 | }; |
| 1285 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1286 | static const struct hda_verb cxt5047_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1287 | /* Line in, Mic, Built-in Mic */ |
| 1288 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1289 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, |
| 1290 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1291 | /* HP, Speaker */ |
Tobin Davis | b7589ce | 2007-04-24 17:56:55 +0200 | [diff] [blame] | 1292 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
Takashi Iwai | 5b3a744 | 2009-03-10 15:10:55 +0100 | [diff] [blame] | 1293 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ |
| 1294 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1295 | /* Record selector: Mic */ |
| 1296 | {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, |
| 1297 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1298 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 1299 | {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1300 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1301 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, |
| 1302 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1303 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1304 | /* SPDIF route: PCM */ |
| 1305 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1306 | /* Enable unsolicited events */ |
| 1307 | {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 1308 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1309 | { } /* end */ |
| 1310 | }; |
| 1311 | |
| 1312 | /* configuration for Toshiba Laptops */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1313 | static const struct hda_verb cxt5047_toshiba_init_verbs[] = { |
Takashi Iwai | 3b62886 | 2009-03-10 14:53:54 +0100 | [diff] [blame] | 1314 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1315 | {} |
| 1316 | }; |
| 1317 | |
| 1318 | /* Test configuration for debugging, modelled after the ALC260 test |
| 1319 | * configuration. |
| 1320 | */ |
| 1321 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1322 | static const struct hda_input_mux cxt5047_test_capture_source = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1323 | .num_items = 4, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1324 | .items = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1325 | { "LINE1 pin", 0x0 }, |
| 1326 | { "MIC1 pin", 0x1 }, |
| 1327 | { "MIC2 pin", 0x2 }, |
| 1328 | { "CD pin", 0x3 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1329 | }, |
| 1330 | }; |
| 1331 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1332 | static const struct snd_kcontrol_new cxt5047_test_mixer[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1333 | |
| 1334 | /* Output only controls */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1335 | HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1336 | HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), |
| 1337 | HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1338 | HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1339 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1340 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1341 | HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1342 | HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1343 | HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), |
| 1344 | HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 1345 | HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1346 | HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1347 | |
| 1348 | /* Modes for retasking pin widgets */ |
| 1349 | CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), |
| 1350 | CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), |
| 1351 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1352 | /* EAPD Switch Control */ |
| 1353 | CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), |
| 1354 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1355 | /* Loopback mixer controls */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1356 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), |
| 1357 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), |
| 1358 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), |
| 1359 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), |
| 1360 | HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), |
| 1361 | HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), |
| 1362 | HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), |
| 1363 | HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1364 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1365 | HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), |
| 1366 | HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), |
| 1367 | HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), |
| 1368 | HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), |
| 1369 | HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), |
| 1370 | HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), |
| 1371 | HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), |
| 1372 | HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1373 | { |
| 1374 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1375 | .name = "Input Source", |
| 1376 | .info = conexant_mux_enum_info, |
| 1377 | .get = conexant_mux_enum_get, |
| 1378 | .put = conexant_mux_enum_put, |
| 1379 | }, |
Takashi Iwai | 854206b | 2009-11-30 18:22:04 +0100 | [diff] [blame] | 1380 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1381 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1382 | { } /* end */ |
| 1383 | }; |
| 1384 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1385 | static const struct hda_verb cxt5047_test_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1386 | /* Enable retasking pins as output, initially without power amp */ |
| 1387 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1388 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1389 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1390 | |
| 1391 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 1392 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 1393 | * payload also sets the generation to 0, output to be in "consumer" |
| 1394 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 1395 | * control. |
| 1396 | */ |
| 1397 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 1398 | |
| 1399 | /* Ensure mic1, mic2, line1 pin widgets take input from the |
| 1400 | * OUT1 sum bus when acting as an output. |
| 1401 | */ |
| 1402 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, |
| 1403 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 1404 | |
| 1405 | /* Start with output sum widgets muted and their output gains at min */ |
| 1406 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1407 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1408 | |
| 1409 | /* Unmute retasking pin widget output buffers since the default |
| 1410 | * state appears to be output. As the pin mode is changed by the |
| 1411 | * user the pin mode control will take care of enabling the pin's |
| 1412 | * input/output buffers as needed. |
| 1413 | */ |
| 1414 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1415 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1416 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1417 | |
| 1418 | /* Mute capture amp left and right */ |
| 1419 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1420 | |
| 1421 | /* Set ADC connection select to match default mixer setting (mic1 |
| 1422 | * pin) |
| 1423 | */ |
| 1424 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1425 | |
| 1426 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 1427 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 1428 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 1429 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 1430 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 1431 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 1432 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 1433 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 1434 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 1435 | |
| 1436 | { } |
| 1437 | }; |
| 1438 | #endif |
| 1439 | |
| 1440 | |
| 1441 | /* initialize jack-sensing, too */ |
| 1442 | static int cxt5047_hp_init(struct hda_codec *codec) |
| 1443 | { |
| 1444 | conexant_init(codec); |
| 1445 | cxt5047_hp_automute(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1446 | return 0; |
| 1447 | } |
| 1448 | |
| 1449 | |
| 1450 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1451 | CXT5047_LAPTOP, /* Laptops w/o EAPD support */ |
| 1452 | CXT5047_LAPTOP_HP, /* Some HP laptops */ |
| 1453 | CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1454 | #ifdef CONFIG_SND_DEBUG |
| 1455 | CXT5047_TEST, |
| 1456 | #endif |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1457 | CXT5047_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1458 | CXT5047_MODELS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1459 | }; |
| 1460 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1461 | static const char * const cxt5047_models[CXT5047_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1462 | [CXT5047_LAPTOP] = "laptop", |
| 1463 | [CXT5047_LAPTOP_HP] = "laptop-hp", |
| 1464 | [CXT5047_LAPTOP_EAPD] = "laptop-eapd", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1465 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1466 | [CXT5047_TEST] = "test", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1467 | #endif |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1468 | [CXT5047_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1469 | }; |
| 1470 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1471 | static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1472 | SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1473 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
| 1474 | CXT5047_LAPTOP), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1475 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1476 | {} |
| 1477 | }; |
| 1478 | |
| 1479 | static int patch_cxt5047(struct hda_codec *codec) |
| 1480 | { |
| 1481 | struct conexant_spec *spec; |
| 1482 | int board_config; |
| 1483 | |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1484 | board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, |
| 1485 | cxt5047_models, |
| 1486 | cxt5047_cfg_tbl); |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1487 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1488 | board_config = CXT5047_AUTO; /* model=auto as default */ |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1489 | if (board_config == CXT5047_AUTO) |
| 1490 | return patch_conexant_auto(codec); |
| 1491 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1492 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1493 | if (!spec) |
| 1494 | return -ENOMEM; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1495 | codec->spec = spec; |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 1496 | codec->pin_amp_workaround = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1497 | |
| 1498 | spec->multiout.max_channels = 2; |
| 1499 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); |
| 1500 | spec->multiout.dac_nids = cxt5047_dac_nids; |
| 1501 | spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; |
| 1502 | spec->num_adc_nids = 1; |
| 1503 | spec->adc_nids = cxt5047_adc_nids; |
| 1504 | spec->capsrc_nids = cxt5047_capsrc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1505 | spec->num_mixers = 1; |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1506 | spec->mixers[0] = cxt5047_base_mixers; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1507 | spec->num_init_verbs = 1; |
| 1508 | spec->init_verbs[0] = cxt5047_init_verbs; |
| 1509 | spec->spdif_route = 0; |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1510 | spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), |
| 1511 | spec->channel_mode = cxt5047_modes, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1512 | |
| 1513 | codec->patch_ops = conexant_patch_ops; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1514 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1515 | switch (board_config) { |
| 1516 | case CXT5047_LAPTOP: |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1517 | spec->num_mixers = 2; |
| 1518 | spec->mixers[1] = cxt5047_hp_spk_mixers; |
| 1519 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1520 | break; |
| 1521 | case CXT5047_LAPTOP_HP: |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1522 | spec->num_mixers = 2; |
| 1523 | spec->mixers[1] = cxt5047_hp_only_mixers; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1524 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1525 | codec->patch_ops.init = cxt5047_hp_init; |
| 1526 | break; |
| 1527 | case CXT5047_LAPTOP_EAPD: |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1528 | spec->input_mux = &cxt5047_toshiba_capture_source; |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1529 | spec->num_mixers = 2; |
| 1530 | spec->mixers[1] = cxt5047_hp_spk_mixers; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1531 | spec->num_init_verbs = 2; |
| 1532 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1533 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1534 | break; |
| 1535 | #ifdef CONFIG_SND_DEBUG |
| 1536 | case CXT5047_TEST: |
| 1537 | spec->input_mux = &cxt5047_test_capture_source; |
| 1538 | spec->mixers[0] = cxt5047_test_mixer; |
| 1539 | spec->init_verbs[0] = cxt5047_test_init_verbs; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1540 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1541 | #endif |
| 1542 | } |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 1543 | spec->vmaster_nid = 0x13; |
Daniel T Chen | 025f206 | 2010-03-21 18:34:43 -0400 | [diff] [blame] | 1544 | |
| 1545 | switch (codec->subsystem_id >> 16) { |
| 1546 | case 0x103c: |
| 1547 | /* HP laptops have really bad sound over 0 dB on NID 0x10. |
| 1548 | * Fix max PCM level to 0 dB (originally it has 0x1e steps |
| 1549 | * with 0 dB offset 0x17) |
| 1550 | */ |
| 1551 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, |
| 1552 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1553 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1554 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1555 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 1556 | break; |
| 1557 | } |
| 1558 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1559 | return 0; |
| 1560 | } |
| 1561 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1562 | /* Conexant 5051 specific */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1563 | static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; |
| 1564 | static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1565 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1566 | static const struct hda_channel_mode cxt5051_modes[1] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1567 | { 2, NULL }, |
| 1568 | }; |
| 1569 | |
| 1570 | static void cxt5051_update_speaker(struct hda_codec *codec) |
| 1571 | { |
| 1572 | struct conexant_spec *spec = codec->spec; |
| 1573 | unsigned int pinctl; |
Takashi Iwai | 23d2df5 | 2010-01-24 11:19:27 +0100 | [diff] [blame] | 1574 | /* headphone pin */ |
| 1575 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1576 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
Takashi Iwai | 23d2df5 | 2010-01-24 11:19:27 +0100 | [diff] [blame] | 1577 | /* speaker pin */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1578 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1579 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
Justin P. Mattock | a80581d | 2012-02-11 05:55:58 -0800 | [diff] [blame] | 1580 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1581 | if (spec->ideapad) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1582 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1583 | } |
| 1584 | |
| 1585 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1586 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1587 | struct snd_ctl_elem_value *ucontrol) |
| 1588 | { |
| 1589 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1590 | |
| 1591 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 1592 | return 0; |
| 1593 | cxt5051_update_speaker(codec); |
| 1594 | return 1; |
| 1595 | } |
| 1596 | |
| 1597 | /* toggle input of built-in and mic jack appropriately */ |
| 1598 | static void cxt5051_portb_automic(struct hda_codec *codec) |
| 1599 | { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1600 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1601 | unsigned int present; |
| 1602 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1603 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1604 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1605 | present = snd_hda_jack_detect(codec, 0x17); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1606 | snd_hda_codec_write(codec, 0x14, 0, |
| 1607 | AC_VERB_SET_CONNECT_SEL, |
| 1608 | present ? 0x01 : 0x00); |
| 1609 | } |
| 1610 | |
| 1611 | /* switch the current ADC according to the jack state */ |
| 1612 | static void cxt5051_portc_automic(struct hda_codec *codec) |
| 1613 | { |
| 1614 | struct conexant_spec *spec = codec->spec; |
| 1615 | unsigned int present; |
| 1616 | hda_nid_t new_adc; |
| 1617 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1618 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1619 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1620 | present = snd_hda_jack_detect(codec, 0x18); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1621 | if (present) |
| 1622 | spec->cur_adc_idx = 1; |
| 1623 | else |
| 1624 | spec->cur_adc_idx = 0; |
| 1625 | new_adc = spec->adc_nids[spec->cur_adc_idx]; |
| 1626 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 1627 | /* stream is running, let's swap the current ADC */ |
Takashi Iwai | f0cea79 | 2010-08-13 11:56:53 +0200 | [diff] [blame] | 1628 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1629 | spec->cur_adc = new_adc; |
| 1630 | snd_hda_codec_setup_stream(codec, new_adc, |
| 1631 | spec->cur_adc_stream_tag, 0, |
| 1632 | spec->cur_adc_format); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | /* mute internal speaker if HP is plugged */ |
| 1637 | static void cxt5051_hp_automute(struct hda_codec *codec) |
| 1638 | { |
| 1639 | struct conexant_spec *spec = codec->spec; |
| 1640 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1641 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1642 | cxt5051_update_speaker(codec); |
| 1643 | } |
| 1644 | |
| 1645 | /* unsolicited event for HP jack sensing */ |
| 1646 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, |
| 1647 | unsigned int res) |
| 1648 | { |
| 1649 | switch (res >> 26) { |
| 1650 | case CONEXANT_HP_EVENT: |
| 1651 | cxt5051_hp_automute(codec); |
| 1652 | break; |
| 1653 | case CXT5051_PORTB_EVENT: |
| 1654 | cxt5051_portb_automic(codec); |
| 1655 | break; |
| 1656 | case CXT5051_PORTC_EVENT: |
| 1657 | cxt5051_portc_automic(codec); |
| 1658 | break; |
| 1659 | } |
| 1660 | } |
| 1661 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1662 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1663 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 1664 | { |
| 1665 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1666 | .name = "Master Playback Switch", |
| 1667 | .info = cxt_eapd_info, |
| 1668 | .get = cxt_eapd_get, |
| 1669 | .put = cxt5051_hp_master_sw_put, |
| 1670 | .private_value = 0x1a, |
| 1671 | }, |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1672 | {} |
| 1673 | }; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1674 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1675 | static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1676 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1677 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1678 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1679 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
David Henningsson | c40bd91 | 2012-09-19 12:19:47 +0200 | [diff] [blame] | 1680 | HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1681 | HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1682 | {} |
| 1683 | }; |
| 1684 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1685 | static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1686 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1687 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1688 | HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1689 | HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1690 | {} |
| 1691 | }; |
| 1692 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1693 | static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
Takashi Iwai | 4e4ac60 | 2010-01-23 22:29:54 +0100 | [diff] [blame] | 1694 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
| 1695 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1696 | {} |
| 1697 | }; |
| 1698 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1699 | static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1700 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
| 1701 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1702 | {} |
| 1703 | }; |
| 1704 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1705 | static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1706 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1707 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1708 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1709 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1710 | {} |
| 1711 | }; |
| 1712 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1713 | static const struct hda_verb cxt5051_init_verbs[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1714 | /* Line in, Mic */ |
| 1715 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1716 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1717 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1718 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1719 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1720 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1721 | /* SPK */ |
| 1722 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1723 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1724 | /* HP, Amp */ |
| 1725 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1726 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1727 | /* DAC1 */ |
| 1728 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1729 | /* Record selector: Internal mic */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1730 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1731 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1732 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1733 | /* SPDIF route: PCM */ |
Pierre-Louis Bossart | 1965c44 | 2010-05-06 16:37:03 -0500 | [diff] [blame] | 1734 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1735 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1736 | /* EAPD */ |
| 1737 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1738 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1739 | { } /* end */ |
| 1740 | }; |
| 1741 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1742 | static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1743 | /* Line in, Mic */ |
| 1744 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1745 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1746 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1747 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1748 | /* SPK */ |
| 1749 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1750 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1751 | /* HP, Amp */ |
| 1752 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1753 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1754 | /* DAC1 */ |
| 1755 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1756 | /* Record selector: Internal mic */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1757 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1758 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1759 | /* SPDIF route: PCM */ |
| 1760 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1761 | /* EAPD */ |
| 1762 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1763 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1764 | { } /* end */ |
| 1765 | }; |
| 1766 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1767 | static const struct hda_verb cxt5051_f700_init_verbs[] = { |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1768 | /* Line in, Mic */ |
Takashi Iwai | 30ed7ed | 2010-01-28 17:11:45 +0100 | [diff] [blame] | 1769 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1770 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1771 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1772 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1773 | /* SPK */ |
| 1774 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1775 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1776 | /* HP, Amp */ |
| 1777 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1778 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1779 | /* DAC1 */ |
| 1780 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1781 | /* Record selector: Internal mic */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1782 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1783 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1784 | /* SPDIF route: PCM */ |
| 1785 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1786 | /* EAPD */ |
| 1787 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1788 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1789 | { } /* end */ |
| 1790 | }; |
| 1791 | |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1792 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
| 1793 | unsigned int event) |
| 1794 | { |
| 1795 | snd_hda_codec_write(codec, nid, 0, |
| 1796 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1797 | AC_USRSP_EN | event); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1798 | } |
| 1799 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1800 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1801 | /* Subwoofer */ |
| 1802 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1803 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1804 | { } /* end */ |
| 1805 | }; |
| 1806 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1807 | /* initialize jack-sensing, too */ |
| 1808 | static int cxt5051_init(struct hda_codec *codec) |
| 1809 | { |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1810 | struct conexant_spec *spec = codec->spec; |
| 1811 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1812 | conexant_init(codec); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1813 | |
| 1814 | if (spec->auto_mic & AUTO_MIC_PORTB) |
| 1815 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); |
| 1816 | if (spec->auto_mic & AUTO_MIC_PORTC) |
| 1817 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); |
| 1818 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1819 | if (codec->patch_ops.unsol_event) { |
| 1820 | cxt5051_hp_automute(codec); |
| 1821 | cxt5051_portb_automic(codec); |
| 1822 | cxt5051_portc_automic(codec); |
| 1823 | } |
| 1824 | return 0; |
| 1825 | } |
| 1826 | |
| 1827 | |
| 1828 | enum { |
| 1829 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ |
| 1830 | CXT5051_HP, /* no docking */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1831 | CXT5051_HP_DV6736, /* HP without mic switch */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1832 | CXT5051_F700, /* HP Compaq Presario F700 */ |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1833 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1834 | CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1835 | CXT5051_AUTO, /* auto-parser */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1836 | CXT5051_MODELS |
| 1837 | }; |
| 1838 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1839 | static const char *const cxt5051_models[CXT5051_MODELS] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1840 | [CXT5051_LAPTOP] = "laptop", |
| 1841 | [CXT5051_HP] = "hp", |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1842 | [CXT5051_HP_DV6736] = "hp-dv6736", |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1843 | [CXT5051_F700] = "hp-700", |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1844 | [CXT5051_TOSHIBA] = "toshiba", |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1845 | [CXT5051_IDEAPAD] = "ideapad", |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1846 | [CXT5051_AUTO] = "auto", |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1847 | }; |
| 1848 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1849 | static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1850 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
Tony Vroon | 1812e67 | 2009-05-27 21:00:41 +0100 | [diff] [blame] | 1851 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1852 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1853 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1854 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 1855 | CXT5051_LAPTOP), |
| 1856 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1857 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1858 | {} |
| 1859 | }; |
| 1860 | |
| 1861 | static int patch_cxt5051(struct hda_codec *codec) |
| 1862 | { |
| 1863 | struct conexant_spec *spec; |
| 1864 | int board_config; |
| 1865 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1866 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
| 1867 | cxt5051_models, |
| 1868 | cxt5051_cfg_tbl); |
| 1869 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1870 | board_config = CXT5051_AUTO; /* model=auto as default */ |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1871 | if (board_config == CXT5051_AUTO) |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1872 | return patch_conexant_auto(codec); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1873 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1874 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1875 | if (!spec) |
| 1876 | return -ENOMEM; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1877 | codec->spec = spec; |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 1878 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1879 | |
| 1880 | codec->patch_ops = conexant_patch_ops; |
| 1881 | codec->patch_ops.init = cxt5051_init; |
| 1882 | |
| 1883 | spec->multiout.max_channels = 2; |
| 1884 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); |
| 1885 | spec->multiout.dac_nids = cxt5051_dac_nids; |
| 1886 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; |
| 1887 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ |
| 1888 | spec->adc_nids = cxt5051_adc_nids; |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1889 | spec->num_mixers = 2; |
| 1890 | spec->mixers[0] = cxt5051_capture_mixers; |
| 1891 | spec->mixers[1] = cxt5051_playback_mixers; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1892 | spec->num_init_verbs = 1; |
| 1893 | spec->init_verbs[0] = cxt5051_init_verbs; |
| 1894 | spec->spdif_route = 0; |
| 1895 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); |
| 1896 | spec->channel_mode = cxt5051_modes; |
| 1897 | spec->cur_adc = 0; |
| 1898 | spec->cur_adc_idx = 0; |
| 1899 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1900 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 1901 | |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1902 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
| 1903 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1904 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1905 | switch (board_config) { |
| 1906 | case CXT5051_HP: |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1907 | spec->mixers[0] = cxt5051_hp_mixers; |
| 1908 | break; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1909 | case CXT5051_HP_DV6736: |
| 1910 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; |
| 1911 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1912 | spec->auto_mic = 0; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1913 | break; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1914 | case CXT5051_F700: |
| 1915 | spec->init_verbs[0] = cxt5051_f700_init_verbs; |
| 1916 | spec->mixers[0] = cxt5051_f700_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1917 | spec->auto_mic = 0; |
| 1918 | break; |
| 1919 | case CXT5051_TOSHIBA: |
| 1920 | spec->mixers[0] = cxt5051_toshiba_mixers; |
| 1921 | spec->auto_mic = AUTO_MIC_PORTB; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1922 | break; |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1923 | case CXT5051_IDEAPAD: |
| 1924 | spec->init_verbs[spec->num_init_verbs++] = |
| 1925 | cxt5051_ideapad_init_verbs; |
| 1926 | spec->ideapad = 1; |
| 1927 | break; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1928 | } |
| 1929 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1930 | if (spec->beep_amp) |
Takashi Iwai | a86b1a2c | 2013-03-18 11:00:44 +0100 | [diff] [blame] | 1931 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1932 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1933 | return 0; |
| 1934 | } |
| 1935 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1936 | /* Conexant 5066 specific */ |
| 1937 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1938 | static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; |
| 1939 | static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; |
| 1940 | static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; |
| 1941 | static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1942 | |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 1943 | /* OLPC's microphone port is DC coupled for use with external sensors, |
| 1944 | * therefore we use a 50% mic bias in order to center the input signal with |
| 1945 | * the DC input range of the codec. */ |
| 1946 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 |
| 1947 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1948 | static const struct hda_channel_mode cxt5066_modes[1] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1949 | { 2, NULL }, |
| 1950 | }; |
| 1951 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1952 | #define HP_PRESENT_PORT_A (1 << 0) |
| 1953 | #define HP_PRESENT_PORT_D (1 << 1) |
| 1954 | #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) |
| 1955 | #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) |
| 1956 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1957 | static void cxt5066_update_speaker(struct hda_codec *codec) |
| 1958 | { |
| 1959 | struct conexant_spec *spec = codec->spec; |
| 1960 | unsigned int pinctl; |
| 1961 | |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 1962 | snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", |
| 1963 | spec->hp_present, spec->cur_eapd); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1964 | |
| 1965 | /* Port A (HP) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1966 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1967 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1968 | |
| 1969 | /* Port D (HP/LO) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1970 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
| 1971 | if (spec->dell_automute || spec->thinkpad) { |
| 1972 | /* Mute if Port A is connected */ |
| 1973 | if (hp_port_a_present(spec)) |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 1974 | pinctl = 0; |
| 1975 | } else { |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1976 | /* Thinkpad/Dell doesn't give pin-D status */ |
| 1977 | if (!hp_port_d_present(spec)) |
| 1978 | pinctl = 0; |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 1979 | } |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1980 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1981 | |
| 1982 | /* CLASS_D AMP */ |
| 1983 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1984 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1985 | } |
| 1986 | |
| 1987 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1988 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1989 | struct snd_ctl_elem_value *ucontrol) |
| 1990 | { |
| 1991 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1992 | |
| 1993 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 1994 | return 0; |
| 1995 | |
| 1996 | cxt5066_update_speaker(codec); |
| 1997 | return 1; |
| 1998 | } |
| 1999 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2000 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { |
| 2001 | .num_items = 3, |
| 2002 | .items = { |
| 2003 | { "Off", PIN_IN }, |
| 2004 | { "50%", PIN_VREF50 }, |
| 2005 | { "80%", PIN_VREF80 }, |
| 2006 | }, |
| 2007 | }; |
| 2008 | |
| 2009 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) |
| 2010 | { |
| 2011 | struct conexant_spec *spec = codec->spec; |
| 2012 | /* Even though port F is the DC input, the bias is controlled on port B. |
| 2013 | * we also leave that port as an active input (but unselected) in DC mode |
| 2014 | * just in case that is necessary to make the bias setting take effect. */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2015 | return snd_hda_set_pin_ctl_cache(codec, 0x1a, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2016 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); |
| 2017 | } |
| 2018 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2019 | /* OLPC defers mic widget control until when capture is started because the |
| 2020 | * microphone LED comes on as soon as these settings are put in place. if we |
| 2021 | * did this before recording, it would give the false indication that recording |
| 2022 | * is happening when it is not. */ |
| 2023 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2024 | { |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 2025 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2026 | if (!spec->recording) |
| 2027 | return; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2028 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2029 | if (spec->dc_enable) { |
| 2030 | /* in DC mode we ignore presence detection and just use the jack |
| 2031 | * through our special DC port */ |
| 2032 | const struct hda_verb enable_dc_mode[] = { |
| 2033 | /* disble internal mic, port C */ |
| 2034 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2035 | |
| 2036 | /* enable DC capture, port F */ |
| 2037 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2038 | {}, |
| 2039 | }; |
| 2040 | |
| 2041 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2042 | /* port B input disabled (and bias set) through the following call */ |
| 2043 | cxt5066_set_olpc_dc_bias(codec); |
| 2044 | return; |
| 2045 | } |
| 2046 | |
| 2047 | /* disable DC (port F) */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2048 | snd_hda_set_pin_ctl(codec, 0x1e, 0); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2049 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2050 | /* external mic, port B */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2051 | snd_hda_set_pin_ctl(codec, 0x1a, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2052 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2053 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2054 | /* internal mic, port C */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2055 | snd_hda_set_pin_ctl(codec, 0x1b, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2056 | spec->ext_mic_present ? 0 : PIN_VREF80); |
| 2057 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2058 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2059 | /* toggle input of built-in and mic jack appropriately */ |
| 2060 | static void cxt5066_olpc_automic(struct hda_codec *codec) |
| 2061 | { |
| 2062 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2063 | unsigned int present; |
| 2064 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2065 | if (spec->dc_enable) /* don't do presence detection in DC mode */ |
| 2066 | return; |
| 2067 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2068 | present = snd_hda_codec_read(codec, 0x1a, 0, |
| 2069 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 2070 | if (present) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2071 | snd_printdd("CXT5066: external microphone detected\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2072 | else |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2073 | snd_printdd("CXT5066: external microphone absent\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2074 | |
| 2075 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2076 | present ? 0 : 1); |
| 2077 | spec->ext_mic_present = !!present; |
| 2078 | |
| 2079 | cxt5066_olpc_select_mic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2080 | } |
| 2081 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2082 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2083 | static void cxt5066_vostro_automic(struct hda_codec *codec) |
| 2084 | { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2085 | unsigned int present; |
| 2086 | |
| 2087 | struct hda_verb ext_mic_present[] = { |
| 2088 | /* enable external mic, port B */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2089 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2090 | |
| 2091 | /* switch to external mic input */ |
| 2092 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2093 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2094 | |
| 2095 | /* disable internal digital mic */ |
| 2096 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2097 | {} |
| 2098 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2099 | static const struct hda_verb ext_mic_absent[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2100 | /* enable internal mic, port C */ |
| 2101 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2102 | |
| 2103 | /* switch to internal mic input */ |
| 2104 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2105 | |
| 2106 | /* disable external mic, port B */ |
| 2107 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2108 | {} |
| 2109 | }; |
| 2110 | |
| 2111 | present = snd_hda_jack_detect(codec, 0x1a); |
| 2112 | if (present) { |
| 2113 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2114 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2115 | } else { |
| 2116 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2117 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2118 | } |
| 2119 | } |
| 2120 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2121 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2122 | static void cxt5066_ideapad_automic(struct hda_codec *codec) |
| 2123 | { |
| 2124 | unsigned int present; |
| 2125 | |
| 2126 | struct hda_verb ext_mic_present[] = { |
| 2127 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2128 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2129 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2130 | {} |
| 2131 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2132 | static const struct hda_verb ext_mic_absent[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2133 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2134 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2135 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2136 | {} |
| 2137 | }; |
| 2138 | |
| 2139 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2140 | if (present) { |
| 2141 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2142 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2143 | } else { |
| 2144 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2145 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2146 | } |
| 2147 | } |
| 2148 | |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2149 | |
| 2150 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2151 | static void cxt5066_asus_automic(struct hda_codec *codec) |
| 2152 | { |
| 2153 | unsigned int present; |
| 2154 | |
| 2155 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2156 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2157 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2158 | present ? 1 : 0); |
| 2159 | } |
| 2160 | |
| 2161 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2162 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2163 | static void cxt5066_hp_laptop_automic(struct hda_codec *codec) |
| 2164 | { |
| 2165 | unsigned int present; |
| 2166 | |
| 2167 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2168 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2169 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2170 | present ? 1 : 3); |
| 2171 | } |
| 2172 | |
| 2173 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2174 | /* toggle input of built-in digital mic and mic jack appropriately |
| 2175 | order is: external mic -> dock mic -> interal mic */ |
| 2176 | static void cxt5066_thinkpad_automic(struct hda_codec *codec) |
| 2177 | { |
| 2178 | unsigned int ext_present, dock_present; |
| 2179 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2180 | static const struct hda_verb ext_mic_present[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2181 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2182 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, |
| 2183 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2184 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2185 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2186 | {} |
| 2187 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2188 | static const struct hda_verb dock_mic_present[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2189 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2190 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2191 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2192 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2193 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2194 | {} |
| 2195 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2196 | static const struct hda_verb ext_mic_absent[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2197 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2198 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2199 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2200 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2201 | {} |
| 2202 | }; |
| 2203 | |
| 2204 | ext_present = snd_hda_jack_detect(codec, 0x1b); |
| 2205 | dock_present = snd_hda_jack_detect(codec, 0x1a); |
| 2206 | if (ext_present) { |
| 2207 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2208 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2209 | } else if (dock_present) { |
| 2210 | snd_printdd("CXT5066: dock microphone detected\n"); |
| 2211 | snd_hda_sequence_write(codec, dock_mic_present); |
| 2212 | } else { |
| 2213 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2214 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2215 | } |
| 2216 | } |
| 2217 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2218 | /* mute internal speaker if HP is plugged */ |
| 2219 | static void cxt5066_hp_automute(struct hda_codec *codec) |
| 2220 | { |
| 2221 | struct conexant_spec *spec = codec->spec; |
| 2222 | unsigned int portA, portD; |
| 2223 | |
| 2224 | /* Port A */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2225 | portA = snd_hda_jack_detect(codec, 0x19); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2226 | |
| 2227 | /* Port D */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2228 | portD = snd_hda_jack_detect(codec, 0x1c); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2229 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2230 | spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; |
| 2231 | spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2232 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
| 2233 | portA, portD, spec->hp_present); |
| 2234 | cxt5066_update_speaker(codec); |
| 2235 | } |
| 2236 | |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2237 | /* Dispatch the right mic autoswitch function */ |
| 2238 | static void cxt5066_automic(struct hda_codec *codec) |
| 2239 | { |
| 2240 | struct conexant_spec *spec = codec->spec; |
| 2241 | |
| 2242 | if (spec->dell_vostro) |
| 2243 | cxt5066_vostro_automic(codec); |
| 2244 | else if (spec->ideapad) |
| 2245 | cxt5066_ideapad_automic(codec); |
| 2246 | else if (spec->thinkpad) |
| 2247 | cxt5066_thinkpad_automic(codec); |
| 2248 | else if (spec->hp_laptop) |
| 2249 | cxt5066_hp_laptop_automic(codec); |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2250 | else if (spec->asus) |
| 2251 | cxt5066_asus_automic(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2252 | } |
| 2253 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2254 | /* unsolicited event for jack sensing */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2255 | static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2256 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2257 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2258 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
| 2259 | switch (res >> 26) { |
| 2260 | case CONEXANT_HP_EVENT: |
| 2261 | cxt5066_hp_automute(codec); |
| 2262 | break; |
| 2263 | case CONEXANT_MIC_EVENT: |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2264 | /* ignore mic events in DC mode; we're always using the jack */ |
| 2265 | if (!spec->dc_enable) |
| 2266 | cxt5066_olpc_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2267 | break; |
| 2268 | } |
| 2269 | } |
| 2270 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2271 | /* unsolicited event for jack sensing */ |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2272 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2273 | { |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2274 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2275 | switch (res >> 26) { |
| 2276 | case CONEXANT_HP_EVENT: |
| 2277 | cxt5066_hp_automute(codec); |
| 2278 | break; |
| 2279 | case CONEXANT_MIC_EVENT: |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2280 | cxt5066_automic(codec); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2281 | break; |
| 2282 | } |
| 2283 | } |
| 2284 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2285 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2286 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
| 2287 | .num_items = 5, |
| 2288 | .items = { |
| 2289 | { "0dB", 0 }, |
| 2290 | { "10dB", 1 }, |
| 2291 | { "20dB", 2 }, |
| 2292 | { "30dB", 3 }, |
| 2293 | { "40dB", 4 }, |
| 2294 | }, |
| 2295 | }; |
| 2296 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2297 | static void cxt5066_set_mic_boost(struct hda_codec *codec) |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2298 | { |
| 2299 | struct conexant_spec *spec = codec->spec; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2300 | snd_hda_codec_write_cache(codec, 0x17, 0, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2301 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2302 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | |
| 2303 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2304 | if (spec->ideapad || spec->thinkpad) { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2305 | /* adjust the internal mic as well...it is not through 0x17 */ |
| 2306 | snd_hda_codec_write_cache(codec, 0x23, 0, |
| 2307 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2308 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | |
| 2309 | cxt5066_analog_mic_boost. |
| 2310 | items[spec->mic_boost].index); |
| 2311 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2312 | } |
| 2313 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2314 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 2315 | struct snd_ctl_elem_info *uinfo) |
| 2316 | { |
| 2317 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); |
| 2318 | } |
| 2319 | |
| 2320 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 2321 | struct snd_ctl_elem_value *ucontrol) |
| 2322 | { |
| 2323 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2324 | struct conexant_spec *spec = codec->spec; |
| 2325 | ucontrol->value.enumerated.item[0] = spec->mic_boost; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2326 | return 0; |
| 2327 | } |
| 2328 | |
| 2329 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 2330 | struct snd_ctl_elem_value *ucontrol) |
| 2331 | { |
| 2332 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2333 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2334 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2335 | unsigned int idx; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2336 | idx = ucontrol->value.enumerated.item[0]; |
| 2337 | if (idx >= imux->num_items) |
| 2338 | idx = imux->num_items - 1; |
| 2339 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2340 | spec->mic_boost = idx; |
| 2341 | if (!spec->dc_enable) |
| 2342 | cxt5066_set_mic_boost(codec); |
| 2343 | return 1; |
| 2344 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2345 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2346 | static void cxt5066_enable_dc(struct hda_codec *codec) |
| 2347 | { |
| 2348 | const struct hda_verb enable_dc_mode[] = { |
| 2349 | /* disable gain */ |
| 2350 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2351 | |
| 2352 | /* switch to DC input */ |
| 2353 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, |
| 2354 | {} |
| 2355 | }; |
| 2356 | |
| 2357 | /* configure as input source */ |
| 2358 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2359 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ |
| 2360 | } |
| 2361 | |
| 2362 | static void cxt5066_disable_dc(struct hda_codec *codec) |
| 2363 | { |
| 2364 | /* reconfigure input source */ |
| 2365 | cxt5066_set_mic_boost(codec); |
| 2366 | /* automic also selects the right mic if we're recording */ |
| 2367 | cxt5066_olpc_automic(codec); |
| 2368 | } |
| 2369 | |
| 2370 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, |
| 2371 | struct snd_ctl_elem_value *ucontrol) |
| 2372 | { |
| 2373 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2374 | struct conexant_spec *spec = codec->spec; |
| 2375 | ucontrol->value.integer.value[0] = spec->dc_enable; |
| 2376 | return 0; |
| 2377 | } |
| 2378 | |
| 2379 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
| 2380 | struct snd_ctl_elem_value *ucontrol) |
| 2381 | { |
| 2382 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2383 | struct conexant_spec *spec = codec->spec; |
| 2384 | int dc_enable = !!ucontrol->value.integer.value[0]; |
| 2385 | |
| 2386 | if (dc_enable == spec->dc_enable) |
| 2387 | return 0; |
| 2388 | |
| 2389 | spec->dc_enable = dc_enable; |
| 2390 | if (dc_enable) |
| 2391 | cxt5066_enable_dc(codec); |
| 2392 | else |
| 2393 | cxt5066_disable_dc(codec); |
| 2394 | |
| 2395 | return 1; |
| 2396 | } |
| 2397 | |
| 2398 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, |
| 2399 | struct snd_ctl_elem_info *uinfo) |
| 2400 | { |
| 2401 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); |
| 2402 | } |
| 2403 | |
| 2404 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, |
| 2405 | struct snd_ctl_elem_value *ucontrol) |
| 2406 | { |
| 2407 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2408 | struct conexant_spec *spec = codec->spec; |
| 2409 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; |
| 2410 | return 0; |
| 2411 | } |
| 2412 | |
| 2413 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, |
| 2414 | struct snd_ctl_elem_value *ucontrol) |
| 2415 | { |
| 2416 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2417 | struct conexant_spec *spec = codec->spec; |
| 2418 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2419 | unsigned int idx; |
| 2420 | |
| 2421 | idx = ucontrol->value.enumerated.item[0]; |
| 2422 | if (idx >= imux->num_items) |
| 2423 | idx = imux->num_items - 1; |
| 2424 | |
| 2425 | spec->dc_input_bias = idx; |
| 2426 | if (spec->dc_enable) |
| 2427 | cxt5066_set_olpc_dc_bias(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2428 | return 1; |
| 2429 | } |
| 2430 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2431 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) |
| 2432 | { |
| 2433 | struct conexant_spec *spec = codec->spec; |
| 2434 | /* mark as recording and configure the microphone widget so that the |
| 2435 | * recording LED comes on. */ |
| 2436 | spec->recording = 1; |
| 2437 | cxt5066_olpc_select_mic(codec); |
| 2438 | } |
| 2439 | |
| 2440 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) |
| 2441 | { |
| 2442 | struct conexant_spec *spec = codec->spec; |
| 2443 | const struct hda_verb disable_mics[] = { |
| 2444 | /* disable external mic, port B */ |
| 2445 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2446 | |
| 2447 | /* disble internal mic, port C */ |
| 2448 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2449 | |
| 2450 | /* disable DC capture, port F */ |
| 2451 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2452 | {}, |
| 2453 | }; |
| 2454 | |
| 2455 | snd_hda_sequence_write(codec, disable_mics); |
| 2456 | spec->recording = 0; |
| 2457 | } |
| 2458 | |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2459 | static void conexant_check_dig_outs(struct hda_codec *codec, |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2460 | const hda_nid_t *dig_pins, |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2461 | int num_pins) |
| 2462 | { |
| 2463 | struct conexant_spec *spec = codec->spec; |
| 2464 | hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; |
| 2465 | int i; |
| 2466 | |
| 2467 | for (i = 0; i < num_pins; i++, dig_pins++) { |
| 2468 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); |
| 2469 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) |
| 2470 | continue; |
| 2471 | if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) |
| 2472 | continue; |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2473 | } |
| 2474 | } |
| 2475 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2476 | static const struct hda_input_mux cxt5066_capture_source = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2477 | .num_items = 4, |
| 2478 | .items = { |
| 2479 | { "Mic B", 0 }, |
| 2480 | { "Mic C", 1 }, |
| 2481 | { "Mic E", 2 }, |
| 2482 | { "Mic F", 3 }, |
| 2483 | }, |
| 2484 | }; |
| 2485 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2486 | static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2487 | .ops = &snd_hda_bind_vol, |
| 2488 | .values = { |
| 2489 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2490 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2491 | 0 |
| 2492 | }, |
| 2493 | }; |
| 2494 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2495 | static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2496 | .ops = &snd_hda_bind_sw, |
| 2497 | .values = { |
| 2498 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2499 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2500 | 0 |
| 2501 | }, |
| 2502 | }; |
| 2503 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2504 | static const struct snd_kcontrol_new cxt5066_mixer_master[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2505 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 2506 | {} |
| 2507 | }; |
| 2508 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2509 | static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2510 | { |
| 2511 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2512 | .name = "Master Playback Volume", |
| 2513 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2514 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2515 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2516 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2517 | .info = snd_hda_mixer_amp_volume_info, |
| 2518 | .get = snd_hda_mixer_amp_volume_get, |
| 2519 | .put = snd_hda_mixer_amp_volume_put, |
| 2520 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
| 2521 | /* offset by 28 volume steps to limit minimum gain to -46dB */ |
| 2522 | .private_value = |
| 2523 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), |
| 2524 | }, |
| 2525 | {} |
| 2526 | }; |
| 2527 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2528 | static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2529 | { |
| 2530 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2531 | .name = "DC Mode Enable Switch", |
| 2532 | .info = snd_ctl_boolean_mono_info, |
| 2533 | .get = cxt5066_olpc_dc_get, |
| 2534 | .put = cxt5066_olpc_dc_put, |
| 2535 | }, |
| 2536 | { |
| 2537 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2538 | .name = "DC Input Bias Enum", |
| 2539 | .info = cxt5066_olpc_dc_bias_enum_info, |
| 2540 | .get = cxt5066_olpc_dc_bias_enum_get, |
| 2541 | .put = cxt5066_olpc_dc_bias_enum_put, |
| 2542 | }, |
| 2543 | {} |
| 2544 | }; |
| 2545 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2546 | static const struct snd_kcontrol_new cxt5066_mixers[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2547 | { |
| 2548 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2549 | .name = "Master Playback Switch", |
| 2550 | .info = cxt_eapd_info, |
| 2551 | .get = cxt_eapd_get, |
| 2552 | .put = cxt5066_hp_master_sw_put, |
| 2553 | .private_value = 0x1d, |
| 2554 | }, |
| 2555 | |
| 2556 | { |
| 2557 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2558 | .name = "Analog Mic Boost Capture Enum", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2559 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2560 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2561 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2562 | }, |
| 2563 | |
| 2564 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
| 2565 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), |
| 2566 | {} |
| 2567 | }; |
| 2568 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2569 | static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2570 | { |
| 2571 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2572 | .name = "Internal Mic Boost Capture Enum", |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2573 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2574 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2575 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2576 | .private_value = 0x23 | 0x100, |
| 2577 | }, |
| 2578 | {} |
| 2579 | }; |
| 2580 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2581 | static const struct hda_verb cxt5066_init_verbs[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2582 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2583 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2584 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2585 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2586 | |
| 2587 | /* Speakers */ |
| 2588 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2589 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2590 | |
| 2591 | /* HP, Amp */ |
| 2592 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2593 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2594 | |
| 2595 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2596 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2597 | |
| 2598 | /* DAC1 */ |
| 2599 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2600 | |
| 2601 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2602 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2603 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2604 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2605 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2606 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2607 | |
| 2608 | /* no digital microphone support yet */ |
| 2609 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2610 | |
| 2611 | /* Audio input selector */ |
| 2612 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2613 | |
| 2614 | /* SPDIF route: PCM */ |
| 2615 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2616 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2617 | |
| 2618 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2619 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2620 | |
| 2621 | /* EAPD */ |
| 2622 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2623 | |
| 2624 | /* not handling these yet */ |
| 2625 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2626 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2627 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2628 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2629 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2630 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2631 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2632 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2633 | { } /* end */ |
| 2634 | }; |
| 2635 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2636 | static const struct hda_verb cxt5066_init_verbs_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2637 | /* Port A: headphones */ |
| 2638 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2639 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2640 | |
| 2641 | /* Port B: external microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2642 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2643 | |
| 2644 | /* Port C: internal microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2645 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2646 | |
| 2647 | /* Port D: unused */ |
| 2648 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2649 | |
| 2650 | /* Port E: unused, but has primary EAPD */ |
| 2651 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2652 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2653 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2654 | /* Port F: external DC input through microphone port */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2655 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2656 | |
| 2657 | /* Port G: internal speakers */ |
| 2658 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2659 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2660 | |
| 2661 | /* DAC1 */ |
| 2662 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2663 | |
| 2664 | /* DAC2: unused */ |
| 2665 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2666 | |
| 2667 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2668 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2669 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2670 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2671 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2672 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2673 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2674 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2675 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2676 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2677 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2678 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2679 | |
| 2680 | /* Disable digital microphone port */ |
| 2681 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2682 | |
| 2683 | /* Audio input selectors */ |
| 2684 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2685 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2686 | |
| 2687 | /* Disable SPDIF */ |
| 2688 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2689 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2690 | |
| 2691 | /* enable unsolicited events for Port A and B */ |
| 2692 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2693 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2694 | { } /* end */ |
| 2695 | }; |
| 2696 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2697 | static const struct hda_verb cxt5066_init_verbs_vostro[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2698 | /* Port A: headphones */ |
| 2699 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2700 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2701 | |
| 2702 | /* Port B: external microphone */ |
| 2703 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2704 | |
| 2705 | /* Port C: unused */ |
| 2706 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2707 | |
| 2708 | /* Port D: unused */ |
| 2709 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2710 | |
| 2711 | /* Port E: unused, but has primary EAPD */ |
| 2712 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2713 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2714 | |
| 2715 | /* Port F: unused */ |
| 2716 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2717 | |
| 2718 | /* Port G: internal speakers */ |
| 2719 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2720 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2721 | |
| 2722 | /* DAC1 */ |
| 2723 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2724 | |
| 2725 | /* DAC2: unused */ |
| 2726 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2727 | |
| 2728 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2729 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2730 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2731 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2732 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2733 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2734 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2735 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2736 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2737 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2738 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2739 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2740 | |
| 2741 | /* Digital microphone port */ |
| 2742 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2743 | |
| 2744 | /* Audio input selectors */ |
| 2745 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2746 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2747 | |
| 2748 | /* Disable SPDIF */ |
| 2749 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2750 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2751 | |
| 2752 | /* enable unsolicited events for Port A and B */ |
| 2753 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2754 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2755 | { } /* end */ |
| 2756 | }; |
| 2757 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2758 | static const struct hda_verb cxt5066_init_verbs_ideapad[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2759 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2760 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2761 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2762 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2763 | |
| 2764 | /* Speakers */ |
| 2765 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2766 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2767 | |
| 2768 | /* HP, Amp */ |
| 2769 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2770 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2771 | |
| 2772 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2773 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2774 | |
| 2775 | /* DAC1 */ |
| 2776 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2777 | |
| 2778 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2779 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2780 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2781 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2782 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2783 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2784 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2785 | |
| 2786 | /* Audio input selector */ |
| 2787 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2788 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2789 | |
| 2790 | /* SPDIF route: PCM */ |
| 2791 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2792 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2793 | |
| 2794 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2795 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2796 | |
| 2797 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2798 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2799 | |
| 2800 | /* EAPD */ |
| 2801 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2802 | |
| 2803 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2804 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2805 | { } /* end */ |
| 2806 | }; |
| 2807 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2808 | static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2809 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2810 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2811 | |
| 2812 | /* Port G: internal speakers */ |
| 2813 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2814 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2815 | |
| 2816 | /* Port A: HP, Amp */ |
| 2817 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2818 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2819 | |
| 2820 | /* Port B: Mic Dock */ |
| 2821 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2822 | |
| 2823 | /* Port C: Mic */ |
| 2824 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2825 | |
| 2826 | /* Port D: HP Dock, Amp */ |
| 2827 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2828 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2829 | |
| 2830 | /* DAC1 */ |
| 2831 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2832 | |
| 2833 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2834 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2835 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2836 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2837 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2838 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2839 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2840 | |
| 2841 | /* Audio input selector */ |
| 2842 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2843 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2844 | |
| 2845 | /* SPDIF route: PCM */ |
| 2846 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2847 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2848 | |
| 2849 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2850 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2851 | |
| 2852 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2853 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2854 | |
| 2855 | /* EAPD */ |
| 2856 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2857 | |
| 2858 | /* enable unsolicited events for Port A, B, C and D */ |
| 2859 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2860 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2861 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2862 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2863 | { } /* end */ |
| 2864 | }; |
| 2865 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2866 | static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2867 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2868 | { } /* end */ |
| 2869 | }; |
| 2870 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2871 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2872 | static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2873 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2874 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2875 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2876 | { } /* end */ |
| 2877 | }; |
| 2878 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2879 | /* initialize jack-sensing, too */ |
| 2880 | static int cxt5066_init(struct hda_codec *codec) |
| 2881 | { |
| 2882 | snd_printdd("CXT5066: init\n"); |
| 2883 | conexant_init(codec); |
| 2884 | if (codec->patch_ops.unsol_event) { |
| 2885 | cxt5066_hp_automute(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2886 | cxt5066_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2887 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2888 | cxt5066_set_mic_boost(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2889 | return 0; |
| 2890 | } |
| 2891 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2892 | static int cxt5066_olpc_init(struct hda_codec *codec) |
| 2893 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2894 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2895 | snd_printdd("CXT5066: init\n"); |
| 2896 | conexant_init(codec); |
| 2897 | cxt5066_hp_automute(codec); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2898 | if (!spec->dc_enable) { |
| 2899 | cxt5066_set_mic_boost(codec); |
| 2900 | cxt5066_olpc_automic(codec); |
| 2901 | } else { |
| 2902 | cxt5066_enable_dc(codec); |
| 2903 | } |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2904 | return 0; |
| 2905 | } |
| 2906 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2907 | enum { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2908 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2909 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
| 2910 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2911 | CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2912 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2913 | CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2914 | CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2915 | CXT5066_HP_LAPTOP, /* HP Laptop */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2916 | CXT5066_AUTO, /* BIOS auto-parser */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2917 | CXT5066_MODELS |
| 2918 | }; |
| 2919 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2920 | static const char * const cxt5066_models[CXT5066_MODELS] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2921 | [CXT5066_LAPTOP] = "laptop", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2922 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
| 2923 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2924 | [CXT5066_DELL_VOSTRO] = "dell-vostro", |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2925 | [CXT5066_IDEAPAD] = "ideapad", |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2926 | [CXT5066_THINKPAD] = "thinkpad", |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2927 | [CXT5066_ASUS] = "asus", |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2928 | [CXT5066_HP_LAPTOP] = "hp-laptop", |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2929 | [CXT5066_AUTO] = "auto", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2930 | }; |
| 2931 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2932 | static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
Takashi Iwai | 00cd0bb | 2010-10-21 09:57:40 +0200 | [diff] [blame] | 2933 | SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2934 | SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), |
David Henningsson | 8a96b1e | 2010-12-09 07:17:27 +0100 | [diff] [blame] | 2935 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), |
Daniel T Chen | ca6cd85 | 2011-01-08 18:25:27 -0500 | [diff] [blame] | 2936 | SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), |
Anisse Astier | 231f50b | 2010-04-28 18:05:06 +0200 | [diff] [blame] | 2937 | SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), |
David Henningsson | ebbd224 | 2011-02-23 13:15:56 +0100 | [diff] [blame] | 2938 | SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2939 | SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2940 | SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2941 | SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2942 | SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), |
Anisse Astier | 2ca9cac | 2010-09-10 15:47:55 +0200 | [diff] [blame] | 2943 | SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), |
Daniel T Chen | c536668 | 2010-05-04 22:07:58 -0400 | [diff] [blame] | 2944 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), |
David Henningsson | 5637edb | 2010-09-17 10:58:03 +0200 | [diff] [blame] | 2945 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 2946 | CXT5066_LAPTOP), |
| 2947 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), |
Takashi Iwai | 4d15564 | 2010-09-07 11:58:30 +0200 | [diff] [blame] | 2948 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), |
Manoj Iyer | ef61d4e | 2010-12-03 18:43:55 -0600 | [diff] [blame] | 2949 | SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), |
David Henningsson | 1959387 | 2011-01-27 10:28:46 +0100 | [diff] [blame] | 2950 | SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), |
David Henningsson | d2859fd | 2011-05-23 08:26:16 +0200 | [diff] [blame] | 2951 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2952 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2953 | {} |
| 2954 | }; |
| 2955 | |
| 2956 | static int patch_cxt5066(struct hda_codec *codec) |
| 2957 | { |
| 2958 | struct conexant_spec *spec; |
| 2959 | int board_config; |
| 2960 | |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2961 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, |
| 2962 | cxt5066_models, cxt5066_cfg_tbl); |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2963 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 2964 | board_config = CXT5066_AUTO; /* model=auto as default */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2965 | if (board_config == CXT5066_AUTO) |
| 2966 | return patch_conexant_auto(codec); |
| 2967 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2968 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2969 | if (!spec) |
| 2970 | return -ENOMEM; |
| 2971 | codec->spec = spec; |
| 2972 | |
| 2973 | codec->patch_ops = conexant_patch_ops; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2974 | codec->patch_ops.init = conexant_init; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2975 | |
| 2976 | spec->dell_automute = 0; |
| 2977 | spec->multiout.max_channels = 2; |
| 2978 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); |
| 2979 | spec->multiout.dac_nids = cxt5066_dac_nids; |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2980 | conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, |
| 2981 | ARRAY_SIZE(cxt5066_digout_pin_nids)); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2982 | spec->num_adc_nids = 1; |
| 2983 | spec->adc_nids = cxt5066_adc_nids; |
| 2984 | spec->capsrc_nids = cxt5066_capsrc_nids; |
| 2985 | spec->input_mux = &cxt5066_capture_source; |
| 2986 | |
| 2987 | spec->port_d_mode = PIN_HP; |
| 2988 | |
| 2989 | spec->num_init_verbs = 1; |
| 2990 | spec->init_verbs[0] = cxt5066_init_verbs; |
| 2991 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); |
| 2992 | spec->channel_mode = cxt5066_modes; |
| 2993 | spec->cur_adc = 0; |
| 2994 | spec->cur_adc_idx = 0; |
| 2995 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 2996 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 2997 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2998 | switch (board_config) { |
| 2999 | default: |
| 3000 | case CXT5066_LAPTOP: |
| 3001 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3002 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3003 | break; |
| 3004 | case CXT5066_DELL_LAPTOP: |
| 3005 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3006 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3007 | |
| 3008 | spec->port_d_mode = PIN_OUT; |
| 3009 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; |
| 3010 | spec->num_init_verbs++; |
| 3011 | spec->dell_automute = 1; |
| 3012 | break; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3013 | case CXT5066_ASUS: |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3014 | case CXT5066_HP_LAPTOP: |
| 3015 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3016 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3017 | spec->init_verbs[spec->num_init_verbs] = |
| 3018 | cxt5066_init_verbs_hp_laptop; |
| 3019 | spec->num_init_verbs++; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3020 | spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; |
| 3021 | spec->asus = board_config == CXT5066_ASUS; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3022 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3023 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3024 | /* no S/PDIF out */ |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 3025 | if (board_config == CXT5066_HP_LAPTOP) |
| 3026 | spec->multiout.dig_out_nid = 0; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3027 | /* input source automatically selected */ |
| 3028 | spec->input_mux = NULL; |
| 3029 | spec->port_d_mode = 0; |
| 3030 | spec->mic_boost = 3; /* default 30dB gain */ |
| 3031 | break; |
| 3032 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3033 | case CXT5066_OLPC_XO_1_5: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3034 | codec->patch_ops.init = cxt5066_olpc_init; |
| 3035 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3036 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
| 3037 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3038 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3039 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3040 | spec->port_d_mode = 0; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3041 | spec->mic_boost = 3; /* default 30dB gain */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3042 | |
| 3043 | /* no S/PDIF out */ |
| 3044 | spec->multiout.dig_out_nid = 0; |
| 3045 | |
| 3046 | /* input source automatically selected */ |
| 3047 | spec->input_mux = NULL; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3048 | |
| 3049 | /* our capture hooks which allow us to turn on the microphone LED |
| 3050 | * at the right time */ |
| 3051 | spec->capture_prepare = cxt5066_olpc_capture_prepare; |
| 3052 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3053 | break; |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 3054 | case CXT5066_DELL_VOSTRO: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3055 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3056 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3057 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
| 3058 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
| 3059 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3060 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3061 | spec->port_d_mode = 0; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3062 | spec->dell_vostro = 1; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3063 | spec->mic_boost = 3; /* default 30dB gain */ |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3064 | |
| 3065 | /* no S/PDIF out */ |
| 3066 | spec->multiout.dig_out_nid = 0; |
| 3067 | |
| 3068 | /* input source automatically selected */ |
| 3069 | spec->input_mux = NULL; |
| 3070 | break; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3071 | case CXT5066_IDEAPAD: |
| 3072 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3073 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3074 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3075 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3076 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; |
| 3077 | spec->port_d_mode = 0; |
| 3078 | spec->ideapad = 1; |
| 3079 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3080 | |
| 3081 | /* no S/PDIF out */ |
| 3082 | spec->multiout.dig_out_nid = 0; |
| 3083 | |
| 3084 | /* input source automatically selected */ |
| 3085 | spec->input_mux = NULL; |
| 3086 | break; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3087 | case CXT5066_THINKPAD: |
| 3088 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3089 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3090 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3091 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3092 | spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; |
| 3093 | spec->thinkpad = 1; |
| 3094 | spec->port_d_mode = PIN_OUT; |
| 3095 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3096 | |
| 3097 | /* no S/PDIF out */ |
| 3098 | spec->multiout.dig_out_nid = 0; |
| 3099 | |
| 3100 | /* input source automatically selected */ |
| 3101 | spec->input_mux = NULL; |
| 3102 | break; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3103 | } |
| 3104 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3105 | if (spec->beep_amp) |
Takashi Iwai | a86b1a2c | 2013-03-18 11:00:44 +0100 | [diff] [blame] | 3106 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3107 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3108 | return 0; |
| 3109 | } |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3110 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 3111 | #endif /* ENABLE_CXT_STATIC_QUIRKS */ |
| 3112 | |
| 3113 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3114 | /* |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3115 | * Automatic parser for CX20641 & co |
| 3116 | */ |
| 3117 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3118 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3119 | static void cx_auto_parse_beep(struct hda_codec *codec) |
| 3120 | { |
| 3121 | struct conexant_spec *spec = codec->spec; |
| 3122 | hda_nid_t nid, end_nid; |
| 3123 | |
| 3124 | end_nid = codec->start_nid + codec->num_nodes; |
| 3125 | for (nid = codec->start_nid; nid < end_nid; nid++) |
| 3126 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { |
| 3127 | set_beep_amp(spec, nid, 0, HDA_OUTPUT); |
| 3128 | break; |
| 3129 | } |
| 3130 | } |
| 3131 | #else |
| 3132 | #define cx_auto_parse_beep(codec) |
| 3133 | #endif |
| 3134 | |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3135 | /* parse EAPDs */ |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3136 | static void cx_auto_parse_eapd(struct hda_codec *codec) |
| 3137 | { |
| 3138 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3139 | hda_nid_t nid, end_nid; |
| 3140 | |
| 3141 | end_nid = codec->start_nid + codec->num_nodes; |
| 3142 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3143 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 3144 | continue; |
| 3145 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) |
| 3146 | continue; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3147 | spec->eapds[spec->num_eapds++] = nid; |
| 3148 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) |
| 3149 | break; |
| 3150 | } |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3151 | |
| 3152 | /* NOTE: below is a wild guess; if we have more than two EAPDs, |
| 3153 | * it's a new chip, where EAPDs are supposed to be associated to |
| 3154 | * pins, and we can control EAPD per pin. |
| 3155 | * OTOH, if only one or two EAPDs are found, it's an old chip, |
| 3156 | * thus it might control over all pins. |
| 3157 | */ |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3158 | if (spec->num_eapds > 2) |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 3159 | spec->dynamic_eapd = 1; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3160 | } |
| 3161 | |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3162 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
| 3163 | hda_nid_t *pins, bool on) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3164 | { |
| 3165 | int i; |
| 3166 | for (i = 0; i < num_pins; i++) { |
| 3167 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) |
| 3168 | snd_hda_codec_write(codec, pins[i], 0, |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3169 | AC_VERB_SET_EAPD_BTLENABLE, |
| 3170 | on ? 0x02 : 0); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3171 | } |
| 3172 | } |
| 3173 | |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3174 | /* turn on/off EAPD according to Master switch */ |
| 3175 | static void cx_auto_vmaster_hook(void *private_data, int enabled) |
| 3176 | { |
| 3177 | struct hda_codec *codec = private_data; |
| 3178 | struct conexant_spec *spec = codec->spec; |
| 3179 | |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3180 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); |
| 3181 | } |
| 3182 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3183 | static int cx_auto_build_controls(struct hda_codec *codec) |
| 3184 | { |
| 3185 | int err; |
| 3186 | |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3187 | err = snd_hda_gen_build_controls(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3188 | if (err < 0) |
| 3189 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3190 | |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3191 | err = add_beep_ctls(codec); |
| 3192 | if (err < 0) |
| 3193 | return err; |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 3194 | |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 3195 | return 0; |
| 3196 | } |
| 3197 | |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 3198 | static int cx_auto_init(struct hda_codec *codec) |
| 3199 | { |
| 3200 | struct conexant_spec *spec = codec->spec; |
| 3201 | snd_hda_gen_init(codec); |
| 3202 | if (!spec->dynamic_eapd) |
| 3203 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3204 | |
| 3205 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); |
| 3206 | |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 3207 | return 0; |
| 3208 | } |
| 3209 | |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3210 | static void cx_auto_free(struct hda_codec *codec) |
| 3211 | { |
| 3212 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); |
| 3213 | snd_hda_gen_free(codec); |
| 3214 | } |
| 3215 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 3216 | static const struct hda_codec_ops cx_auto_patch_ops = { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3217 | .build_controls = cx_auto_build_controls, |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3218 | .build_pcms = snd_hda_gen_build_pcms, |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 3219 | .init = cx_auto_init, |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3220 | .free = cx_auto_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3221 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 164a7ad | 2013-01-18 18:25:45 +0100 | [diff] [blame] | 3222 | #ifdef CONFIG_PM |
| 3223 | .check_power_status = snd_hda_gen_check_power_status, |
| 3224 | #endif |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3225 | }; |
| 3226 | |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3227 | /* |
| 3228 | * pin fix-up |
| 3229 | */ |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 3230 | enum { |
| 3231 | CXT_PINCFG_LENOVO_X200, |
Takashi Iwai | d398011 | 2012-04-19 17:17:59 +0200 | [diff] [blame] | 3232 | CXT_PINCFG_LENOVO_TP410, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3233 | CXT_PINCFG_LEMOTE_A1004, |
| 3234 | CXT_PINCFG_LEMOTE_A1205, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 3235 | CXT_FIXUP_STEREO_DMIC, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3236 | CXT_FIXUP_INC_MIC_BOOST, |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3237 | CXT_FIXUP_HEADPHONE_MIC_PIN, |
| 3238 | CXT_FIXUP_HEADPHONE_MIC, |
Takashi Iwai | 4a43704 | 2013-09-30 12:13:44 +0200 | [diff] [blame] | 3239 | CXT_FIXUP_GPIO1, |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3240 | CXT_FIXUP_THINKPAD_ACPI, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 3241 | }; |
| 3242 | |
Takashi Iwai | b317b03 | 2014-01-08 11:44:21 +0100 | [diff] [blame] | 3243 | /* for hda_fixup_thinkpad_acpi() */ |
| 3244 | #include "thinkpad_helper.c" |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3245 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3246 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, |
| 3247 | const struct hda_fixup *fix, int action) |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3248 | { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 3249 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3250 | spec->gen.inv_dmic_split = 1; |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3251 | } |
| 3252 | |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3253 | static void cxt5066_increase_mic_boost(struct hda_codec *codec, |
| 3254 | const struct hda_fixup *fix, int action) |
| 3255 | { |
| 3256 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 3257 | return; |
| 3258 | |
| 3259 | snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, |
| 3260 | (0x3 << AC_AMPCAP_OFFSET_SHIFT) | |
| 3261 | (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 3262 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 3263 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 3264 | } |
| 3265 | |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3266 | static void cxt_update_headset_mode(struct hda_codec *codec) |
| 3267 | { |
| 3268 | /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ |
| 3269 | int i; |
| 3270 | bool mic_mode = false; |
| 3271 | struct conexant_spec *spec = codec->spec; |
| 3272 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; |
| 3273 | |
| 3274 | hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; |
| 3275 | |
| 3276 | for (i = 0; i < cfg->num_inputs; i++) |
| 3277 | if (cfg->inputs[i].pin == mux_pin) { |
| 3278 | mic_mode = !!cfg->inputs[i].is_headphone_mic; |
| 3279 | break; |
| 3280 | } |
| 3281 | |
| 3282 | if (mic_mode) { |
| 3283 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ |
| 3284 | spec->gen.hp_jack_present = false; |
| 3285 | } else { |
| 3286 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ |
| 3287 | spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); |
| 3288 | } |
| 3289 | |
| 3290 | snd_hda_gen_update_outputs(codec); |
| 3291 | } |
| 3292 | |
| 3293 | static void cxt_update_headset_mode_hook(struct hda_codec *codec, |
Takashi Iwai | 7fe3071 | 2014-01-30 17:59:02 +0100 | [diff] [blame] | 3294 | struct snd_kcontrol *kcontrol, |
| 3295 | struct snd_ctl_elem_value *ucontrol) |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3296 | { |
| 3297 | cxt_update_headset_mode(codec); |
| 3298 | } |
| 3299 | |
| 3300 | static void cxt_fixup_headphone_mic(struct hda_codec *codec, |
| 3301 | const struct hda_fixup *fix, int action) |
| 3302 | { |
| 3303 | struct conexant_spec *spec = codec->spec; |
| 3304 | |
| 3305 | switch (action) { |
| 3306 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 3307 | spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; |
| 3308 | break; |
| 3309 | case HDA_FIXUP_ACT_PROBE: |
| 3310 | spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; |
| 3311 | spec->gen.automute_hook = cxt_update_headset_mode; |
| 3312 | break; |
| 3313 | case HDA_FIXUP_ACT_INIT: |
| 3314 | cxt_update_headset_mode(codec); |
| 3315 | break; |
| 3316 | } |
| 3317 | } |
| 3318 | |
| 3319 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3320 | /* ThinkPad X200 & co with cxt5051 */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3321 | static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3322 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ |
| 3323 | { 0x17, 0x21a11000 }, /* dock-mic */ |
| 3324 | { 0x19, 0x2121103f }, /* dock-HP */ |
Takashi Iwai | 3e93f5e | 2012-02-28 21:49:55 +0100 | [diff] [blame] | 3325 | { 0x1c, 0x21440100 }, /* dock SPDIF out */ |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3326 | {} |
| 3327 | }; |
| 3328 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3329 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3330 | static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3331 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ |
| 3332 | { 0x1a, 0x21a190f0 }, /* dock-mic */ |
| 3333 | { 0x1c, 0x212140ff }, /* dock-HP */ |
| 3334 | {} |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3335 | }; |
| 3336 | |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3337 | /* Lemote A1004/A1205 with cxt5066 */ |
| 3338 | static const struct hda_pintbl cxt_pincfg_lemote[] = { |
| 3339 | { 0x1a, 0x90a10020 }, /* Internal mic */ |
| 3340 | { 0x1b, 0x03a11020 }, /* External mic */ |
| 3341 | { 0x1d, 0x400101f0 }, /* Not used */ |
| 3342 | { 0x1e, 0x40a701f0 }, /* Not used */ |
| 3343 | { 0x20, 0x404501f0 }, /* Not used */ |
| 3344 | { 0x22, 0x404401f0 }, /* Not used */ |
| 3345 | { 0x23, 0x40a701f0 }, /* Not used */ |
| 3346 | {} |
| 3347 | }; |
| 3348 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3349 | static const struct hda_fixup cxt_fixups[] = { |
| 3350 | [CXT_PINCFG_LENOVO_X200] = { |
| 3351 | .type = HDA_FIXUP_PINS, |
| 3352 | .v.pins = cxt_pincfg_lenovo_x200, |
| 3353 | }, |
| 3354 | [CXT_PINCFG_LENOVO_TP410] = { |
| 3355 | .type = HDA_FIXUP_PINS, |
| 3356 | .v.pins = cxt_pincfg_lenovo_tp410, |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3357 | .chained = true, |
| 3358 | .chain_id = CXT_FIXUP_THINKPAD_ACPI, |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3359 | }, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3360 | [CXT_PINCFG_LEMOTE_A1004] = { |
| 3361 | .type = HDA_FIXUP_PINS, |
| 3362 | .chained = true, |
| 3363 | .chain_id = CXT_FIXUP_INC_MIC_BOOST, |
| 3364 | .v.pins = cxt_pincfg_lemote, |
| 3365 | }, |
| 3366 | [CXT_PINCFG_LEMOTE_A1205] = { |
| 3367 | .type = HDA_FIXUP_PINS, |
| 3368 | .v.pins = cxt_pincfg_lemote, |
| 3369 | }, |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3370 | [CXT_FIXUP_STEREO_DMIC] = { |
| 3371 | .type = HDA_FIXUP_FUNC, |
| 3372 | .v.func = cxt_fixup_stereo_dmic, |
| 3373 | }, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3374 | [CXT_FIXUP_INC_MIC_BOOST] = { |
| 3375 | .type = HDA_FIXUP_FUNC, |
| 3376 | .v.func = cxt5066_increase_mic_boost, |
| 3377 | }, |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3378 | [CXT_FIXUP_HEADPHONE_MIC_PIN] = { |
| 3379 | .type = HDA_FIXUP_PINS, |
| 3380 | .chained = true, |
| 3381 | .chain_id = CXT_FIXUP_HEADPHONE_MIC, |
| 3382 | .v.pins = (const struct hda_pintbl[]) { |
| 3383 | { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ |
| 3384 | { } |
| 3385 | } |
| 3386 | }, |
| 3387 | [CXT_FIXUP_HEADPHONE_MIC] = { |
| 3388 | .type = HDA_FIXUP_FUNC, |
| 3389 | .v.func = cxt_fixup_headphone_mic, |
| 3390 | }, |
Takashi Iwai | 4a43704 | 2013-09-30 12:13:44 +0200 | [diff] [blame] | 3391 | [CXT_FIXUP_GPIO1] = { |
| 3392 | .type = HDA_FIXUP_VERBS, |
| 3393 | .v.verbs = (const struct hda_verb[]) { |
| 3394 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, |
| 3395 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, |
| 3396 | { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, |
| 3397 | { } |
| 3398 | }, |
| 3399 | }, |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3400 | [CXT_FIXUP_THINKPAD_ACPI] = { |
| 3401 | .type = HDA_FIXUP_FUNC, |
Takashi Iwai | b317b03 | 2014-01-08 11:44:21 +0100 | [diff] [blame] | 3402 | .v.func = hda_fixup_thinkpad_acpi, |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3403 | }, |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3404 | }; |
| 3405 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3406 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3407 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), |
| 3408 | {} |
| 3409 | }; |
| 3410 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3411 | static const struct snd_pci_quirk cxt5066_fixups[] = { |
Takashi Iwai | 63a077e | 2012-12-12 12:10:01 +0100 | [diff] [blame] | 3412 | SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), |
Takashi Iwai | 4a43704 | 2013-09-30 12:13:44 +0200 | [diff] [blame] | 3413 | SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3414 | SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 3415 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), |
| 3416 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), |
| 3417 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), |
| 3418 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), |
| 3419 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), |
David Henningsson | a555bb8 | 2013-04-29 08:24:23 +0200 | [diff] [blame] | 3420 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), |
David Henningsson | 88d5760 | 2013-06-20 10:23:54 +0200 | [diff] [blame] | 3421 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 3422 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), |
Felix Kaechele | e4db095 | 2012-09-26 01:20:44 +0200 | [diff] [blame] | 3423 | SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), |
David Henningsson | b3c5dce | 2012-06-21 16:03:01 +0200 | [diff] [blame] | 3424 | SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), |
Hui Wang | 2fd3f17 | 2013-11-27 14:47:26 +0800 | [diff] [blame] | 3425 | SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 3426 | SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), |
| 3427 | SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3428 | {} |
| 3429 | }; |
| 3430 | |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 3431 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches |
| 3432 | * can be created (bko#42825) |
| 3433 | */ |
| 3434 | static void add_cx5051_fake_mutes(struct hda_codec *codec) |
| 3435 | { |
| 3436 | static hda_nid_t out_nids[] = { |
| 3437 | 0x10, 0x11, 0 |
| 3438 | }; |
| 3439 | hda_nid_t *p; |
| 3440 | |
| 3441 | for (p = out_nids; *p; p++) |
| 3442 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, |
| 3443 | AC_AMPCAP_MIN_MUTE | |
| 3444 | query_amp_caps(codec, *p, HDA_OUTPUT)); |
| 3445 | } |
| 3446 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3447 | static int patch_conexant_auto(struct hda_codec *codec) |
| 3448 | { |
| 3449 | struct conexant_spec *spec; |
| 3450 | int err; |
| 3451 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3452 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 3453 | codec->chip_name); |
| 3454 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3455 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3456 | if (!spec) |
| 3457 | return -ENOMEM; |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3458 | snd_hda_gen_spec_init(&spec->gen); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3459 | codec->spec = spec; |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3460 | |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3461 | cx_auto_parse_beep(codec); |
| 3462 | cx_auto_parse_eapd(codec); |
Takashi Iwai | ff359b1 | 2013-05-04 10:57:16 +0200 | [diff] [blame] | 3463 | spec->gen.own_eapd_ctl = 1; |
| 3464 | if (spec->dynamic_eapd) |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3465 | spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 3466 | |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 3467 | switch (codec->vendor_id) { |
| 3468 | case 0x14f15045: |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 3469 | codec->single_adc_amp = 1; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 3470 | break; |
Takashi Iwai | 164a7ad | 2013-01-18 18:25:45 +0100 | [diff] [blame] | 3471 | case 0x14f15047: |
| 3472 | codec->pin_amp_workaround = 1; |
| 3473 | spec->gen.mixer_nid = 0x19; |
| 3474 | break; |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 3475 | case 0x14f15051: |
| 3476 | add_cx5051_fake_mutes(codec); |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 3477 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3478 | snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 3479 | break; |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 3480 | default: |
| 3481 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 3482 | snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); |
| 3483 | break; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 3484 | } |
| 3485 | |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 3486 | /* Show mute-led control only on HP laptops |
| 3487 | * This is a sort of white-list: on HP laptops, EAPD corresponds |
| 3488 | * only to the mute-LED without actualy amp function. Meanwhile, |
| 3489 | * others may use EAPD really as an amp switch, so it might be |
| 3490 | * not good to expose it blindly. |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3491 | */ |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 3492 | switch (codec->subsystem_id >> 16) { |
| 3493 | case 0x103c: |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3494 | spec->gen.vmaster_mute_enum = 1; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 3495 | break; |
| 3496 | } |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3497 | |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3498 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 3499 | |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3500 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, |
| 3501 | spec->parse_flags); |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 3502 | if (err < 0) |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3503 | goto error; |
| 3504 | |
| 3505 | err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); |
| 3506 | if (err < 0) |
| 3507 | goto error; |
| 3508 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3509 | codec->patch_ops = cx_auto_patch_ops; |
Takashi Iwai | 4f2864a | 2012-01-25 11:54:19 +0100 | [diff] [blame] | 3510 | |
| 3511 | /* Some laptops with Conexant chips show stalls in S3 resume, |
| 3512 | * which falls into the single-cmd mode. |
| 3513 | * Better to make reset, then. |
| 3514 | */ |
| 3515 | if (!codec->bus->sync_write) { |
| 3516 | snd_printd("hda_codec: " |
| 3517 | "Enable sync_write for stable communication\n"); |
| 3518 | codec->bus->sync_write = 1; |
| 3519 | codec->bus->allow_bus_reset = 1; |
| 3520 | } |
| 3521 | |
David Henningsson | e4c3bce | 2013-07-16 11:48:10 +0200 | [diff] [blame] | 3522 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 3523 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3524 | return 0; |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3525 | |
| 3526 | error: |
David Henningsson | 08cf680 | 2013-10-16 23:10:33 +0200 | [diff] [blame] | 3527 | cx_auto_free(codec); |
Takashi Iwai | aed523f | 2012-12-20 16:34:12 +0100 | [diff] [blame] | 3528 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3529 | } |
| 3530 | |
Takashi Iwai | bf92d1d | 2012-12-20 16:38:19 +0100 | [diff] [blame] | 3531 | #ifndef ENABLE_CXT_STATIC_QUIRKS |
| 3532 | #define patch_cxt5045 patch_conexant_auto |
| 3533 | #define patch_cxt5047 patch_conexant_auto |
| 3534 | #define patch_cxt5051 patch_conexant_auto |
| 3535 | #define patch_cxt5066 patch_conexant_auto |
| 3536 | #endif |
| 3537 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3538 | /* |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3539 | */ |
| 3540 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 3541 | static const struct hda_codec_preset snd_hda_preset_conexant[] = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 3542 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
| 3543 | .patch = patch_cxt5045 }, |
| 3544 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", |
| 3545 | .patch = patch_cxt5047 }, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3546 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
| 3547 | .patch = patch_cxt5051 }, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3548 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
| 3549 | .patch = patch_cxt5066 }, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3550 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
| 3551 | .patch = patch_cxt5066 }, |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 3552 | { .id = 0x14f15068, .name = "CX20584", |
| 3553 | .patch = patch_cxt5066 }, |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3554 | { .id = 0x14f15069, .name = "CX20585", |
| 3555 | .patch = patch_cxt5066 }, |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 3556 | { .id = 0x14f1506c, .name = "CX20588", |
| 3557 | .patch = patch_cxt5066 }, |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 3558 | { .id = 0x14f1506e, .name = "CX20590", |
| 3559 | .patch = patch_cxt5066 }, |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3560 | { .id = 0x14f15097, .name = "CX20631", |
| 3561 | .patch = patch_conexant_auto }, |
| 3562 | { .id = 0x14f15098, .name = "CX20632", |
| 3563 | .patch = patch_conexant_auto }, |
| 3564 | { .id = 0x14f150a1, .name = "CX20641", |
| 3565 | .patch = patch_conexant_auto }, |
| 3566 | { .id = 0x14f150a2, .name = "CX20642", |
| 3567 | .patch = patch_conexant_auto }, |
| 3568 | { .id = 0x14f150ab, .name = "CX20651", |
| 3569 | .patch = patch_conexant_auto }, |
| 3570 | { .id = 0x14f150ac, .name = "CX20652", |
| 3571 | .patch = patch_conexant_auto }, |
| 3572 | { .id = 0x14f150b8, .name = "CX20664", |
| 3573 | .patch = patch_conexant_auto }, |
| 3574 | { .id = 0x14f150b9, .name = "CX20665", |
| 3575 | .patch = patch_conexant_auto }, |
Takashi Iwai | 2d825fd | 2012-05-11 08:39:24 +0200 | [diff] [blame] | 3576 | { .id = 0x14f1510f, .name = "CX20751/2", |
| 3577 | .patch = patch_conexant_auto }, |
| 3578 | { .id = 0x14f15110, .name = "CX20751/2", |
| 3579 | .patch = patch_conexant_auto }, |
| 3580 | { .id = 0x14f15111, .name = "CX20753/4", |
| 3581 | .patch = patch_conexant_auto }, |
Takashi Iwai | 42c364a | 2013-01-21 16:53:37 +0100 | [diff] [blame] | 3582 | { .id = 0x14f15113, .name = "CX20755", |
| 3583 | .patch = patch_conexant_auto }, |
| 3584 | { .id = 0x14f15114, .name = "CX20756", |
| 3585 | .patch = patch_conexant_auto }, |
| 3586 | { .id = 0x14f15115, .name = "CX20757", |
| 3587 | .patch = patch_conexant_auto }, |
Takashi Iwai | 8f42d769 | 2013-11-06 18:47:42 +0100 | [diff] [blame] | 3588 | { .id = 0x14f151d7, .name = "CX20952", |
| 3589 | .patch = patch_conexant_auto }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 3590 | {} /* terminator */ |
| 3591 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 3592 | |
| 3593 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); |
| 3594 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
| 3595 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3596 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3597 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 3598 | MODULE_ALIAS("snd-hda-codec-id:14f15068"); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3599 | MODULE_ALIAS("snd-hda-codec-id:14f15069"); |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 3600 | MODULE_ALIAS("snd-hda-codec-id:14f1506c"); |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 3601 | MODULE_ALIAS("snd-hda-codec-id:14f1506e"); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3602 | MODULE_ALIAS("snd-hda-codec-id:14f15097"); |
| 3603 | MODULE_ALIAS("snd-hda-codec-id:14f15098"); |
| 3604 | MODULE_ALIAS("snd-hda-codec-id:14f150a1"); |
| 3605 | MODULE_ALIAS("snd-hda-codec-id:14f150a2"); |
| 3606 | MODULE_ALIAS("snd-hda-codec-id:14f150ab"); |
| 3607 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); |
| 3608 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); |
| 3609 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); |
Takashi Iwai | 2d825fd | 2012-05-11 08:39:24 +0200 | [diff] [blame] | 3610 | MODULE_ALIAS("snd-hda-codec-id:14f1510f"); |
| 3611 | MODULE_ALIAS("snd-hda-codec-id:14f15110"); |
| 3612 | MODULE_ALIAS("snd-hda-codec-id:14f15111"); |
Takashi Iwai | 42c364a | 2013-01-21 16:53:37 +0100 | [diff] [blame] | 3613 | MODULE_ALIAS("snd-hda-codec-id:14f15113"); |
| 3614 | MODULE_ALIAS("snd-hda-codec-id:14f15114"); |
| 3615 | MODULE_ALIAS("snd-hda-codec-id:14f15115"); |
Takashi Iwai | 8f42d769 | 2013-11-06 18:47:42 +0100 | [diff] [blame] | 3616 | MODULE_ALIAS("snd-hda-codec-id:14f151d7"); |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 3617 | |
| 3618 | MODULE_LICENSE("GPL"); |
| 3619 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
| 3620 | |
| 3621 | static struct hda_codec_preset_list conexant_list = { |
| 3622 | .preset = snd_hda_preset_conexant, |
| 3623 | .owner = THIS_MODULE, |
| 3624 | }; |
| 3625 | |
| 3626 | static int __init patch_conexant_init(void) |
| 3627 | { |
| 3628 | return snd_hda_add_codec_preset(&conexant_list); |
| 3629 | } |
| 3630 | |
| 3631 | static void __exit patch_conexant_exit(void) |
| 3632 | { |
| 3633 | snd_hda_delete_codec_preset(&conexant_list); |
| 3634 | } |
| 3635 | |
| 3636 | module_init(patch_conexant_init) |
| 3637 | module_exit(patch_conexant_exit) |