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