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