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" |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 36 | |
| 37 | #define CXT_PIN_DIR_IN 0x00 |
| 38 | #define CXT_PIN_DIR_OUT 0x01 |
| 39 | #define CXT_PIN_DIR_INOUT 0x02 |
| 40 | #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 |
| 41 | #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 |
| 42 | |
| 43 | #define CONEXANT_HP_EVENT 0x37 |
| 44 | #define CONEXANT_MIC_EVENT 0x38 |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 45 | #define CONEXANT_LINE_EVENT 0x39 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 46 | |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 47 | /* Conexant 5051 specific */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 48 | |
Takashi Iwai | ecda0cf | 2010-01-24 11:14:36 +0100 | [diff] [blame] | 49 | #define CXT5051_SPDIF_OUT 0x12 |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 50 | #define CXT5051_PORTB_EVENT 0x38 |
| 51 | #define CXT5051_PORTC_EVENT 0x39 |
| 52 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 53 | #define AUTO_MIC_PORTB (1 << 1) |
| 54 | #define AUTO_MIC_PORTC (1 << 2) |
Ulrich Dangel | bc7a166 | 2009-01-02 19:30:13 +0100 | [diff] [blame] | 55 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 56 | struct pin_dac_pair { |
| 57 | hda_nid_t pin; |
| 58 | hda_nid_t dac; |
| 59 | int type; |
| 60 | }; |
| 61 | |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 62 | struct imux_info { |
| 63 | hda_nid_t pin; /* input pin NID */ |
| 64 | hda_nid_t adc; /* connected ADC NID */ |
| 65 | hda_nid_t boost; /* optional boost volume NID */ |
| 66 | int index; /* corresponding to autocfg.input */ |
| 67 | }; |
| 68 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 69 | struct conexant_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 70 | struct hda_gen_spec gen; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 71 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 72 | const struct snd_kcontrol_new *mixers[5]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 73 | int num_mixers; |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 74 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 75 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 76 | bool vmaster_mute_led; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 77 | |
| 78 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
| 79 | * don't forget NULL |
| 80 | * termination! |
| 81 | */ |
| 82 | unsigned int num_init_verbs; |
| 83 | |
| 84 | /* playback */ |
| 85 | struct hda_multi_out multiout; /* playback set-up |
| 86 | * max_channels, dacs must be set |
| 87 | * dig_out_nid and hp_nid are optional |
| 88 | */ |
| 89 | unsigned int cur_eapd; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 90 | unsigned int hp_present; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 91 | unsigned int line_present; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 92 | unsigned int auto_mic; |
Takashi Iwai | f6100bb | 2011-05-13 18:26:39 +0200 | [diff] [blame] | 93 | int auto_mic_ext; /* imux_pins[] index for ext mic */ |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 94 | int auto_mic_dock; /* imux_pins[] index for dock mic */ |
| 95 | int auto_mic_int; /* imux_pins[] index for int mic */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 96 | unsigned int need_dac_fix; |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 97 | hda_nid_t slave_dig_outs[2]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 98 | |
| 99 | /* capture */ |
| 100 | unsigned int num_adc_nids; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 101 | const hda_nid_t *adc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 102 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 103 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 104 | unsigned int cur_adc_idx; |
| 105 | hda_nid_t cur_adc; |
| 106 | unsigned int cur_adc_stream_tag; |
| 107 | unsigned int cur_adc_format; |
| 108 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 109 | const struct hda_pcm_stream *capture_stream; |
| 110 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 111 | /* capture source */ |
| 112 | const struct hda_input_mux *input_mux; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 113 | const hda_nid_t *capsrc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 114 | unsigned int cur_mux[3]; |
| 115 | |
| 116 | /* channel model */ |
| 117 | const struct hda_channel_mode *channel_mode; |
| 118 | int num_channel_mode; |
| 119 | |
| 120 | /* PCM information */ |
| 121 | struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ |
| 122 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 123 | unsigned int spdif_route; |
| 124 | |
| 125 | /* dynamic controls, init_verbs and input_mux */ |
| 126 | struct auto_pin_cfg autocfg; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 127 | struct hda_input_mux private_imux; |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 128 | struct imux_info imux_info[HDA_MAX_NUM_INPUTS]; |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 129 | hda_nid_t private_adc_nids[HDA_MAX_NUM_INPUTS]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 130 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 131 | struct pin_dac_pair dac_info[8]; |
| 132 | int dac_info_filled; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 133 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 134 | unsigned int port_d_mode; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 135 | unsigned int auto_mute:1; /* used in auto-parser */ |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 136 | unsigned int detect_line:1; /* Line-out detection enabled */ |
| 137 | unsigned int automute_lines:1; /* automute line-out as well */ |
| 138 | unsigned int automute_hp_lo:1; /* both HP and LO available */ |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 139 | unsigned int dell_automute:1; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 140 | unsigned int dell_vostro:1; |
| 141 | unsigned int ideapad:1; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 142 | unsigned int thinkpad:1; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 143 | unsigned int hp_laptop:1; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 144 | unsigned int asus:1; |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 145 | unsigned int pin_eapd_ctrls:1; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 146 | unsigned int fixup_stereo_dmic:1; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 147 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 148 | unsigned int adc_switching:1; |
| 149 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 150 | unsigned int ext_mic_present; |
| 151 | unsigned int recording; |
| 152 | void (*capture_prepare)(struct hda_codec *codec); |
| 153 | void (*capture_cleanup)(struct hda_codec *codec); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 154 | |
| 155 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) |
| 156 | * through the microphone jack. |
| 157 | * When the user enables this through a mixer switch, both internal and |
| 158 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, |
| 159 | * we also allow the bias to be configured through a separate mixer |
| 160 | * control. */ |
| 161 | unsigned int dc_enable; |
| 162 | unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ |
| 163 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 164 | |
| 165 | unsigned int beep_amp; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 166 | |
| 167 | /* extra EAPD pins */ |
| 168 | unsigned int num_eapds; |
| 169 | hda_nid_t eapds[4]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 173 | struct hda_codec *codec, |
| 174 | struct snd_pcm_substream *substream) |
| 175 | { |
| 176 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 177 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 178 | hinfo); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 182 | struct hda_codec *codec, |
| 183 | unsigned int stream_tag, |
| 184 | unsigned int format, |
| 185 | struct snd_pcm_substream *substream) |
| 186 | { |
| 187 | struct conexant_spec *spec = codec->spec; |
| 188 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 189 | stream_tag, |
| 190 | format, substream); |
| 191 | } |
| 192 | |
| 193 | static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 194 | struct hda_codec *codec, |
| 195 | struct snd_pcm_substream *substream) |
| 196 | { |
| 197 | struct conexant_spec *spec = codec->spec; |
| 198 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * Digital out |
| 203 | */ |
| 204 | static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 205 | struct hda_codec *codec, |
| 206 | struct snd_pcm_substream *substream) |
| 207 | { |
| 208 | struct conexant_spec *spec = codec->spec; |
| 209 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 210 | } |
| 211 | |
| 212 | static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 213 | struct hda_codec *codec, |
| 214 | struct snd_pcm_substream *substream) |
| 215 | { |
| 216 | struct conexant_spec *spec = codec->spec; |
| 217 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 218 | } |
| 219 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 220 | static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 221 | struct hda_codec *codec, |
| 222 | unsigned int stream_tag, |
| 223 | unsigned int format, |
| 224 | struct snd_pcm_substream *substream) |
| 225 | { |
| 226 | struct conexant_spec *spec = codec->spec; |
| 227 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 228 | stream_tag, |
| 229 | format, substream); |
| 230 | } |
| 231 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 232 | /* |
| 233 | * Analog capture |
| 234 | */ |
| 235 | static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 236 | struct hda_codec *codec, |
| 237 | unsigned int stream_tag, |
| 238 | unsigned int format, |
| 239 | struct snd_pcm_substream *substream) |
| 240 | { |
| 241 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 242 | if (spec->capture_prepare) |
| 243 | spec->capture_prepare(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 244 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 245 | stream_tag, 0, format); |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 250 | struct hda_codec *codec, |
| 251 | struct snd_pcm_substream *substream) |
| 252 | { |
| 253 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 254 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 255 | if (spec->capture_cleanup) |
| 256 | spec->capture_cleanup(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 262 | static const struct hda_pcm_stream conexant_pcm_analog_playback = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 263 | .substreams = 1, |
| 264 | .channels_min = 2, |
| 265 | .channels_max = 2, |
| 266 | .nid = 0, /* fill later */ |
| 267 | .ops = { |
| 268 | .open = conexant_playback_pcm_open, |
| 269 | .prepare = conexant_playback_pcm_prepare, |
| 270 | .cleanup = conexant_playback_pcm_cleanup |
| 271 | }, |
| 272 | }; |
| 273 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 274 | static const struct hda_pcm_stream conexant_pcm_analog_capture = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 275 | .substreams = 1, |
| 276 | .channels_min = 2, |
| 277 | .channels_max = 2, |
| 278 | .nid = 0, /* fill later */ |
| 279 | .ops = { |
| 280 | .prepare = conexant_capture_pcm_prepare, |
| 281 | .cleanup = conexant_capture_pcm_cleanup |
| 282 | }, |
| 283 | }; |
| 284 | |
| 285 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 286 | static const struct hda_pcm_stream conexant_pcm_digital_playback = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 287 | .substreams = 1, |
| 288 | .channels_min = 2, |
| 289 | .channels_max = 2, |
| 290 | .nid = 0, /* fill later */ |
| 291 | .ops = { |
| 292 | .open = conexant_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 293 | .close = conexant_dig_playback_pcm_close, |
| 294 | .prepare = conexant_dig_playback_pcm_prepare |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 295 | }, |
| 296 | }; |
| 297 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 298 | static const struct hda_pcm_stream conexant_pcm_digital_capture = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 299 | .substreams = 1, |
| 300 | .channels_min = 2, |
| 301 | .channels_max = 2, |
| 302 | /* NID is set in alc_build_pcms */ |
| 303 | }; |
| 304 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 305 | static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 306 | struct hda_codec *codec, |
| 307 | unsigned int stream_tag, |
| 308 | unsigned int format, |
| 309 | struct snd_pcm_substream *substream) |
| 310 | { |
| 311 | struct conexant_spec *spec = codec->spec; |
| 312 | spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; |
| 313 | spec->cur_adc_stream_tag = stream_tag; |
| 314 | spec->cur_adc_format = format; |
| 315 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 316 | return 0; |
| 317 | } |
| 318 | |
| 319 | static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 320 | struct hda_codec *codec, |
| 321 | struct snd_pcm_substream *substream) |
| 322 | { |
| 323 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 324 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 325 | spec->cur_adc = 0; |
| 326 | return 0; |
| 327 | } |
| 328 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 329 | static const struct hda_pcm_stream cx5051_pcm_analog_capture = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 330 | .substreams = 1, |
| 331 | .channels_min = 2, |
| 332 | .channels_max = 2, |
| 333 | .nid = 0, /* fill later */ |
| 334 | .ops = { |
| 335 | .prepare = cx5051_capture_pcm_prepare, |
| 336 | .cleanup = cx5051_capture_pcm_cleanup |
| 337 | }, |
| 338 | }; |
| 339 | |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 340 | static bool is_2_1_speaker(struct conexant_spec *spec); |
| 341 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 342 | static int conexant_build_pcms(struct hda_codec *codec) |
| 343 | { |
| 344 | struct conexant_spec *spec = codec->spec; |
| 345 | struct hda_pcm *info = spec->pcm_rec; |
| 346 | |
| 347 | codec->num_pcms = 1; |
| 348 | codec->pcm_info = info; |
| 349 | |
| 350 | info->name = "CONEXANT Analog"; |
| 351 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; |
| 352 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 353 | spec->multiout.max_channels; |
| 354 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 355 | spec->multiout.dac_nids[0]; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 356 | if (is_2_1_speaker(spec)) |
| 357 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 358 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 359 | if (spec->capture_stream) |
| 360 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; |
| 361 | else { |
| 362 | if (codec->vendor_id == 0x14f15051) |
| 363 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 364 | cx5051_pcm_analog_capture; |
| 365 | else { |
| 366 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 367 | conexant_pcm_analog_capture; |
| 368 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 369 | spec->num_adc_nids; |
| 370 | } |
| 371 | } |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 372 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 373 | |
| 374 | if (spec->multiout.dig_out_nid) { |
| 375 | info++; |
| 376 | codec->num_pcms++; |
| 377 | info->name = "Conexant Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 378 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 379 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 380 | conexant_pcm_digital_playback; |
| 381 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 382 | spec->multiout.dig_out_nid; |
| 383 | if (spec->dig_in_nid) { |
| 384 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 385 | conexant_pcm_digital_capture; |
| 386 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 387 | spec->dig_in_nid; |
| 388 | } |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 389 | if (spec->slave_dig_outs[0]) |
| 390 | codec->slave_dig_outs = spec->slave_dig_outs; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 397 | struct snd_ctl_elem_info *uinfo) |
| 398 | { |
| 399 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 400 | struct conexant_spec *spec = codec->spec; |
| 401 | |
| 402 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 403 | } |
| 404 | |
| 405 | static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 406 | struct snd_ctl_elem_value *ucontrol) |
| 407 | { |
| 408 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 409 | struct conexant_spec *spec = codec->spec; |
| 410 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 411 | |
| 412 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 413 | return 0; |
| 414 | } |
| 415 | |
| 416 | static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 417 | struct snd_ctl_elem_value *ucontrol) |
| 418 | { |
| 419 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 420 | struct conexant_spec *spec = codec->spec; |
| 421 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 422 | |
| 423 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
| 424 | spec->capsrc_nids[adc_idx], |
| 425 | &spec->cur_mux[adc_idx]); |
| 426 | } |
| 427 | |
Takashi Iwai | 4d7fbdb | 2011-07-26 10:33:10 +0200 | [diff] [blame] | 428 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, |
| 429 | unsigned int power_state) |
| 430 | { |
| 431 | if (power_state == AC_PWRST_D3) |
| 432 | msleep(100); |
| 433 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, |
| 434 | power_state); |
| 435 | /* partial workaround for "azx_get_response timeout" */ |
| 436 | if (power_state == AC_PWRST_D0) |
| 437 | msleep(10); |
| 438 | snd_hda_codec_set_power_to_all(codec, fg, power_state, true); |
| 439 | } |
| 440 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 441 | static int conexant_init(struct hda_codec *codec) |
| 442 | { |
| 443 | struct conexant_spec *spec = codec->spec; |
| 444 | int i; |
| 445 | |
| 446 | for (i = 0; i < spec->num_init_verbs; i++) |
| 447 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
| 448 | return 0; |
| 449 | } |
| 450 | |
| 451 | static void conexant_free(struct hda_codec *codec) |
| 452 | { |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 453 | struct conexant_spec *spec = codec->spec; |
| 454 | snd_hda_gen_free(&spec->gen); |
Einar Rünkaru | c0f8faf | 2009-12-16 22:41:36 +0200 | [diff] [blame] | 455 | snd_hda_detach_beep_device(codec); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 456 | kfree(spec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 457 | } |
| 458 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 459 | static const struct snd_kcontrol_new cxt_capture_mixers[] = { |
Takashi Iwai | b880c74 | 2009-03-10 14:41:05 +0100 | [diff] [blame] | 460 | { |
| 461 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 462 | .name = "Capture Source", |
| 463 | .info = conexant_mux_enum_info, |
| 464 | .get = conexant_mux_enum_get, |
| 465 | .put = conexant_mux_enum_put |
| 466 | }, |
| 467 | {} |
| 468 | }; |
| 469 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 470 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 471 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 472 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 473 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), |
| 474 | HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), |
| 475 | { } /* end */ |
| 476 | }; |
| 477 | #endif |
| 478 | |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 479 | static const char * const slave_pfxs[] = { |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 480 | "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 481 | NULL |
| 482 | }; |
| 483 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 484 | static int conexant_build_controls(struct hda_codec *codec) |
| 485 | { |
| 486 | struct conexant_spec *spec = codec->spec; |
| 487 | unsigned int i; |
| 488 | int err; |
| 489 | |
| 490 | for (i = 0; i < spec->num_mixers; i++) { |
| 491 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 492 | if (err < 0) |
| 493 | return err; |
| 494 | } |
| 495 | if (spec->multiout.dig_out_nid) { |
| 496 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 497 | spec->multiout.dig_out_nid, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 498 | spec->multiout.dig_out_nid); |
| 499 | if (err < 0) |
| 500 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 501 | err = snd_hda_create_spdif_share_sw(codec, |
| 502 | &spec->multiout); |
| 503 | if (err < 0) |
| 504 | return err; |
| 505 | spec->multiout.share_spdif = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 506 | } |
| 507 | if (spec->dig_in_nid) { |
| 508 | err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); |
| 509 | if (err < 0) |
| 510 | return err; |
| 511 | } |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 512 | |
| 513 | /* if we have no master control, let's create it */ |
| 514 | if (spec->vmaster_nid && |
| 515 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
| 516 | unsigned int vmaster_tlv[4]; |
| 517 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
| 518 | HDA_OUTPUT, vmaster_tlv); |
| 519 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 520 | vmaster_tlv, slave_pfxs, |
| 521 | "Playback Volume"); |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 522 | if (err < 0) |
| 523 | return err; |
| 524 | } |
| 525 | if (spec->vmaster_nid && |
| 526 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 527 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 528 | NULL, slave_pfxs, |
| 529 | "Playback Switch", true, |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 530 | &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 531 | if (err < 0) |
| 532 | return err; |
| 533 | } |
| 534 | |
Takashi Iwai | b880c74 | 2009-03-10 14:41:05 +0100 | [diff] [blame] | 535 | if (spec->input_mux) { |
| 536 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); |
| 537 | if (err < 0) |
| 538 | return err; |
| 539 | } |
| 540 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 541 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 542 | /* create beep controls if needed */ |
| 543 | if (spec->beep_amp) { |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 544 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 545 | for (knew = cxt_beep_mixer; knew->name; knew++) { |
| 546 | struct snd_kcontrol *kctl; |
| 547 | kctl = snd_ctl_new1(knew, codec); |
| 548 | if (!kctl) |
| 549 | return -ENOMEM; |
| 550 | kctl->private_value = spec->beep_amp; |
| 551 | err = snd_hda_ctl_add(codec, 0, kctl); |
| 552 | if (err < 0) |
| 553 | return err; |
| 554 | } |
| 555 | } |
| 556 | #endif |
| 557 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 558 | return 0; |
| 559 | } |
| 560 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 561 | #ifdef CONFIG_PM |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 562 | static int conexant_suspend(struct hda_codec *codec) |
Takashi Iwai | 697c373 | 2010-07-30 11:28:02 +0200 | [diff] [blame] | 563 | { |
| 564 | snd_hda_shutup_pins(codec); |
| 565 | return 0; |
| 566 | } |
| 567 | #endif |
| 568 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 569 | static const struct hda_codec_ops conexant_patch_ops = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 570 | .build_controls = conexant_build_controls, |
| 571 | .build_pcms = conexant_build_pcms, |
| 572 | .init = conexant_init, |
| 573 | .free = conexant_free, |
Takashi Iwai | 4d7fbdb | 2011-07-26 10:33:10 +0200 | [diff] [blame] | 574 | .set_power_state = conexant_set_power, |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 575 | #ifdef CONFIG_PM |
Takashi Iwai | 697c373 | 2010-07-30 11:28:02 +0200 | [diff] [blame] | 576 | .suspend = conexant_suspend, |
| 577 | #endif |
| 578 | .reboot_notify = snd_hda_shutup_pins, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 579 | }; |
| 580 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 581 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 582 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 583 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) |
| 584 | #else |
| 585 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 586 | #endif |
| 587 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 588 | static int patch_conexant_auto(struct hda_codec *codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 589 | /* |
| 590 | * EAPD control |
| 591 | * the private value = nid | (invert << 8) |
| 592 | */ |
| 593 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 594 | #define cxt_eapd_info snd_ctl_boolean_mono_info |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 595 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 596 | static int cxt_eapd_get(struct snd_kcontrol *kcontrol, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 597 | struct snd_ctl_elem_value *ucontrol) |
| 598 | { |
| 599 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 600 | struct conexant_spec *spec = codec->spec; |
| 601 | int invert = (kcontrol->private_value >> 8) & 1; |
| 602 | if (invert) |
| 603 | ucontrol->value.integer.value[0] = !spec->cur_eapd; |
| 604 | else |
| 605 | ucontrol->value.integer.value[0] = spec->cur_eapd; |
| 606 | return 0; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 607 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 608 | } |
| 609 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 610 | static int cxt_eapd_put(struct snd_kcontrol *kcontrol, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 611 | struct snd_ctl_elem_value *ucontrol) |
| 612 | { |
| 613 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 614 | struct conexant_spec *spec = codec->spec; |
| 615 | int invert = (kcontrol->private_value >> 8) & 1; |
| 616 | hda_nid_t nid = kcontrol->private_value & 0xff; |
| 617 | unsigned int eapd; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 618 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 619 | eapd = !!ucontrol->value.integer.value[0]; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 620 | if (invert) |
| 621 | eapd = !eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 622 | if (eapd == spec->cur_eapd) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 623 | return 0; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 624 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 625 | spec->cur_eapd = eapd; |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 626 | snd_hda_codec_write_cache(codec, nid, |
| 627 | 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 628 | eapd ? 0x02 : 0x00); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 629 | return 1; |
| 630 | } |
| 631 | |
Takashi Iwai | 86d72bd | 2006-11-28 11:33:10 +0100 | [diff] [blame] | 632 | /* controls for test mode */ |
| 633 | #ifdef CONFIG_SND_DEBUG |
| 634 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 635 | #define CXT_EAPD_SWITCH(xname, nid, mask) \ |
| 636 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 637 | .info = cxt_eapd_info, \ |
| 638 | .get = cxt_eapd_get, \ |
| 639 | .put = cxt_eapd_put, \ |
| 640 | .private_value = nid | (mask<<16) } |
| 641 | |
| 642 | |
| 643 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 644 | static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 645 | struct snd_ctl_elem_info *uinfo) |
| 646 | { |
| 647 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 648 | struct conexant_spec *spec = codec->spec; |
| 649 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
| 650 | spec->num_channel_mode); |
| 651 | } |
| 652 | |
| 653 | static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 654 | struct snd_ctl_elem_value *ucontrol) |
| 655 | { |
| 656 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 657 | struct conexant_spec *spec = codec->spec; |
| 658 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
| 659 | spec->num_channel_mode, |
| 660 | spec->multiout.max_channels); |
| 661 | } |
| 662 | |
| 663 | static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_value *ucontrol) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct conexant_spec *spec = codec->spec; |
| 668 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
| 669 | spec->num_channel_mode, |
| 670 | &spec->multiout.max_channels); |
| 671 | if (err >= 0 && spec->need_dac_fix) |
| 672 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
| 673 | return err; |
| 674 | } |
| 675 | |
| 676 | #define CXT_PIN_MODE(xname, nid, dir) \ |
| 677 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
| 678 | .info = conexant_ch_mode_info, \ |
| 679 | .get = conexant_ch_mode_get, \ |
| 680 | .put = conexant_ch_mode_put, \ |
| 681 | .private_value = nid | (dir<<16) } |
| 682 | |
Takashi Iwai | 86d72bd | 2006-11-28 11:33:10 +0100 | [diff] [blame] | 683 | #endif /* CONFIG_SND_DEBUG */ |
| 684 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 685 | /* Conexant 5045 specific */ |
| 686 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 687 | static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; |
| 688 | static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; |
| 689 | static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 690 | #define CXT5045_SPDIF_OUT 0x18 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 691 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 692 | static const struct hda_channel_mode cxt5045_modes[1] = { |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 693 | { 2, NULL }, |
| 694 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 695 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 696 | static const struct hda_input_mux cxt5045_capture_source = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 697 | .num_items = 2, |
| 698 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 699 | { "Internal Mic", 0x1 }, |
| 700 | { "Mic", 0x2 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 701 | } |
| 702 | }; |
| 703 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 704 | static const struct hda_input_mux cxt5045_capture_source_benq = { |
Michael Karcher | e6e03da | 2012-04-06 15:34:18 +0200 | [diff] [blame] | 705 | .num_items = 4, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 706 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 707 | { "Internal Mic", 0x1 }, |
| 708 | { "Mic", 0x2 }, |
| 709 | { "Line", 0x3 }, |
| 710 | { "Mixer", 0x0 }, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 711 | } |
| 712 | }; |
| 713 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 714 | static const struct hda_input_mux cxt5045_capture_source_hp530 = { |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 715 | .num_items = 2, |
| 716 | .items = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 717 | { "Mic", 0x1 }, |
| 718 | { "Internal Mic", 0x2 }, |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 719 | } |
| 720 | }; |
| 721 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 722 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 723 | static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 724 | struct snd_ctl_elem_value *ucontrol) |
| 725 | { |
| 726 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 727 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 728 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 729 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 730 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 731 | return 0; |
| 732 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 733 | /* toggle internal speakers mute depending of presence of |
| 734 | * the headphone jack |
| 735 | */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 736 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
| 737 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
| 738 | HDA_AMP_MUTE, bits); |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 739 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 740 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
| 741 | snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, |
| 742 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 743 | return 1; |
| 744 | } |
| 745 | |
| 746 | /* bind volumes of both NID 0x10 and 0x11 */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 747 | static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 748 | .ops = &snd_hda_bind_vol, |
| 749 | .values = { |
| 750 | HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), |
| 751 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), |
| 752 | 0 |
| 753 | }, |
| 754 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 755 | |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 756 | /* toggle input of built-in and mic jack appropriately */ |
| 757 | static void cxt5045_hp_automic(struct hda_codec *codec) |
| 758 | { |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 759 | static const struct hda_verb mic_jack_on[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 760 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 761 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 762 | {} |
| 763 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 764 | static const struct hda_verb mic_jack_off[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 765 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
| 766 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 767 | {} |
| 768 | }; |
| 769 | unsigned int present; |
| 770 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 771 | present = snd_hda_jack_detect(codec, 0x12); |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 772 | if (present) |
| 773 | snd_hda_sequence_write(codec, mic_jack_on); |
| 774 | else |
| 775 | snd_hda_sequence_write(codec, mic_jack_off); |
| 776 | } |
| 777 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 778 | |
| 779 | /* mute internal speaker if HP is plugged */ |
| 780 | static void cxt5045_hp_automute(struct hda_codec *codec) |
| 781 | { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 782 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 783 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 784 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 785 | spec->hp_present = snd_hda_jack_detect(codec, 0x11); |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 786 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 787 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
| 788 | snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, |
| 789 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | /* unsolicited event for HP jack sensing */ |
| 793 | static void cxt5045_hp_unsol_event(struct hda_codec *codec, |
| 794 | unsigned int res) |
| 795 | { |
| 796 | res >>= 26; |
| 797 | switch (res) { |
| 798 | case CONEXANT_HP_EVENT: |
| 799 | cxt5045_hp_automute(codec); |
| 800 | break; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 801 | case CONEXANT_MIC_EVENT: |
| 802 | cxt5045_hp_automic(codec); |
| 803 | break; |
| 804 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 805 | } |
| 806 | } |
| 807 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 808 | static const struct snd_kcontrol_new cxt5045_mixers[] = { |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 809 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), |
| 810 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Takashi Iwai | c8229c3 | 2007-10-19 08:06:21 +0200 | [diff] [blame] | 811 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
| 812 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 813 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
| 814 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 815 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
| 816 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 817 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 818 | { |
| 819 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 820 | .name = "Master Playback Switch", |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 821 | .info = cxt_eapd_info, |
| 822 | .get = cxt_eapd_get, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 823 | .put = cxt5045_hp_master_sw_put, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 824 | .private_value = 0x10, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 825 | }, |
| 826 | |
| 827 | {} |
| 828 | }; |
| 829 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 830 | static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { |
Michael Karcher | 3edbbb9 | 2012-04-06 15:34:16 +0200 | [diff] [blame] | 831 | HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), |
| 832 | HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), |
Lukasz Marcinowski | 22e1413 | 2009-09-22 21:42:40 +0200 | [diff] [blame] | 833 | |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 834 | {} |
| 835 | }; |
| 836 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 837 | static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 838 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), |
| 839 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 840 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), |
| 841 | HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 842 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), |
| 843 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 844 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), |
| 845 | HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 846 | HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), |
| 847 | { |
| 848 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 849 | .name = "Master Playback Switch", |
| 850 | .info = cxt_eapd_info, |
| 851 | .get = cxt_eapd_get, |
| 852 | .put = cxt5045_hp_master_sw_put, |
| 853 | .private_value = 0x10, |
| 854 | }, |
| 855 | |
| 856 | {} |
| 857 | }; |
| 858 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 859 | static const struct hda_verb cxt5045_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 860 | /* Line in, Mic */ |
Takashi Iwai | 4090dff | 2008-07-12 12:02:45 +0200 | [diff] [blame] | 861 | {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] | 862 | {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] | 863 | /* HP, Amp */ |
Takashi Iwai | c8229c3 | 2007-10-19 08:06:21 +0200 | [diff] [blame] | 864 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 865 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 866 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 867 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 868 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 869 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 870 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 871 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 872 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 873 | /* Record selector: Internal mic */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 874 | {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 875 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 876 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 877 | /* SPDIF route: PCM */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 878 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 879 | { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 880 | /* EAPD */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 881 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 882 | { } /* end */ |
| 883 | }; |
| 884 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 885 | static const struct hda_verb cxt5045_benq_init_verbs[] = { |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 886 | /* Internal Mic, Mic */ |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 887 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
| 888 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, |
| 889 | /* Line In,HP, Amp */ |
| 890 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 891 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 892 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 893 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 894 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 895 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 896 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 897 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 898 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 899 | /* Record selector: Internal mic */ |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 900 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 901 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, |
| 902 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 903 | /* SPDIF route: PCM */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 904 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 905 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 906 | /* EAPD */ |
| 907 | {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 908 | { } /* end */ |
| 909 | }; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 910 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 911 | static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 912 | /* pin sensing on HP jack */ |
| 913 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
Takashi Iwai | d3091fa | 2007-03-28 15:11:53 +0200 | [diff] [blame] | 914 | { } /* end */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 915 | }; |
| 916 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 917 | static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 918 | /* pin sensing on HP jack */ |
| 919 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
Takashi Iwai | d3091fa | 2007-03-28 15:11:53 +0200 | [diff] [blame] | 920 | { } /* end */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 921 | }; |
| 922 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 923 | #ifdef CONFIG_SND_DEBUG |
| 924 | /* Test configuration for debugging, modelled after the ALC260 test |
| 925 | * configuration. |
| 926 | */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 927 | static const struct hda_input_mux cxt5045_test_capture_source = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 928 | .num_items = 5, |
| 929 | .items = { |
| 930 | { "MIXER", 0x0 }, |
| 931 | { "MIC1 pin", 0x1 }, |
| 932 | { "LINE1 pin", 0x2 }, |
| 933 | { "HP-OUT pin", 0x3 }, |
| 934 | { "CD pin", 0x4 }, |
| 935 | }, |
| 936 | }; |
| 937 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 938 | static const struct snd_kcontrol_new cxt5045_test_mixer[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 939 | |
| 940 | /* Output controls */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 941 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), |
| 942 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 943 | HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
| 944 | HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
| 945 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
| 946 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 947 | |
| 948 | /* Modes for retasking pin widgets */ |
| 949 | CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), |
| 950 | CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), |
| 951 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 952 | /* EAPD Switch Control */ |
| 953 | CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), |
| 954 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 955 | /* Loopback mixer controls */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 956 | |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 957 | HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), |
| 958 | HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), |
| 959 | HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), |
| 960 | HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), |
| 961 | HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), |
| 962 | HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), |
| 963 | HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), |
| 964 | HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), |
| 965 | HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), |
| 966 | HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 967 | { |
| 968 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 969 | .name = "Input Source", |
| 970 | .info = conexant_mux_enum_info, |
| 971 | .get = conexant_mux_enum_get, |
| 972 | .put = conexant_mux_enum_put, |
| 973 | }, |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 974 | /* Audio input controls */ |
Michael Karcher | cbf2d28 | 2012-04-06 15:34:17 +0200 | [diff] [blame] | 975 | HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), |
| 976 | HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 977 | { } /* end */ |
| 978 | }; |
| 979 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 980 | static const struct hda_verb cxt5045_test_init_verbs[] = { |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 981 | /* Set connections */ |
| 982 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
| 983 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
| 984 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 985 | /* Enable retasking pins as output, initially without power amp */ |
| 986 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 987 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 988 | |
| 989 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 990 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 991 | * payload also sets the generation to 0, output to be in "consumer" |
| 992 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 993 | * control. |
| 994 | */ |
Takashi Iwai | cbef978 | 2008-02-22 18:36:46 +0100 | [diff] [blame] | 995 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 996 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 997 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 998 | /* Unmute retasking pin widget output buffers since the default |
| 999 | * state appears to be output. As the pin mode is changed by the |
| 1000 | * user the pin mode control will take care of enabling the pin's |
| 1001 | * input/output buffers as needed. |
| 1002 | */ |
| 1003 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1004 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1005 | |
| 1006 | /* Mute capture amp left and right */ |
| 1007 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1008 | |
| 1009 | /* Set ADC connection select to match default mixer setting (mic1 |
| 1010 | * pin) |
| 1011 | */ |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 1012 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1013 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1014 | |
| 1015 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
Michael Karcher | 250f327 | 2012-04-06 15:34:20 +0200 | [diff] [blame] | 1016 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1017 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ |
| 1018 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ |
| 1019 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ |
| 1020 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 1021 | |
| 1022 | { } |
| 1023 | }; |
| 1024 | #endif |
| 1025 | |
| 1026 | |
| 1027 | /* initialize jack-sensing, too */ |
| 1028 | static int cxt5045_init(struct hda_codec *codec) |
| 1029 | { |
| 1030 | conexant_init(codec); |
| 1031 | cxt5045_hp_automute(codec); |
| 1032 | return 0; |
| 1033 | } |
| 1034 | |
| 1035 | |
| 1036 | enum { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1037 | CXT5045_LAPTOP_HPSENSE, |
| 1038 | CXT5045_LAPTOP_MICSENSE, |
| 1039 | CXT5045_LAPTOP_HPMICSENSE, |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1040 | CXT5045_BENQ, |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1041 | CXT5045_LAPTOP_HP530, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1042 | #ifdef CONFIG_SND_DEBUG |
| 1043 | CXT5045_TEST, |
| 1044 | #endif |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1045 | CXT5045_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1046 | CXT5045_MODELS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1047 | }; |
| 1048 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1049 | static const char * const cxt5045_models[CXT5045_MODELS] = { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1050 | [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", |
| 1051 | [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", |
| 1052 | [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", |
| 1053 | [CXT5045_BENQ] = "benq", |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1054 | [CXT5045_LAPTOP_HP530] = "laptop-hp530", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1055 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1056 | [CXT5045_TEST] = "test", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1057 | #endif |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1058 | [CXT5045_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1059 | }; |
| 1060 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1061 | static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1062 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), |
Takashi Iwai | 6a9dccd | 2008-07-01 14:52:05 +0200 | [diff] [blame] | 1063 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1064 | SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1065 | SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), |
| 1066 | SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), |
Takashi Iwai | 9e46415 | 2008-07-12 12:05:25 +0200 | [diff] [blame] | 1067 | SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", |
| 1068 | CXT5045_LAPTOP_HPMICSENSE), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1069 | SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
| 1070 | SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
| 1071 | SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1072 | SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", |
| 1073 | CXT5045_LAPTOP_HPMICSENSE), |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1074 | SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1075 | {} |
| 1076 | }; |
| 1077 | |
| 1078 | static int patch_cxt5045(struct hda_codec *codec) |
| 1079 | { |
| 1080 | struct conexant_spec *spec; |
| 1081 | int board_config; |
| 1082 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1083 | board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, |
| 1084 | cxt5045_models, |
| 1085 | cxt5045_cfg_tbl); |
| 1086 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1087 | board_config = CXT5045_AUTO; /* model=auto as default */ |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1088 | if (board_config == CXT5045_AUTO) |
| 1089 | return patch_conexant_auto(codec); |
| 1090 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1091 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1092 | if (!spec) |
| 1093 | return -ENOMEM; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1094 | codec->spec = spec; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 1095 | codec->single_adc_amp = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1096 | |
| 1097 | spec->multiout.max_channels = 2; |
| 1098 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); |
| 1099 | spec->multiout.dac_nids = cxt5045_dac_nids; |
| 1100 | spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; |
| 1101 | spec->num_adc_nids = 1; |
| 1102 | spec->adc_nids = cxt5045_adc_nids; |
| 1103 | spec->capsrc_nids = cxt5045_capsrc_nids; |
| 1104 | spec->input_mux = &cxt5045_capture_source; |
| 1105 | spec->num_mixers = 1; |
| 1106 | spec->mixers[0] = cxt5045_mixers; |
| 1107 | spec->num_init_verbs = 1; |
| 1108 | spec->init_verbs[0] = cxt5045_init_verbs; |
| 1109 | spec->spdif_route = 0; |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1110 | spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); |
| 1111 | spec->channel_mode = cxt5045_modes; |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1112 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1113 | set_beep_amp(spec, 0x16, 0, 1); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1114 | |
| 1115 | codec->patch_ops = conexant_patch_ops; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1116 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1117 | switch (board_config) { |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1118 | case CXT5045_LAPTOP_HPSENSE: |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1119 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1120 | spec->input_mux = &cxt5045_capture_source; |
| 1121 | spec->num_init_verbs = 2; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1122 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1123 | spec->mixers[0] = cxt5045_mixers; |
| 1124 | codec->patch_ops.init = cxt5045_init; |
| 1125 | break; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1126 | case CXT5045_LAPTOP_MICSENSE: |
Takashi Iwai | 86376df | 2008-07-12 12:04:05 +0200 | [diff] [blame] | 1127 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1128 | spec->input_mux = &cxt5045_capture_source; |
| 1129 | spec->num_init_verbs = 2; |
| 1130 | spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1131 | spec->mixers[0] = cxt5045_mixers; |
| 1132 | codec->patch_ops.init = cxt5045_init; |
| 1133 | break; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1134 | default: |
| 1135 | case CXT5045_LAPTOP_HPMICSENSE: |
| 1136 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1137 | spec->input_mux = &cxt5045_capture_source; |
| 1138 | spec->num_init_verbs = 3; |
| 1139 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1140 | spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; |
| 1141 | spec->mixers[0] = cxt5045_mixers; |
| 1142 | codec->patch_ops.init = cxt5045_init; |
| 1143 | break; |
Jiang Zhe | 5218c89 | 2008-01-17 11:18:41 +0100 | [diff] [blame] | 1144 | case CXT5045_BENQ: |
| 1145 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1146 | spec->input_mux = &cxt5045_capture_source_benq; |
| 1147 | spec->num_init_verbs = 1; |
| 1148 | spec->init_verbs[0] = cxt5045_benq_init_verbs; |
| 1149 | spec->mixers[0] = cxt5045_mixers; |
| 1150 | spec->mixers[1] = cxt5045_benq_mixers; |
| 1151 | spec->num_mixers = 2; |
| 1152 | codec->patch_ops.init = cxt5045_init; |
| 1153 | break; |
Jiang zhe | 2de3c23 | 2008-03-06 11:09:09 +0100 | [diff] [blame] | 1154 | case CXT5045_LAPTOP_HP530: |
| 1155 | codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; |
| 1156 | spec->input_mux = &cxt5045_capture_source_hp530; |
| 1157 | spec->num_init_verbs = 2; |
| 1158 | spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; |
| 1159 | spec->mixers[0] = cxt5045_mixers_hp530; |
| 1160 | codec->patch_ops.init = cxt5045_init; |
| 1161 | break; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1162 | #ifdef CONFIG_SND_DEBUG |
| 1163 | case CXT5045_TEST: |
| 1164 | spec->input_mux = &cxt5045_test_capture_source; |
| 1165 | spec->mixers[0] = cxt5045_test_mixer; |
| 1166 | spec->init_verbs[0] = cxt5045_test_init_verbs; |
Marc Boucher | 15908c3 | 2008-01-22 15:15:59 +0100 | [diff] [blame] | 1167 | break; |
| 1168 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1169 | #endif |
| 1170 | } |
Takashi Iwai | 48ecb7e | 2007-12-17 14:32:49 +0100 | [diff] [blame] | 1171 | |
Takashi Iwai | 031005f | 2008-06-26 14:49:58 +0200 | [diff] [blame] | 1172 | switch (codec->subsystem_id >> 16) { |
| 1173 | case 0x103c: |
Daniel T Chen | 8f0f5ff | 2010-04-28 18:00:11 -0400 | [diff] [blame] | 1174 | case 0x1631: |
Daniel T Chen | 0b587fc | 2009-11-25 18:27:20 -0500 | [diff] [blame] | 1175 | case 0x1734: |
Daniel T Chen | 0ebf9e3 | 2010-05-10 21:50:04 +0200 | [diff] [blame] | 1176 | case 0x17aa: |
| 1177 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have |
| 1178 | * really bad sound over 0dB on NID 0x17. Fix max PCM level to |
| 1179 | * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) |
Takashi Iwai | 031005f | 2008-06-26 14:49:58 +0200 | [diff] [blame] | 1180 | */ |
| 1181 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, |
| 1182 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1183 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1184 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1185 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 1186 | break; |
| 1187 | } |
Takashi Iwai | 48ecb7e | 2007-12-17 14:32:49 +0100 | [diff] [blame] | 1188 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1189 | if (spec->beep_amp) |
| 1190 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
| 1191 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1192 | return 0; |
| 1193 | } |
| 1194 | |
| 1195 | |
| 1196 | /* Conexant 5047 specific */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1197 | #define CXT5047_SPDIF_OUT 0x11 |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1198 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1199 | static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ |
| 1200 | static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; |
| 1201 | static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1202 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1203 | static const struct hda_channel_mode cxt5047_modes[1] = { |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1204 | { 2, NULL }, |
| 1205 | }; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1206 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1207 | static const struct hda_input_mux cxt5047_toshiba_capture_source = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1208 | .num_items = 2, |
| 1209 | .items = { |
| 1210 | { "ExtMic", 0x2 }, |
| 1211 | { "Line-In", 0x1 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1212 | } |
| 1213 | }; |
| 1214 | |
| 1215 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1216 | static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1217 | struct snd_ctl_elem_value *ucontrol) |
| 1218 | { |
| 1219 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1220 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1221 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1222 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1223 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1224 | return 0; |
| 1225 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1226 | /* toggle internal speakers mute depending of presence of |
| 1227 | * the headphone jack |
| 1228 | */ |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1229 | bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1230 | /* NOTE: Conexat codec needs the index for *OUTPUT* amp of |
| 1231 | * pin widgets unlike other codecs. In this case, we need to |
| 1232 | * set index 0x01 for the volume from the mixer amp 0x19. |
| 1233 | */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1234 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1235 | HDA_AMP_MUTE, bits); |
| 1236 | bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; |
| 1237 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, |
| 1238 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1239 | return 1; |
| 1240 | } |
| 1241 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1242 | /* mute internal speaker if HP is plugged */ |
| 1243 | static void cxt5047_hp_automute(struct hda_codec *codec) |
| 1244 | { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1245 | struct conexant_spec *spec = codec->spec; |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 1246 | unsigned int bits; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1247 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1248 | spec->hp_present = snd_hda_jack_detect(codec, 0x13); |
Tobin Davis | dd87da1 | 2007-02-26 16:07:42 +0100 | [diff] [blame] | 1249 | |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1250 | bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1251 | /* See the note in cxt5047_hp_master_sw_put */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1252 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, |
Takashi Iwai | 47fd830 | 2007-08-10 17:11:07 +0200 | [diff] [blame] | 1253 | HDA_AMP_MUTE, bits); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | /* toggle input of built-in and mic jack appropriately */ |
| 1257 | static void cxt5047_hp_automic(struct hda_codec *codec) |
| 1258 | { |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1259 | static const struct hda_verb mic_jack_on[] = { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1260 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1261 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1262 | {} |
| 1263 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1264 | static const struct hda_verb mic_jack_off[] = { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1265 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 1266 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1267 | {} |
| 1268 | }; |
| 1269 | unsigned int present; |
| 1270 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1271 | present = snd_hda_jack_detect(codec, 0x15); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1272 | if (present) |
| 1273 | snd_hda_sequence_write(codec, mic_jack_on); |
| 1274 | else |
| 1275 | snd_hda_sequence_write(codec, mic_jack_off); |
| 1276 | } |
| 1277 | |
| 1278 | /* unsolicited event for HP jack sensing */ |
| 1279 | static void cxt5047_hp_unsol_event(struct hda_codec *codec, |
| 1280 | unsigned int res) |
| 1281 | { |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1282 | switch (res >> 26) { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1283 | case CONEXANT_HP_EVENT: |
| 1284 | cxt5047_hp_automute(codec); |
| 1285 | break; |
| 1286 | case CONEXANT_MIC_EVENT: |
| 1287 | cxt5047_hp_automic(codec); |
| 1288 | break; |
| 1289 | } |
| 1290 | } |
| 1291 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1292 | static const struct snd_kcontrol_new cxt5047_base_mixers[] = { |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1293 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), |
| 1294 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), |
David Henningsson | 5f99f86 | 2011-01-04 15:24:24 +0100 | [diff] [blame] | 1295 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1296 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
| 1297 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), |
| 1298 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), |
| 1299 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1300 | { |
| 1301 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1302 | .name = "Master Playback Switch", |
| 1303 | .info = cxt_eapd_info, |
| 1304 | .get = cxt_eapd_get, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1305 | .put = cxt5047_hp_master_sw_put, |
| 1306 | .private_value = 0x13, |
| 1307 | }, |
| 1308 | |
| 1309 | {} |
| 1310 | }; |
| 1311 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1312 | static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
Takashi Iwai | 3b7523f | 2009-03-12 16:45:01 +0100 | [diff] [blame] | 1313 | /* See the note in cxt5047_hp_master_sw_put */ |
Gregorio Guidi | 5d75bc5 | 2009-03-12 16:41:51 +0100 | [diff] [blame] | 1314 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1315 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
| 1316 | {} |
| 1317 | }; |
| 1318 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1319 | static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1320 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1321 | { } /* end */ |
| 1322 | }; |
| 1323 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1324 | static const struct hda_verb cxt5047_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1325 | /* Line in, Mic, Built-in Mic */ |
| 1326 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
| 1327 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, |
| 1328 | {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] | 1329 | /* HP, Speaker */ |
Tobin Davis | b7589ce | 2007-04-24 17:56:55 +0200 | [diff] [blame] | 1330 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
Takashi Iwai | 5b3a744 | 2009-03-10 15:10:55 +0100 | [diff] [blame] | 1331 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ |
| 1332 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ |
Tobin Davis | 7f29673 | 2007-03-12 11:39:01 +0100 | [diff] [blame] | 1333 | /* Record selector: Mic */ |
| 1334 | {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, |
| 1335 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1336 | AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, |
| 1337 | {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1338 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1339 | AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, |
| 1340 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1341 | 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] | 1342 | /* SPDIF route: PCM */ |
| 1343 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1344 | /* Enable unsolicited events */ |
| 1345 | {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 1346 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1347 | { } /* end */ |
| 1348 | }; |
| 1349 | |
| 1350 | /* configuration for Toshiba Laptops */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1351 | static const struct hda_verb cxt5047_toshiba_init_verbs[] = { |
Takashi Iwai | 3b62886 | 2009-03-10 14:53:54 +0100 | [diff] [blame] | 1352 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1353 | {} |
| 1354 | }; |
| 1355 | |
| 1356 | /* Test configuration for debugging, modelled after the ALC260 test |
| 1357 | * configuration. |
| 1358 | */ |
| 1359 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1360 | static const struct hda_input_mux cxt5047_test_capture_source = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1361 | .num_items = 4, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1362 | .items = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1363 | { "LINE1 pin", 0x0 }, |
| 1364 | { "MIC1 pin", 0x1 }, |
| 1365 | { "MIC2 pin", 0x2 }, |
| 1366 | { "CD pin", 0x3 }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1367 | }, |
| 1368 | }; |
| 1369 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1370 | static const struct snd_kcontrol_new cxt5047_test_mixer[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1371 | |
| 1372 | /* Output only controls */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1373 | HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), |
| 1374 | HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), |
| 1375 | HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), |
| 1376 | HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1377 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), |
| 1378 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 1379 | HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
| 1380 | HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1381 | HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), |
| 1382 | HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
| 1383 | HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), |
| 1384 | HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1385 | |
| 1386 | /* Modes for retasking pin widgets */ |
| 1387 | CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), |
| 1388 | CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), |
| 1389 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1390 | /* EAPD Switch Control */ |
| 1391 | CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), |
| 1392 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1393 | /* Loopback mixer controls */ |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1394 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), |
| 1395 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), |
| 1396 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), |
| 1397 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), |
| 1398 | HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), |
| 1399 | HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), |
| 1400 | HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), |
| 1401 | HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1402 | |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1403 | HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), |
| 1404 | HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), |
| 1405 | HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), |
| 1406 | HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), |
| 1407 | HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), |
| 1408 | HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), |
| 1409 | HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), |
| 1410 | HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1411 | { |
| 1412 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1413 | .name = "Input Source", |
| 1414 | .info = conexant_mux_enum_info, |
| 1415 | .get = conexant_mux_enum_get, |
| 1416 | .put = conexant_mux_enum_put, |
| 1417 | }, |
Takashi Iwai | 854206b | 2009-11-30 18:22:04 +0100 | [diff] [blame] | 1418 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), |
Marc Boucher | 9f113e0 | 2008-01-22 15:18:08 +0100 | [diff] [blame] | 1419 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1420 | { } /* end */ |
| 1421 | }; |
| 1422 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1423 | static const struct hda_verb cxt5047_test_init_verbs[] = { |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1424 | /* Enable retasking pins as output, initially without power amp */ |
| 1425 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1426 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1427 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1428 | |
| 1429 | /* Disable digital (SPDIF) pins initially, but users can enable |
| 1430 | * them via a mixer switch. In the case of SPDIF-out, this initverb |
| 1431 | * payload also sets the generation to 0, output to be in "consumer" |
| 1432 | * PCM format, copyright asserted, no pre-emphasis and no validity |
| 1433 | * control. |
| 1434 | */ |
| 1435 | {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
| 1436 | |
| 1437 | /* Ensure mic1, mic2, line1 pin widgets take input from the |
| 1438 | * OUT1 sum bus when acting as an output. |
| 1439 | */ |
| 1440 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, |
| 1441 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 1442 | |
| 1443 | /* Start with output sum widgets muted and their output gains at min */ |
| 1444 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1445 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 1446 | |
| 1447 | /* Unmute retasking pin widget output buffers since the default |
| 1448 | * state appears to be output. As the pin mode is changed by the |
| 1449 | * user the pin mode control will take care of enabling the pin's |
| 1450 | * input/output buffers as needed. |
| 1451 | */ |
| 1452 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1453 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1454 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 1455 | |
| 1456 | /* Mute capture amp left and right */ |
| 1457 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 1458 | |
| 1459 | /* Set ADC connection select to match default mixer setting (mic1 |
| 1460 | * pin) |
| 1461 | */ |
| 1462 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1463 | |
| 1464 | /* Mute all inputs to mixer widget (even unconnected ones) */ |
| 1465 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ |
| 1466 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ |
| 1467 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ |
| 1468 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ |
| 1469 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ |
| 1470 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ |
| 1471 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ |
| 1472 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ |
| 1473 | |
| 1474 | { } |
| 1475 | }; |
| 1476 | #endif |
| 1477 | |
| 1478 | |
| 1479 | /* initialize jack-sensing, too */ |
| 1480 | static int cxt5047_hp_init(struct hda_codec *codec) |
| 1481 | { |
| 1482 | conexant_init(codec); |
| 1483 | cxt5047_hp_automute(codec); |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1484 | return 0; |
| 1485 | } |
| 1486 | |
| 1487 | |
| 1488 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1489 | CXT5047_LAPTOP, /* Laptops w/o EAPD support */ |
| 1490 | CXT5047_LAPTOP_HP, /* Some HP laptops */ |
| 1491 | CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1492 | #ifdef CONFIG_SND_DEBUG |
| 1493 | CXT5047_TEST, |
| 1494 | #endif |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1495 | CXT5047_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1496 | CXT5047_MODELS |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1497 | }; |
| 1498 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1499 | static const char * const cxt5047_models[CXT5047_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1500 | [CXT5047_LAPTOP] = "laptop", |
| 1501 | [CXT5047_LAPTOP_HP] = "laptop-hp", |
| 1502 | [CXT5047_LAPTOP_EAPD] = "laptop-eapd", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1503 | #ifdef CONFIG_SND_DEBUG |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1504 | [CXT5047_TEST] = "test", |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1505 | #endif |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1506 | [CXT5047_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1507 | }; |
| 1508 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1509 | static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { |
Takashi Iwai | ac3e374 | 2007-12-17 17:14:18 +0100 | [diff] [blame] | 1510 | SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1511 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", |
| 1512 | CXT5047_LAPTOP), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1513 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1514 | {} |
| 1515 | }; |
| 1516 | |
| 1517 | static int patch_cxt5047(struct hda_codec *codec) |
| 1518 | { |
| 1519 | struct conexant_spec *spec; |
| 1520 | int board_config; |
| 1521 | |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1522 | board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, |
| 1523 | cxt5047_models, |
| 1524 | cxt5047_cfg_tbl); |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1525 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1526 | board_config = CXT5047_AUTO; /* model=auto as default */ |
Takashi Iwai | fa5dadc | 2011-05-13 19:33:18 +0200 | [diff] [blame] | 1527 | if (board_config == CXT5047_AUTO) |
| 1528 | return patch_conexant_auto(codec); |
| 1529 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1530 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1531 | if (!spec) |
| 1532 | return -ENOMEM; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1533 | codec->spec = spec; |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 1534 | codec->pin_amp_workaround = 1; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1535 | |
| 1536 | spec->multiout.max_channels = 2; |
| 1537 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); |
| 1538 | spec->multiout.dac_nids = cxt5047_dac_nids; |
| 1539 | spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; |
| 1540 | spec->num_adc_nids = 1; |
| 1541 | spec->adc_nids = cxt5047_adc_nids; |
| 1542 | spec->capsrc_nids = cxt5047_capsrc_nids; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1543 | spec->num_mixers = 1; |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1544 | spec->mixers[0] = cxt5047_base_mixers; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1545 | spec->num_init_verbs = 1; |
| 1546 | spec->init_verbs[0] = cxt5047_init_verbs; |
| 1547 | spec->spdif_route = 0; |
Tobin Davis | 5cd5752 | 2006-11-20 17:42:09 +0100 | [diff] [blame] | 1548 | spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), |
| 1549 | spec->channel_mode = cxt5047_modes, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1550 | |
| 1551 | codec->patch_ops = conexant_patch_ops; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1552 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1553 | switch (board_config) { |
| 1554 | case CXT5047_LAPTOP: |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1555 | spec->num_mixers = 2; |
| 1556 | spec->mixers[1] = cxt5047_hp_spk_mixers; |
| 1557 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1558 | break; |
| 1559 | case CXT5047_LAPTOP_HP: |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1560 | spec->num_mixers = 2; |
| 1561 | spec->mixers[1] = cxt5047_hp_only_mixers; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1562 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1563 | codec->patch_ops.init = cxt5047_hp_init; |
| 1564 | break; |
| 1565 | case CXT5047_LAPTOP_EAPD: |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 1566 | spec->input_mux = &cxt5047_toshiba_capture_source; |
Takashi Iwai | df481e4 | 2009-03-10 15:35:35 +0100 | [diff] [blame] | 1567 | spec->num_mixers = 2; |
| 1568 | spec->mixers[1] = cxt5047_hp_spk_mixers; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1569 | spec->num_init_verbs = 2; |
| 1570 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1571 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1572 | break; |
| 1573 | #ifdef CONFIG_SND_DEBUG |
| 1574 | case CXT5047_TEST: |
| 1575 | spec->input_mux = &cxt5047_test_capture_source; |
| 1576 | spec->mixers[0] = cxt5047_test_mixer; |
| 1577 | spec->init_verbs[0] = cxt5047_test_init_verbs; |
Tobin Davis | fb3409e | 2007-05-17 09:40:47 +0200 | [diff] [blame] | 1578 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1579 | #endif |
| 1580 | } |
Takashi Iwai | dd5746a | 2009-03-10 14:30:40 +0100 | [diff] [blame] | 1581 | spec->vmaster_nid = 0x13; |
Daniel T Chen | 025f206 | 2010-03-21 18:34:43 -0400 | [diff] [blame] | 1582 | |
| 1583 | switch (codec->subsystem_id >> 16) { |
| 1584 | case 0x103c: |
| 1585 | /* HP laptops have really bad sound over 0 dB on NID 0x10. |
| 1586 | * Fix max PCM level to 0 dB (originally it has 0x1e steps |
| 1587 | * with 0 dB offset 0x17) |
| 1588 | */ |
| 1589 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, |
| 1590 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 1591 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 1592 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 1593 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 1594 | break; |
| 1595 | } |
| 1596 | |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 1597 | return 0; |
| 1598 | } |
| 1599 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1600 | /* Conexant 5051 specific */ |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1601 | static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; |
| 1602 | static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1603 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1604 | static const struct hda_channel_mode cxt5051_modes[1] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1605 | { 2, NULL }, |
| 1606 | }; |
| 1607 | |
| 1608 | static void cxt5051_update_speaker(struct hda_codec *codec) |
| 1609 | { |
| 1610 | struct conexant_spec *spec = codec->spec; |
| 1611 | unsigned int pinctl; |
Takashi Iwai | 23d2df5 | 2010-01-24 11:19:27 +0100 | [diff] [blame] | 1612 | /* headphone pin */ |
| 1613 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1614 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
Takashi Iwai | 23d2df5 | 2010-01-24 11:19:27 +0100 | [diff] [blame] | 1615 | /* speaker pin */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1616 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1617 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
Justin P. Mattock | a80581d | 2012-02-11 05:55:58 -0800 | [diff] [blame] | 1618 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1619 | if (spec->ideapad) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1620 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1624 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1625 | struct snd_ctl_elem_value *ucontrol) |
| 1626 | { |
| 1627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1628 | |
| 1629 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 1630 | return 0; |
| 1631 | cxt5051_update_speaker(codec); |
| 1632 | return 1; |
| 1633 | } |
| 1634 | |
| 1635 | /* toggle input of built-in and mic jack appropriately */ |
| 1636 | static void cxt5051_portb_automic(struct hda_codec *codec) |
| 1637 | { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1638 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1639 | unsigned int present; |
| 1640 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1641 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1642 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1643 | present = snd_hda_jack_detect(codec, 0x17); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1644 | snd_hda_codec_write(codec, 0x14, 0, |
| 1645 | AC_VERB_SET_CONNECT_SEL, |
| 1646 | present ? 0x01 : 0x00); |
| 1647 | } |
| 1648 | |
| 1649 | /* switch the current ADC according to the jack state */ |
| 1650 | static void cxt5051_portc_automic(struct hda_codec *codec) |
| 1651 | { |
| 1652 | struct conexant_spec *spec = codec->spec; |
| 1653 | unsigned int present; |
| 1654 | hda_nid_t new_adc; |
| 1655 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1656 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1657 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1658 | present = snd_hda_jack_detect(codec, 0x18); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1659 | if (present) |
| 1660 | spec->cur_adc_idx = 1; |
| 1661 | else |
| 1662 | spec->cur_adc_idx = 0; |
| 1663 | new_adc = spec->adc_nids[spec->cur_adc_idx]; |
| 1664 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 1665 | /* stream is running, let's swap the current ADC */ |
Takashi Iwai | f0cea79 | 2010-08-13 11:56:53 +0200 | [diff] [blame] | 1666 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1667 | spec->cur_adc = new_adc; |
| 1668 | snd_hda_codec_setup_stream(codec, new_adc, |
| 1669 | spec->cur_adc_stream_tag, 0, |
| 1670 | spec->cur_adc_format); |
| 1671 | } |
| 1672 | } |
| 1673 | |
| 1674 | /* mute internal speaker if HP is plugged */ |
| 1675 | static void cxt5051_hp_automute(struct hda_codec *codec) |
| 1676 | { |
| 1677 | struct conexant_spec *spec = codec->spec; |
| 1678 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1679 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1680 | cxt5051_update_speaker(codec); |
| 1681 | } |
| 1682 | |
| 1683 | /* unsolicited event for HP jack sensing */ |
| 1684 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, |
| 1685 | unsigned int res) |
| 1686 | { |
| 1687 | switch (res >> 26) { |
| 1688 | case CONEXANT_HP_EVENT: |
| 1689 | cxt5051_hp_automute(codec); |
| 1690 | break; |
| 1691 | case CXT5051_PORTB_EVENT: |
| 1692 | cxt5051_portb_automic(codec); |
| 1693 | break; |
| 1694 | case CXT5051_PORTC_EVENT: |
| 1695 | cxt5051_portc_automic(codec); |
| 1696 | break; |
| 1697 | } |
| 1698 | } |
| 1699 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1700 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1701 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 1702 | { |
| 1703 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1704 | .name = "Master Playback Switch", |
| 1705 | .info = cxt_eapd_info, |
| 1706 | .get = cxt_eapd_get, |
| 1707 | .put = cxt5051_hp_master_sw_put, |
| 1708 | .private_value = 0x1a, |
| 1709 | }, |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1710 | {} |
| 1711 | }; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1712 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1713 | static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1714 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1715 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1716 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1717 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
David Henningsson | c40bd91 | 2012-09-19 12:19:47 +0200 | [diff] [blame] | 1718 | HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1719 | HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1720 | {} |
| 1721 | }; |
| 1722 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1723 | static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1724 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1725 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1726 | HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1727 | HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1728 | {} |
| 1729 | }; |
| 1730 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1731 | static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
Takashi Iwai | 4e4ac60 | 2010-01-23 22:29:54 +0100 | [diff] [blame] | 1732 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
| 1733 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1734 | {} |
| 1735 | }; |
| 1736 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1737 | static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1738 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
| 1739 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1740 | {} |
| 1741 | }; |
| 1742 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1743 | static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1744 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1745 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1746 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1747 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1748 | {} |
| 1749 | }; |
| 1750 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1751 | static const struct hda_verb cxt5051_init_verbs[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1752 | /* Line in, Mic */ |
| 1753 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1754 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1755 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1756 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1757 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1758 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1759 | /* SPK */ |
| 1760 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1761 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1762 | /* HP, Amp */ |
| 1763 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1764 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1765 | /* DAC1 */ |
| 1766 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1767 | /* Record selector: Internal mic */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1768 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1769 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1770 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1771 | /* SPDIF route: PCM */ |
Pierre-Louis Bossart | 1965c44 | 2010-05-06 16:37:03 -0500 | [diff] [blame] | 1772 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1773 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1774 | /* EAPD */ |
| 1775 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1776 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1777 | { } /* end */ |
| 1778 | }; |
| 1779 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1780 | static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1781 | /* Line in, Mic */ |
| 1782 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1783 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1784 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1785 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1786 | /* SPK */ |
| 1787 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1788 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1789 | /* HP, Amp */ |
| 1790 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1791 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1792 | /* DAC1 */ |
| 1793 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1794 | /* Record selector: Internal mic */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1795 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1796 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1797 | /* SPDIF route: PCM */ |
| 1798 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1799 | /* EAPD */ |
| 1800 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1801 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1802 | { } /* end */ |
| 1803 | }; |
| 1804 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1805 | static const struct hda_verb cxt5051_f700_init_verbs[] = { |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1806 | /* Line in, Mic */ |
Takashi Iwai | 30ed7ed | 2010-01-28 17:11:45 +0100 | [diff] [blame] | 1807 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1808 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1809 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1810 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1811 | /* SPK */ |
| 1812 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1813 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1814 | /* HP, Amp */ |
| 1815 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1816 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1817 | /* DAC1 */ |
| 1818 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1819 | /* Record selector: Internal mic */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1820 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1821 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1822 | /* SPDIF route: PCM */ |
| 1823 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1824 | /* EAPD */ |
| 1825 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1826 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1827 | { } /* end */ |
| 1828 | }; |
| 1829 | |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1830 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
| 1831 | unsigned int event) |
| 1832 | { |
| 1833 | snd_hda_codec_write(codec, nid, 0, |
| 1834 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1835 | AC_USRSP_EN | event); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1836 | } |
| 1837 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1838 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1839 | /* Subwoofer */ |
| 1840 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1841 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1842 | { } /* end */ |
| 1843 | }; |
| 1844 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1845 | /* initialize jack-sensing, too */ |
| 1846 | static int cxt5051_init(struct hda_codec *codec) |
| 1847 | { |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1848 | struct conexant_spec *spec = codec->spec; |
| 1849 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1850 | conexant_init(codec); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1851 | |
| 1852 | if (spec->auto_mic & AUTO_MIC_PORTB) |
| 1853 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); |
| 1854 | if (spec->auto_mic & AUTO_MIC_PORTC) |
| 1855 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); |
| 1856 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1857 | if (codec->patch_ops.unsol_event) { |
| 1858 | cxt5051_hp_automute(codec); |
| 1859 | cxt5051_portb_automic(codec); |
| 1860 | cxt5051_portc_automic(codec); |
| 1861 | } |
| 1862 | return 0; |
| 1863 | } |
| 1864 | |
| 1865 | |
| 1866 | enum { |
| 1867 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ |
| 1868 | CXT5051_HP, /* no docking */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1869 | CXT5051_HP_DV6736, /* HP without mic switch */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1870 | CXT5051_F700, /* HP Compaq Presario F700 */ |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1871 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1872 | CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1873 | CXT5051_AUTO, /* auto-parser */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1874 | CXT5051_MODELS |
| 1875 | }; |
| 1876 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1877 | static const char *const cxt5051_models[CXT5051_MODELS] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1878 | [CXT5051_LAPTOP] = "laptop", |
| 1879 | [CXT5051_HP] = "hp", |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1880 | [CXT5051_HP_DV6736] = "hp-dv6736", |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1881 | [CXT5051_F700] = "hp-700", |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1882 | [CXT5051_TOSHIBA] = "toshiba", |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1883 | [CXT5051_IDEAPAD] = "ideapad", |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1884 | [CXT5051_AUTO] = "auto", |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1885 | }; |
| 1886 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1887 | static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1888 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
Tony Vroon | 1812e67 | 2009-05-27 21:00:41 +0100 | [diff] [blame] | 1889 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1890 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1891 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1892 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 1893 | CXT5051_LAPTOP), |
| 1894 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1895 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1896 | {} |
| 1897 | }; |
| 1898 | |
| 1899 | static int patch_cxt5051(struct hda_codec *codec) |
| 1900 | { |
| 1901 | struct conexant_spec *spec; |
| 1902 | int board_config; |
| 1903 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1904 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
| 1905 | cxt5051_models, |
| 1906 | cxt5051_cfg_tbl); |
| 1907 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1908 | board_config = CXT5051_AUTO; /* model=auto as default */ |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1909 | if (board_config == CXT5051_AUTO) |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1910 | return patch_conexant_auto(codec); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1911 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1912 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1913 | if (!spec) |
| 1914 | return -ENOMEM; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1915 | codec->spec = spec; |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 1916 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1917 | |
| 1918 | codec->patch_ops = conexant_patch_ops; |
| 1919 | codec->patch_ops.init = cxt5051_init; |
| 1920 | |
| 1921 | spec->multiout.max_channels = 2; |
| 1922 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); |
| 1923 | spec->multiout.dac_nids = cxt5051_dac_nids; |
| 1924 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; |
| 1925 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ |
| 1926 | spec->adc_nids = cxt5051_adc_nids; |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1927 | spec->num_mixers = 2; |
| 1928 | spec->mixers[0] = cxt5051_capture_mixers; |
| 1929 | spec->mixers[1] = cxt5051_playback_mixers; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1930 | spec->num_init_verbs = 1; |
| 1931 | spec->init_verbs[0] = cxt5051_init_verbs; |
| 1932 | spec->spdif_route = 0; |
| 1933 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); |
| 1934 | spec->channel_mode = cxt5051_modes; |
| 1935 | spec->cur_adc = 0; |
| 1936 | spec->cur_adc_idx = 0; |
| 1937 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1938 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 1939 | |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1940 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
| 1941 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1942 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1943 | switch (board_config) { |
| 1944 | case CXT5051_HP: |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1945 | spec->mixers[0] = cxt5051_hp_mixers; |
| 1946 | break; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1947 | case CXT5051_HP_DV6736: |
| 1948 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; |
| 1949 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1950 | spec->auto_mic = 0; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1951 | break; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1952 | case CXT5051_F700: |
| 1953 | spec->init_verbs[0] = cxt5051_f700_init_verbs; |
| 1954 | spec->mixers[0] = cxt5051_f700_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1955 | spec->auto_mic = 0; |
| 1956 | break; |
| 1957 | case CXT5051_TOSHIBA: |
| 1958 | spec->mixers[0] = cxt5051_toshiba_mixers; |
| 1959 | spec->auto_mic = AUTO_MIC_PORTB; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1960 | break; |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1961 | case CXT5051_IDEAPAD: |
| 1962 | spec->init_verbs[spec->num_init_verbs++] = |
| 1963 | cxt5051_ideapad_init_verbs; |
| 1964 | spec->ideapad = 1; |
| 1965 | break; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1966 | } |
| 1967 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1968 | if (spec->beep_amp) |
| 1969 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
| 1970 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1971 | return 0; |
| 1972 | } |
| 1973 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1974 | /* Conexant 5066 specific */ |
| 1975 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1976 | static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; |
| 1977 | static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; |
| 1978 | static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; |
| 1979 | static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1980 | |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 1981 | /* OLPC's microphone port is DC coupled for use with external sensors, |
| 1982 | * therefore we use a 50% mic bias in order to center the input signal with |
| 1983 | * the DC input range of the codec. */ |
| 1984 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 |
| 1985 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1986 | static const struct hda_channel_mode cxt5066_modes[1] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1987 | { 2, NULL }, |
| 1988 | }; |
| 1989 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1990 | #define HP_PRESENT_PORT_A (1 << 0) |
| 1991 | #define HP_PRESENT_PORT_D (1 << 1) |
| 1992 | #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) |
| 1993 | #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) |
| 1994 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1995 | static void cxt5066_update_speaker(struct hda_codec *codec) |
| 1996 | { |
| 1997 | struct conexant_spec *spec = codec->spec; |
| 1998 | unsigned int pinctl; |
| 1999 | |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 2000 | snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", |
| 2001 | spec->hp_present, spec->cur_eapd); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2002 | |
| 2003 | /* Port A (HP) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2004 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2005 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2006 | |
| 2007 | /* Port D (HP/LO) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2008 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
| 2009 | if (spec->dell_automute || spec->thinkpad) { |
| 2010 | /* Mute if Port A is connected */ |
| 2011 | if (hp_port_a_present(spec)) |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 2012 | pinctl = 0; |
| 2013 | } else { |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2014 | /* Thinkpad/Dell doesn't give pin-D status */ |
| 2015 | if (!hp_port_d_present(spec)) |
| 2016 | pinctl = 0; |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 2017 | } |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2018 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2019 | |
| 2020 | /* CLASS_D AMP */ |
| 2021 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2022 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2023 | } |
| 2024 | |
| 2025 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 2026 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 2027 | struct snd_ctl_elem_value *ucontrol) |
| 2028 | { |
| 2029 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2030 | |
| 2031 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 2032 | return 0; |
| 2033 | |
| 2034 | cxt5066_update_speaker(codec); |
| 2035 | return 1; |
| 2036 | } |
| 2037 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2038 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { |
| 2039 | .num_items = 3, |
| 2040 | .items = { |
| 2041 | { "Off", PIN_IN }, |
| 2042 | { "50%", PIN_VREF50 }, |
| 2043 | { "80%", PIN_VREF80 }, |
| 2044 | }, |
| 2045 | }; |
| 2046 | |
| 2047 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) |
| 2048 | { |
| 2049 | struct conexant_spec *spec = codec->spec; |
| 2050 | /* Even though port F is the DC input, the bias is controlled on port B. |
| 2051 | * we also leave that port as an active input (but unselected) in DC mode |
| 2052 | * just in case that is necessary to make the bias setting take effect. */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2053 | return snd_hda_set_pin_ctl_cache(codec, 0x1a, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2054 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); |
| 2055 | } |
| 2056 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2057 | /* OLPC defers mic widget control until when capture is started because the |
| 2058 | * microphone LED comes on as soon as these settings are put in place. if we |
| 2059 | * did this before recording, it would give the false indication that recording |
| 2060 | * is happening when it is not. */ |
| 2061 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2062 | { |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 2063 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2064 | if (!spec->recording) |
| 2065 | return; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2066 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2067 | if (spec->dc_enable) { |
| 2068 | /* in DC mode we ignore presence detection and just use the jack |
| 2069 | * through our special DC port */ |
| 2070 | const struct hda_verb enable_dc_mode[] = { |
| 2071 | /* disble internal mic, port C */ |
| 2072 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2073 | |
| 2074 | /* enable DC capture, port F */ |
| 2075 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2076 | {}, |
| 2077 | }; |
| 2078 | |
| 2079 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2080 | /* port B input disabled (and bias set) through the following call */ |
| 2081 | cxt5066_set_olpc_dc_bias(codec); |
| 2082 | return; |
| 2083 | } |
| 2084 | |
| 2085 | /* disable DC (port F) */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2086 | snd_hda_set_pin_ctl(codec, 0x1e, 0); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2087 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2088 | /* external mic, port B */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2089 | snd_hda_set_pin_ctl(codec, 0x1a, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2090 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2091 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2092 | /* internal mic, port C */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2093 | snd_hda_set_pin_ctl(codec, 0x1b, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2094 | spec->ext_mic_present ? 0 : PIN_VREF80); |
| 2095 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2096 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2097 | /* toggle input of built-in and mic jack appropriately */ |
| 2098 | static void cxt5066_olpc_automic(struct hda_codec *codec) |
| 2099 | { |
| 2100 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2101 | unsigned int present; |
| 2102 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2103 | if (spec->dc_enable) /* don't do presence detection in DC mode */ |
| 2104 | return; |
| 2105 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2106 | present = snd_hda_codec_read(codec, 0x1a, 0, |
| 2107 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 2108 | if (present) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2109 | snd_printdd("CXT5066: external microphone detected\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2110 | else |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2111 | snd_printdd("CXT5066: external microphone absent\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2112 | |
| 2113 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2114 | present ? 0 : 1); |
| 2115 | spec->ext_mic_present = !!present; |
| 2116 | |
| 2117 | cxt5066_olpc_select_mic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2118 | } |
| 2119 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2120 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2121 | static void cxt5066_vostro_automic(struct hda_codec *codec) |
| 2122 | { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2123 | unsigned int present; |
| 2124 | |
| 2125 | struct hda_verb ext_mic_present[] = { |
| 2126 | /* enable external mic, port B */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2127 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2128 | |
| 2129 | /* switch to external mic input */ |
| 2130 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2131 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2132 | |
| 2133 | /* disable internal digital mic */ |
| 2134 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2135 | {} |
| 2136 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2137 | static const struct hda_verb ext_mic_absent[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2138 | /* enable internal mic, port C */ |
| 2139 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2140 | |
| 2141 | /* switch to internal mic input */ |
| 2142 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2143 | |
| 2144 | /* disable external mic, port B */ |
| 2145 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2146 | {} |
| 2147 | }; |
| 2148 | |
| 2149 | present = snd_hda_jack_detect(codec, 0x1a); |
| 2150 | if (present) { |
| 2151 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2152 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2153 | } else { |
| 2154 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2155 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2156 | } |
| 2157 | } |
| 2158 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2159 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2160 | static void cxt5066_ideapad_automic(struct hda_codec *codec) |
| 2161 | { |
| 2162 | unsigned int present; |
| 2163 | |
| 2164 | struct hda_verb ext_mic_present[] = { |
| 2165 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2166 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2167 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2168 | {} |
| 2169 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2170 | static const struct hda_verb ext_mic_absent[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2171 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2172 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2173 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2174 | {} |
| 2175 | }; |
| 2176 | |
| 2177 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2178 | if (present) { |
| 2179 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2180 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2181 | } else { |
| 2182 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2183 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2184 | } |
| 2185 | } |
| 2186 | |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2187 | |
| 2188 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2189 | static void cxt5066_asus_automic(struct hda_codec *codec) |
| 2190 | { |
| 2191 | unsigned int present; |
| 2192 | |
| 2193 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2194 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2195 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2196 | present ? 1 : 0); |
| 2197 | } |
| 2198 | |
| 2199 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2200 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2201 | static void cxt5066_hp_laptop_automic(struct hda_codec *codec) |
| 2202 | { |
| 2203 | unsigned int present; |
| 2204 | |
| 2205 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2206 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2207 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2208 | present ? 1 : 3); |
| 2209 | } |
| 2210 | |
| 2211 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2212 | /* toggle input of built-in digital mic and mic jack appropriately |
| 2213 | order is: external mic -> dock mic -> interal mic */ |
| 2214 | static void cxt5066_thinkpad_automic(struct hda_codec *codec) |
| 2215 | { |
| 2216 | unsigned int ext_present, dock_present; |
| 2217 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2218 | static const struct hda_verb ext_mic_present[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2219 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2220 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, |
| 2221 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2222 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2223 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2224 | {} |
| 2225 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2226 | static const struct hda_verb dock_mic_present[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2227 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2228 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2229 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2230 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2231 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2232 | {} |
| 2233 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2234 | static const struct hda_verb ext_mic_absent[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2235 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2236 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2237 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2238 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2239 | {} |
| 2240 | }; |
| 2241 | |
| 2242 | ext_present = snd_hda_jack_detect(codec, 0x1b); |
| 2243 | dock_present = snd_hda_jack_detect(codec, 0x1a); |
| 2244 | if (ext_present) { |
| 2245 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2246 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2247 | } else if (dock_present) { |
| 2248 | snd_printdd("CXT5066: dock microphone detected\n"); |
| 2249 | snd_hda_sequence_write(codec, dock_mic_present); |
| 2250 | } else { |
| 2251 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2252 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2253 | } |
| 2254 | } |
| 2255 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2256 | /* mute internal speaker if HP is plugged */ |
| 2257 | static void cxt5066_hp_automute(struct hda_codec *codec) |
| 2258 | { |
| 2259 | struct conexant_spec *spec = codec->spec; |
| 2260 | unsigned int portA, portD; |
| 2261 | |
| 2262 | /* Port A */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2263 | portA = snd_hda_jack_detect(codec, 0x19); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2264 | |
| 2265 | /* Port D */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2266 | portD = snd_hda_jack_detect(codec, 0x1c); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2267 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2268 | spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; |
| 2269 | spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2270 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
| 2271 | portA, portD, spec->hp_present); |
| 2272 | cxt5066_update_speaker(codec); |
| 2273 | } |
| 2274 | |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2275 | /* Dispatch the right mic autoswitch function */ |
| 2276 | static void cxt5066_automic(struct hda_codec *codec) |
| 2277 | { |
| 2278 | struct conexant_spec *spec = codec->spec; |
| 2279 | |
| 2280 | if (spec->dell_vostro) |
| 2281 | cxt5066_vostro_automic(codec); |
| 2282 | else if (spec->ideapad) |
| 2283 | cxt5066_ideapad_automic(codec); |
| 2284 | else if (spec->thinkpad) |
| 2285 | cxt5066_thinkpad_automic(codec); |
| 2286 | else if (spec->hp_laptop) |
| 2287 | cxt5066_hp_laptop_automic(codec); |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2288 | else if (spec->asus) |
| 2289 | cxt5066_asus_automic(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2290 | } |
| 2291 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2292 | /* unsolicited event for jack sensing */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2293 | static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2294 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2295 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2296 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
| 2297 | switch (res >> 26) { |
| 2298 | case CONEXANT_HP_EVENT: |
| 2299 | cxt5066_hp_automute(codec); |
| 2300 | break; |
| 2301 | case CONEXANT_MIC_EVENT: |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2302 | /* ignore mic events in DC mode; we're always using the jack */ |
| 2303 | if (!spec->dc_enable) |
| 2304 | cxt5066_olpc_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2305 | break; |
| 2306 | } |
| 2307 | } |
| 2308 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2309 | /* unsolicited event for jack sensing */ |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2310 | 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] | 2311 | { |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2312 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2313 | switch (res >> 26) { |
| 2314 | case CONEXANT_HP_EVENT: |
| 2315 | cxt5066_hp_automute(codec); |
| 2316 | break; |
| 2317 | case CONEXANT_MIC_EVENT: |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2318 | cxt5066_automic(codec); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2319 | break; |
| 2320 | } |
| 2321 | } |
| 2322 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2323 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2324 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
| 2325 | .num_items = 5, |
| 2326 | .items = { |
| 2327 | { "0dB", 0 }, |
| 2328 | { "10dB", 1 }, |
| 2329 | { "20dB", 2 }, |
| 2330 | { "30dB", 3 }, |
| 2331 | { "40dB", 4 }, |
| 2332 | }, |
| 2333 | }; |
| 2334 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2335 | static void cxt5066_set_mic_boost(struct hda_codec *codec) |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2336 | { |
| 2337 | struct conexant_spec *spec = codec->spec; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2338 | snd_hda_codec_write_cache(codec, 0x17, 0, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2339 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2340 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | |
| 2341 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2342 | if (spec->ideapad || spec->thinkpad) { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2343 | /* adjust the internal mic as well...it is not through 0x17 */ |
| 2344 | snd_hda_codec_write_cache(codec, 0x23, 0, |
| 2345 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2346 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | |
| 2347 | cxt5066_analog_mic_boost. |
| 2348 | items[spec->mic_boost].index); |
| 2349 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2350 | } |
| 2351 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2352 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 2353 | struct snd_ctl_elem_info *uinfo) |
| 2354 | { |
| 2355 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); |
| 2356 | } |
| 2357 | |
| 2358 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 2359 | struct snd_ctl_elem_value *ucontrol) |
| 2360 | { |
| 2361 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2362 | struct conexant_spec *spec = codec->spec; |
| 2363 | ucontrol->value.enumerated.item[0] = spec->mic_boost; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2364 | return 0; |
| 2365 | } |
| 2366 | |
| 2367 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 2368 | struct snd_ctl_elem_value *ucontrol) |
| 2369 | { |
| 2370 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2371 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2372 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2373 | unsigned int idx; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2374 | idx = ucontrol->value.enumerated.item[0]; |
| 2375 | if (idx >= imux->num_items) |
| 2376 | idx = imux->num_items - 1; |
| 2377 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2378 | spec->mic_boost = idx; |
| 2379 | if (!spec->dc_enable) |
| 2380 | cxt5066_set_mic_boost(codec); |
| 2381 | return 1; |
| 2382 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2383 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2384 | static void cxt5066_enable_dc(struct hda_codec *codec) |
| 2385 | { |
| 2386 | const struct hda_verb enable_dc_mode[] = { |
| 2387 | /* disable gain */ |
| 2388 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2389 | |
| 2390 | /* switch to DC input */ |
| 2391 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, |
| 2392 | {} |
| 2393 | }; |
| 2394 | |
| 2395 | /* configure as input source */ |
| 2396 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2397 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ |
| 2398 | } |
| 2399 | |
| 2400 | static void cxt5066_disable_dc(struct hda_codec *codec) |
| 2401 | { |
| 2402 | /* reconfigure input source */ |
| 2403 | cxt5066_set_mic_boost(codec); |
| 2404 | /* automic also selects the right mic if we're recording */ |
| 2405 | cxt5066_olpc_automic(codec); |
| 2406 | } |
| 2407 | |
| 2408 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, |
| 2409 | struct snd_ctl_elem_value *ucontrol) |
| 2410 | { |
| 2411 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2412 | struct conexant_spec *spec = codec->spec; |
| 2413 | ucontrol->value.integer.value[0] = spec->dc_enable; |
| 2414 | return 0; |
| 2415 | } |
| 2416 | |
| 2417 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
| 2418 | struct snd_ctl_elem_value *ucontrol) |
| 2419 | { |
| 2420 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2421 | struct conexant_spec *spec = codec->spec; |
| 2422 | int dc_enable = !!ucontrol->value.integer.value[0]; |
| 2423 | |
| 2424 | if (dc_enable == spec->dc_enable) |
| 2425 | return 0; |
| 2426 | |
| 2427 | spec->dc_enable = dc_enable; |
| 2428 | if (dc_enable) |
| 2429 | cxt5066_enable_dc(codec); |
| 2430 | else |
| 2431 | cxt5066_disable_dc(codec); |
| 2432 | |
| 2433 | return 1; |
| 2434 | } |
| 2435 | |
| 2436 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, |
| 2437 | struct snd_ctl_elem_info *uinfo) |
| 2438 | { |
| 2439 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); |
| 2440 | } |
| 2441 | |
| 2442 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, |
| 2443 | struct snd_ctl_elem_value *ucontrol) |
| 2444 | { |
| 2445 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2446 | struct conexant_spec *spec = codec->spec; |
| 2447 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; |
| 2448 | return 0; |
| 2449 | } |
| 2450 | |
| 2451 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, |
| 2452 | struct snd_ctl_elem_value *ucontrol) |
| 2453 | { |
| 2454 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2455 | struct conexant_spec *spec = codec->spec; |
| 2456 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2457 | unsigned int idx; |
| 2458 | |
| 2459 | idx = ucontrol->value.enumerated.item[0]; |
| 2460 | if (idx >= imux->num_items) |
| 2461 | idx = imux->num_items - 1; |
| 2462 | |
| 2463 | spec->dc_input_bias = idx; |
| 2464 | if (spec->dc_enable) |
| 2465 | cxt5066_set_olpc_dc_bias(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2466 | return 1; |
| 2467 | } |
| 2468 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2469 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) |
| 2470 | { |
| 2471 | struct conexant_spec *spec = codec->spec; |
| 2472 | /* mark as recording and configure the microphone widget so that the |
| 2473 | * recording LED comes on. */ |
| 2474 | spec->recording = 1; |
| 2475 | cxt5066_olpc_select_mic(codec); |
| 2476 | } |
| 2477 | |
| 2478 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) |
| 2479 | { |
| 2480 | struct conexant_spec *spec = codec->spec; |
| 2481 | const struct hda_verb disable_mics[] = { |
| 2482 | /* disable external mic, port B */ |
| 2483 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2484 | |
| 2485 | /* disble internal mic, port C */ |
| 2486 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2487 | |
| 2488 | /* disable DC capture, port F */ |
| 2489 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2490 | {}, |
| 2491 | }; |
| 2492 | |
| 2493 | snd_hda_sequence_write(codec, disable_mics); |
| 2494 | spec->recording = 0; |
| 2495 | } |
| 2496 | |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2497 | static void conexant_check_dig_outs(struct hda_codec *codec, |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2498 | const hda_nid_t *dig_pins, |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2499 | int num_pins) |
| 2500 | { |
| 2501 | struct conexant_spec *spec = codec->spec; |
| 2502 | hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; |
| 2503 | int i; |
| 2504 | |
| 2505 | for (i = 0; i < num_pins; i++, dig_pins++) { |
| 2506 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); |
| 2507 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) |
| 2508 | continue; |
| 2509 | if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) |
| 2510 | continue; |
| 2511 | if (spec->slave_dig_outs[0]) |
| 2512 | nid_loc++; |
| 2513 | else |
| 2514 | nid_loc = spec->slave_dig_outs; |
| 2515 | } |
| 2516 | } |
| 2517 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2518 | static const struct hda_input_mux cxt5066_capture_source = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2519 | .num_items = 4, |
| 2520 | .items = { |
| 2521 | { "Mic B", 0 }, |
| 2522 | { "Mic C", 1 }, |
| 2523 | { "Mic E", 2 }, |
| 2524 | { "Mic F", 3 }, |
| 2525 | }, |
| 2526 | }; |
| 2527 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2528 | static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2529 | .ops = &snd_hda_bind_vol, |
| 2530 | .values = { |
| 2531 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2532 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2533 | 0 |
| 2534 | }, |
| 2535 | }; |
| 2536 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2537 | static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2538 | .ops = &snd_hda_bind_sw, |
| 2539 | .values = { |
| 2540 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2541 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2542 | 0 |
| 2543 | }, |
| 2544 | }; |
| 2545 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2546 | static const struct snd_kcontrol_new cxt5066_mixer_master[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2547 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 2548 | {} |
| 2549 | }; |
| 2550 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2551 | static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2552 | { |
| 2553 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2554 | .name = "Master Playback Volume", |
| 2555 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2556 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2557 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2558 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2559 | .info = snd_hda_mixer_amp_volume_info, |
| 2560 | .get = snd_hda_mixer_amp_volume_get, |
| 2561 | .put = snd_hda_mixer_amp_volume_put, |
| 2562 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
| 2563 | /* offset by 28 volume steps to limit minimum gain to -46dB */ |
| 2564 | .private_value = |
| 2565 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), |
| 2566 | }, |
| 2567 | {} |
| 2568 | }; |
| 2569 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2570 | static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2571 | { |
| 2572 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2573 | .name = "DC Mode Enable Switch", |
| 2574 | .info = snd_ctl_boolean_mono_info, |
| 2575 | .get = cxt5066_olpc_dc_get, |
| 2576 | .put = cxt5066_olpc_dc_put, |
| 2577 | }, |
| 2578 | { |
| 2579 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2580 | .name = "DC Input Bias Enum", |
| 2581 | .info = cxt5066_olpc_dc_bias_enum_info, |
| 2582 | .get = cxt5066_olpc_dc_bias_enum_get, |
| 2583 | .put = cxt5066_olpc_dc_bias_enum_put, |
| 2584 | }, |
| 2585 | {} |
| 2586 | }; |
| 2587 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2588 | static const struct snd_kcontrol_new cxt5066_mixers[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2589 | { |
| 2590 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2591 | .name = "Master Playback Switch", |
| 2592 | .info = cxt_eapd_info, |
| 2593 | .get = cxt_eapd_get, |
| 2594 | .put = cxt5066_hp_master_sw_put, |
| 2595 | .private_value = 0x1d, |
| 2596 | }, |
| 2597 | |
| 2598 | { |
| 2599 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2600 | .name = "Analog Mic Boost Capture Enum", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2601 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2602 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2603 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2604 | }, |
| 2605 | |
| 2606 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
| 2607 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), |
| 2608 | {} |
| 2609 | }; |
| 2610 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2611 | static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2612 | { |
| 2613 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2614 | .name = "Internal Mic Boost Capture Enum", |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2615 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2616 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2617 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2618 | .private_value = 0x23 | 0x100, |
| 2619 | }, |
| 2620 | {} |
| 2621 | }; |
| 2622 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2623 | static const struct hda_verb cxt5066_init_verbs[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2624 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2625 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2626 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2627 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2628 | |
| 2629 | /* Speakers */ |
| 2630 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2631 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2632 | |
| 2633 | /* HP, Amp */ |
| 2634 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2635 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2636 | |
| 2637 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2638 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2639 | |
| 2640 | /* DAC1 */ |
| 2641 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2642 | |
| 2643 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2644 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2645 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2646 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2647 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2648 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2649 | |
| 2650 | /* no digital microphone support yet */ |
| 2651 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2652 | |
| 2653 | /* Audio input selector */ |
| 2654 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2655 | |
| 2656 | /* SPDIF route: PCM */ |
| 2657 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2658 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2659 | |
| 2660 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2661 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2662 | |
| 2663 | /* EAPD */ |
| 2664 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2665 | |
| 2666 | /* not handling these yet */ |
| 2667 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2668 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2669 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2670 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2671 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2672 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2673 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2674 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2675 | { } /* end */ |
| 2676 | }; |
| 2677 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2678 | static const struct hda_verb cxt5066_init_verbs_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2679 | /* Port A: headphones */ |
| 2680 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2681 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2682 | |
| 2683 | /* Port B: external microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2684 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2685 | |
| 2686 | /* Port C: internal microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2687 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2688 | |
| 2689 | /* Port D: unused */ |
| 2690 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2691 | |
| 2692 | /* Port E: unused, but has primary EAPD */ |
| 2693 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2694 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2695 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2696 | /* Port F: external DC input through microphone port */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2697 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2698 | |
| 2699 | /* Port G: internal speakers */ |
| 2700 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2701 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2702 | |
| 2703 | /* DAC1 */ |
| 2704 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2705 | |
| 2706 | /* DAC2: unused */ |
| 2707 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2708 | |
| 2709 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2710 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2711 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2712 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2713 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2714 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2715 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2716 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2717 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2718 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2719 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2720 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2721 | |
| 2722 | /* Disable digital microphone port */ |
| 2723 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2724 | |
| 2725 | /* Audio input selectors */ |
| 2726 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2727 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2728 | |
| 2729 | /* Disable SPDIF */ |
| 2730 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2731 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2732 | |
| 2733 | /* enable unsolicited events for Port A and B */ |
| 2734 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2735 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2736 | { } /* end */ |
| 2737 | }; |
| 2738 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2739 | static const struct hda_verb cxt5066_init_verbs_vostro[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2740 | /* Port A: headphones */ |
| 2741 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2742 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2743 | |
| 2744 | /* Port B: external microphone */ |
| 2745 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2746 | |
| 2747 | /* Port C: unused */ |
| 2748 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2749 | |
| 2750 | /* Port D: unused */ |
| 2751 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2752 | |
| 2753 | /* Port E: unused, but has primary EAPD */ |
| 2754 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2755 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2756 | |
| 2757 | /* Port F: unused */ |
| 2758 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2759 | |
| 2760 | /* Port G: internal speakers */ |
| 2761 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2762 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2763 | |
| 2764 | /* DAC1 */ |
| 2765 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2766 | |
| 2767 | /* DAC2: unused */ |
| 2768 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2769 | |
| 2770 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2771 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2772 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2773 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2774 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2775 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2776 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2777 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2778 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2779 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2780 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2781 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2782 | |
| 2783 | /* Digital microphone port */ |
| 2784 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2785 | |
| 2786 | /* Audio input selectors */ |
| 2787 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2788 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2789 | |
| 2790 | /* Disable SPDIF */ |
| 2791 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2792 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2793 | |
| 2794 | /* enable unsolicited events for Port A and B */ |
| 2795 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2796 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2797 | { } /* end */ |
| 2798 | }; |
| 2799 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2800 | static const struct hda_verb cxt5066_init_verbs_ideapad[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2801 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2802 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2803 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2804 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2805 | |
| 2806 | /* Speakers */ |
| 2807 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2808 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2809 | |
| 2810 | /* HP, Amp */ |
| 2811 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2812 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2813 | |
| 2814 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2815 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2816 | |
| 2817 | /* DAC1 */ |
| 2818 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2819 | |
| 2820 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2821 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2822 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2823 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2824 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2825 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2826 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2827 | |
| 2828 | /* Audio input selector */ |
| 2829 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2830 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2831 | |
| 2832 | /* SPDIF route: PCM */ |
| 2833 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2834 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2835 | |
| 2836 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2837 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2838 | |
| 2839 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2840 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2841 | |
| 2842 | /* EAPD */ |
| 2843 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2844 | |
| 2845 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2846 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2847 | { } /* end */ |
| 2848 | }; |
| 2849 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2850 | static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2851 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2852 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2853 | |
| 2854 | /* Port G: internal speakers */ |
| 2855 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2856 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2857 | |
| 2858 | /* Port A: HP, Amp */ |
| 2859 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2860 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2861 | |
| 2862 | /* Port B: Mic Dock */ |
| 2863 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2864 | |
| 2865 | /* Port C: Mic */ |
| 2866 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2867 | |
| 2868 | /* Port D: HP Dock, Amp */ |
| 2869 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2870 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2871 | |
| 2872 | /* DAC1 */ |
| 2873 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2874 | |
| 2875 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2876 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2877 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2878 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2879 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2880 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2881 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2882 | |
| 2883 | /* Audio input selector */ |
| 2884 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2885 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2886 | |
| 2887 | /* SPDIF route: PCM */ |
| 2888 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2889 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2890 | |
| 2891 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2892 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2893 | |
| 2894 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2895 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2896 | |
| 2897 | /* EAPD */ |
| 2898 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2899 | |
| 2900 | /* enable unsolicited events for Port A, B, C and D */ |
| 2901 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2902 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2903 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2904 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2905 | { } /* end */ |
| 2906 | }; |
| 2907 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2908 | static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2909 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2910 | { } /* end */ |
| 2911 | }; |
| 2912 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2913 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2914 | static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2915 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2916 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2917 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2918 | { } /* end */ |
| 2919 | }; |
| 2920 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2921 | /* initialize jack-sensing, too */ |
| 2922 | static int cxt5066_init(struct hda_codec *codec) |
| 2923 | { |
| 2924 | snd_printdd("CXT5066: init\n"); |
| 2925 | conexant_init(codec); |
| 2926 | if (codec->patch_ops.unsol_event) { |
| 2927 | cxt5066_hp_automute(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2928 | cxt5066_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2929 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2930 | cxt5066_set_mic_boost(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2931 | return 0; |
| 2932 | } |
| 2933 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2934 | static int cxt5066_olpc_init(struct hda_codec *codec) |
| 2935 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2936 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2937 | snd_printdd("CXT5066: init\n"); |
| 2938 | conexant_init(codec); |
| 2939 | cxt5066_hp_automute(codec); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2940 | if (!spec->dc_enable) { |
| 2941 | cxt5066_set_mic_boost(codec); |
| 2942 | cxt5066_olpc_automic(codec); |
| 2943 | } else { |
| 2944 | cxt5066_enable_dc(codec); |
| 2945 | } |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2946 | return 0; |
| 2947 | } |
| 2948 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2949 | enum { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2950 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2951 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
| 2952 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2953 | CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2954 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2955 | CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2956 | 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] | 2957 | CXT5066_HP_LAPTOP, /* HP Laptop */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2958 | CXT5066_AUTO, /* BIOS auto-parser */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2959 | CXT5066_MODELS |
| 2960 | }; |
| 2961 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2962 | static const char * const cxt5066_models[CXT5066_MODELS] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2963 | [CXT5066_LAPTOP] = "laptop", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2964 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
| 2965 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2966 | [CXT5066_DELL_VOSTRO] = "dell-vostro", |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2967 | [CXT5066_IDEAPAD] = "ideapad", |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2968 | [CXT5066_THINKPAD] = "thinkpad", |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2969 | [CXT5066_ASUS] = "asus", |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2970 | [CXT5066_HP_LAPTOP] = "hp-laptop", |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2971 | [CXT5066_AUTO] = "auto", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2972 | }; |
| 2973 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2974 | static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
Takashi Iwai | 00cd0bb | 2010-10-21 09:57:40 +0200 | [diff] [blame] | 2975 | SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2976 | SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), |
David Henningsson | 8a96b1e | 2010-12-09 07:17:27 +0100 | [diff] [blame] | 2977 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), |
Daniel T Chen | ca6cd85 | 2011-01-08 18:25:27 -0500 | [diff] [blame] | 2978 | SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), |
Anisse Astier | 231f50b | 2010-04-28 18:05:06 +0200 | [diff] [blame] | 2979 | SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), |
David Henningsson | ebbd224 | 2011-02-23 13:15:56 +0100 | [diff] [blame] | 2980 | SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), |
| 2981 | SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2982 | SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2983 | SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2984 | SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2985 | SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), |
Anisse Astier | 2ca9cac | 2010-09-10 15:47:55 +0200 | [diff] [blame] | 2986 | SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), |
Daniel T Chen | c536668 | 2010-05-04 22:07:58 -0400 | [diff] [blame] | 2987 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), |
David Henningsson | 5637edb | 2010-09-17 10:58:03 +0200 | [diff] [blame] | 2988 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 2989 | CXT5066_LAPTOP), |
| 2990 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), |
Takashi Iwai | 4d15564 | 2010-09-07 11:58:30 +0200 | [diff] [blame] | 2991 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), |
Manoj Iyer | ef61d4e | 2010-12-03 18:43:55 -0600 | [diff] [blame] | 2992 | SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), |
David Henningsson | 1959387 | 2011-01-27 10:28:46 +0100 | [diff] [blame] | 2993 | SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), |
David Henningsson | 8401265 | 2011-03-31 09:36:19 +0200 | [diff] [blame] | 2994 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD), |
David Henningsson | b2cb129 | 2011-04-05 07:55:24 +0200 | [diff] [blame] | 2995 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), |
David Henningsson | d2859fd | 2011-05-23 08:26:16 +0200 | [diff] [blame] | 2996 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2997 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2998 | {} |
| 2999 | }; |
| 3000 | |
| 3001 | static int patch_cxt5066(struct hda_codec *codec) |
| 3002 | { |
| 3003 | struct conexant_spec *spec; |
| 3004 | int board_config; |
| 3005 | |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3006 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, |
| 3007 | cxt5066_models, cxt5066_cfg_tbl); |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3008 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 3009 | board_config = CXT5066_AUTO; /* model=auto as default */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3010 | if (board_config == CXT5066_AUTO) |
| 3011 | return patch_conexant_auto(codec); |
| 3012 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3013 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3014 | if (!spec) |
| 3015 | return -ENOMEM; |
| 3016 | codec->spec = spec; |
| 3017 | |
| 3018 | codec->patch_ops = conexant_patch_ops; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3019 | codec->patch_ops.init = conexant_init; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3020 | |
| 3021 | spec->dell_automute = 0; |
| 3022 | spec->multiout.max_channels = 2; |
| 3023 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); |
| 3024 | spec->multiout.dac_nids = cxt5066_dac_nids; |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 3025 | conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, |
| 3026 | ARRAY_SIZE(cxt5066_digout_pin_nids)); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3027 | spec->num_adc_nids = 1; |
| 3028 | spec->adc_nids = cxt5066_adc_nids; |
| 3029 | spec->capsrc_nids = cxt5066_capsrc_nids; |
| 3030 | spec->input_mux = &cxt5066_capture_source; |
| 3031 | |
| 3032 | spec->port_d_mode = PIN_HP; |
| 3033 | |
| 3034 | spec->num_init_verbs = 1; |
| 3035 | spec->init_verbs[0] = cxt5066_init_verbs; |
| 3036 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); |
| 3037 | spec->channel_mode = cxt5066_modes; |
| 3038 | spec->cur_adc = 0; |
| 3039 | spec->cur_adc_idx = 0; |
| 3040 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3041 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 3042 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3043 | switch (board_config) { |
| 3044 | default: |
| 3045 | case CXT5066_LAPTOP: |
| 3046 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3047 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3048 | break; |
| 3049 | case CXT5066_DELL_LAPTOP: |
| 3050 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3051 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3052 | |
| 3053 | spec->port_d_mode = PIN_OUT; |
| 3054 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; |
| 3055 | spec->num_init_verbs++; |
| 3056 | spec->dell_automute = 1; |
| 3057 | break; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3058 | case CXT5066_ASUS: |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3059 | case CXT5066_HP_LAPTOP: |
| 3060 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3061 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3062 | spec->init_verbs[spec->num_init_verbs] = |
| 3063 | cxt5066_init_verbs_hp_laptop; |
| 3064 | spec->num_init_verbs++; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3065 | spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; |
| 3066 | spec->asus = board_config == CXT5066_ASUS; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3067 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3068 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3069 | /* no S/PDIF out */ |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 3070 | if (board_config == CXT5066_HP_LAPTOP) |
| 3071 | spec->multiout.dig_out_nid = 0; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3072 | /* input source automatically selected */ |
| 3073 | spec->input_mux = NULL; |
| 3074 | spec->port_d_mode = 0; |
| 3075 | spec->mic_boost = 3; /* default 30dB gain */ |
| 3076 | break; |
| 3077 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3078 | case CXT5066_OLPC_XO_1_5: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3079 | codec->patch_ops.init = cxt5066_olpc_init; |
| 3080 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3081 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
| 3082 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3083 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3084 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3085 | spec->port_d_mode = 0; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3086 | spec->mic_boost = 3; /* default 30dB gain */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3087 | |
| 3088 | /* no S/PDIF out */ |
| 3089 | spec->multiout.dig_out_nid = 0; |
| 3090 | |
| 3091 | /* input source automatically selected */ |
| 3092 | spec->input_mux = NULL; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3093 | |
| 3094 | /* our capture hooks which allow us to turn on the microphone LED |
| 3095 | * at the right time */ |
| 3096 | spec->capture_prepare = cxt5066_olpc_capture_prepare; |
| 3097 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3098 | break; |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 3099 | case CXT5066_DELL_VOSTRO: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3100 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3101 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3102 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
| 3103 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
| 3104 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3105 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3106 | spec->port_d_mode = 0; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3107 | spec->dell_vostro = 1; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3108 | spec->mic_boost = 3; /* default 30dB gain */ |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3109 | |
| 3110 | /* no S/PDIF out */ |
| 3111 | spec->multiout.dig_out_nid = 0; |
| 3112 | |
| 3113 | /* input source automatically selected */ |
| 3114 | spec->input_mux = NULL; |
| 3115 | break; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3116 | case CXT5066_IDEAPAD: |
| 3117 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3118 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3119 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3120 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3121 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; |
| 3122 | spec->port_d_mode = 0; |
| 3123 | spec->ideapad = 1; |
| 3124 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3125 | |
| 3126 | /* no S/PDIF out */ |
| 3127 | spec->multiout.dig_out_nid = 0; |
| 3128 | |
| 3129 | /* input source automatically selected */ |
| 3130 | spec->input_mux = NULL; |
| 3131 | break; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3132 | case CXT5066_THINKPAD: |
| 3133 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3134 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3135 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3136 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3137 | spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; |
| 3138 | spec->thinkpad = 1; |
| 3139 | spec->port_d_mode = PIN_OUT; |
| 3140 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3141 | |
| 3142 | /* no S/PDIF out */ |
| 3143 | spec->multiout.dig_out_nid = 0; |
| 3144 | |
| 3145 | /* input source automatically selected */ |
| 3146 | spec->input_mux = NULL; |
| 3147 | break; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3148 | } |
| 3149 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3150 | if (spec->beep_amp) |
| 3151 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
| 3152 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3153 | return 0; |
| 3154 | } |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3155 | |
| 3156 | /* |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3157 | * Automatic parser for CX20641 & co |
| 3158 | */ |
| 3159 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3160 | static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3161 | struct hda_codec *codec, |
| 3162 | unsigned int stream_tag, |
| 3163 | unsigned int format, |
| 3164 | struct snd_pcm_substream *substream) |
| 3165 | { |
| 3166 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3167 | hda_nid_t adc = spec->imux_info[spec->cur_mux[0]].adc; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3168 | if (spec->adc_switching) { |
| 3169 | spec->cur_adc = adc; |
| 3170 | spec->cur_adc_stream_tag = stream_tag; |
| 3171 | spec->cur_adc_format = format; |
| 3172 | } |
| 3173 | snd_hda_codec_setup_stream(codec, adc, stream_tag, 0, format); |
| 3174 | return 0; |
| 3175 | } |
| 3176 | |
| 3177 | static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3178 | struct hda_codec *codec, |
| 3179 | struct snd_pcm_substream *substream) |
| 3180 | { |
| 3181 | struct conexant_spec *spec = codec->spec; |
| 3182 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 3183 | spec->cur_adc = 0; |
| 3184 | return 0; |
| 3185 | } |
| 3186 | |
| 3187 | static const struct hda_pcm_stream cx_auto_pcm_analog_capture = { |
| 3188 | .substreams = 1, |
| 3189 | .channels_min = 2, |
| 3190 | .channels_max = 2, |
| 3191 | .nid = 0, /* fill later */ |
| 3192 | .ops = { |
| 3193 | .prepare = cx_auto_capture_pcm_prepare, |
| 3194 | .cleanup = cx_auto_capture_pcm_cleanup |
| 3195 | }, |
| 3196 | }; |
| 3197 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 3198 | static const hda_nid_t cx_auto_adc_nids[] = { 0x14 }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3199 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 3200 | #define get_connection_index(codec, mux, nid)\ |
| 3201 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3202 | |
| 3203 | /* get an unassigned DAC from the given list. |
| 3204 | * Return the nid if found and reduce the DAC list, or return zero if |
| 3205 | * not found |
| 3206 | */ |
| 3207 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin, |
| 3208 | hda_nid_t *dacs, int *num_dacs) |
| 3209 | { |
| 3210 | int i, nums = *num_dacs; |
| 3211 | hda_nid_t ret = 0; |
| 3212 | |
| 3213 | for (i = 0; i < nums; i++) { |
| 3214 | if (get_connection_index(codec, pin, dacs[i]) >= 0) { |
| 3215 | ret = dacs[i]; |
| 3216 | break; |
| 3217 | } |
| 3218 | } |
| 3219 | if (!ret) |
| 3220 | return 0; |
| 3221 | if (--nums > 0) |
| 3222 | memmove(dacs, dacs + 1, nums * sizeof(hda_nid_t)); |
| 3223 | *num_dacs = nums; |
| 3224 | return ret; |
| 3225 | } |
| 3226 | |
| 3227 | #define MAX_AUTO_DACS 5 |
| 3228 | |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3229 | #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */ |
| 3230 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3231 | /* fill analog DAC list from the widget tree */ |
| 3232 | static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) |
| 3233 | { |
| 3234 | hda_nid_t nid, end_nid; |
| 3235 | int nums = 0; |
| 3236 | |
| 3237 | end_nid = codec->start_nid + codec->num_nodes; |
| 3238 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3239 | unsigned int wcaps = get_wcaps(codec, nid); |
| 3240 | unsigned int type = get_wcaps_type(wcaps); |
| 3241 | if (type == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) { |
| 3242 | dacs[nums++] = nid; |
| 3243 | if (nums >= MAX_AUTO_DACS) |
| 3244 | break; |
| 3245 | } |
| 3246 | } |
| 3247 | return nums; |
| 3248 | } |
| 3249 | |
| 3250 | /* fill pin_dac_pair list from the pin and dac list */ |
| 3251 | static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, |
| 3252 | int num_pins, hda_nid_t *dacs, int *rest, |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3253 | struct pin_dac_pair *filled, int nums, |
| 3254 | int type) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3255 | { |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3256 | int i, start = nums; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3257 | |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3258 | for (i = 0; i < num_pins; i++, nums++) { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3259 | filled[nums].pin = pins[i]; |
| 3260 | filled[nums].type = type; |
| 3261 | filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3262 | if (filled[nums].dac) |
| 3263 | continue; |
| 3264 | if (filled[start].dac && get_connection_index(codec, pins[i], filled[start].dac) >= 0) { |
| 3265 | filled[nums].dac = filled[start].dac | DAC_SLAVE_FLAG; |
| 3266 | continue; |
| 3267 | } |
| 3268 | if (filled[0].dac && get_connection_index(codec, pins[i], filled[0].dac) >= 0) { |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3269 | filled[nums].dac = filled[0].dac | DAC_SLAVE_FLAG; |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3270 | continue; |
| 3271 | } |
| 3272 | snd_printdd("Failed to find a DAC for pin 0x%x", pins[i]); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3273 | } |
| 3274 | return nums; |
| 3275 | } |
| 3276 | |
| 3277 | /* parse analog output paths */ |
| 3278 | static void cx_auto_parse_output(struct hda_codec *codec) |
| 3279 | { |
| 3280 | struct conexant_spec *spec = codec->spec; |
| 3281 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3282 | hda_nid_t dacs[MAX_AUTO_DACS]; |
| 3283 | int i, j, nums, rest; |
| 3284 | |
| 3285 | rest = fill_cx_auto_dacs(codec, dacs); |
| 3286 | /* parse all analog output pins */ |
| 3287 | nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs, |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3288 | dacs, &rest, spec->dac_info, 0, |
| 3289 | AUTO_PIN_LINE_OUT); |
| 3290 | nums = fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, |
| 3291 | dacs, &rest, spec->dac_info, nums, |
| 3292 | AUTO_PIN_HP_OUT); |
| 3293 | nums = fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, |
| 3294 | dacs, &rest, spec->dac_info, nums, |
| 3295 | AUTO_PIN_SPEAKER_OUT); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3296 | spec->dac_info_filled = nums; |
| 3297 | /* fill multiout struct */ |
| 3298 | for (i = 0; i < nums; i++) { |
| 3299 | hda_nid_t dac = spec->dac_info[i].dac; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3300 | if (!dac || (dac & DAC_SLAVE_FLAG)) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3301 | continue; |
| 3302 | switch (spec->dac_info[i].type) { |
| 3303 | case AUTO_PIN_LINE_OUT: |
| 3304 | spec->private_dac_nids[spec->multiout.num_dacs] = dac; |
| 3305 | spec->multiout.num_dacs++; |
| 3306 | break; |
| 3307 | case AUTO_PIN_HP_OUT: |
| 3308 | case AUTO_PIN_SPEAKER_OUT: |
| 3309 | if (!spec->multiout.hp_nid) { |
| 3310 | spec->multiout.hp_nid = dac; |
| 3311 | break; |
| 3312 | } |
| 3313 | for (j = 0; j < ARRAY_SIZE(spec->multiout.extra_out_nid); j++) |
| 3314 | if (!spec->multiout.extra_out_nid[j]) { |
| 3315 | spec->multiout.extra_out_nid[j] = dac; |
| 3316 | break; |
| 3317 | } |
| 3318 | break; |
| 3319 | } |
| 3320 | } |
| 3321 | spec->multiout.dac_nids = spec->private_dac_nids; |
David Henningsson | 8972495 | 2011-02-16 21:34:04 +0100 | [diff] [blame] | 3322 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3323 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3324 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3325 | if (is_jack_detectable(codec, cfg->hp_pins[i])) { |
| 3326 | spec->auto_mute = 1; |
| 3327 | break; |
| 3328 | } |
| 3329 | } |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3330 | if (spec->auto_mute && |
| 3331 | cfg->line_out_pins[0] && |
| 3332 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3333 | cfg->line_out_pins[0] != cfg->hp_pins[0] && |
| 3334 | cfg->line_out_pins[0] != cfg->speaker_pins[0]) { |
| 3335 | for (i = 0; i < cfg->line_outs; i++) { |
| 3336 | if (is_jack_detectable(codec, cfg->line_out_pins[i])) { |
| 3337 | spec->detect_line = 1; |
| 3338 | break; |
| 3339 | } |
| 3340 | } |
| 3341 | spec->automute_lines = spec->detect_line; |
| 3342 | } |
| 3343 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3344 | spec->vmaster_nid = spec->private_dac_nids[0]; |
| 3345 | } |
| 3346 | |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3347 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
| 3348 | hda_nid_t *pins, bool on); |
| 3349 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3350 | static void do_automute(struct hda_codec *codec, int num_pins, |
| 3351 | hda_nid_t *pins, bool on) |
| 3352 | { |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3353 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3354 | int i; |
| 3355 | for (i = 0; i < num_pins; i++) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3356 | snd_hda_set_pin_ctl(codec, pins[i], on ? PIN_OUT : 0); |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3357 | if (spec->pin_eapd_ctrls) |
| 3358 | cx_auto_turn_eapd(codec, num_pins, pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3359 | } |
| 3360 | |
| 3361 | static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) |
| 3362 | { |
| 3363 | int i, present = 0; |
| 3364 | |
| 3365 | for (i = 0; i < num_pins; i++) { |
| 3366 | hda_nid_t nid = pins[i]; |
| 3367 | if (!nid || !is_jack_detectable(codec, nid)) |
| 3368 | break; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3369 | present |= snd_hda_jack_detect(codec, nid); |
| 3370 | } |
| 3371 | return present; |
| 3372 | } |
| 3373 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3374 | /* auto-mute/unmute speaker and line outs according to headphone jack */ |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3375 | static void cx_auto_update_speakers(struct hda_codec *codec) |
| 3376 | { |
| 3377 | struct conexant_spec *spec = codec->spec; |
| 3378 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3379 | int on = 1; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3380 | |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3381 | /* turn on HP EAPD when HP jacks are present */ |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3382 | if (spec->pin_eapd_ctrls) { |
| 3383 | if (spec->auto_mute) |
| 3384 | on = spec->hp_present; |
| 3385 | cx_auto_turn_eapd(codec, cfg->hp_outs, cfg->hp_pins, on); |
| 3386 | } |
| 3387 | |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3388 | /* mute speakers in auto-mode if HP or LO jacks are plugged */ |
| 3389 | if (spec->auto_mute) |
| 3390 | on = !(spec->hp_present || |
| 3391 | (spec->detect_line && spec->line_present)); |
| 3392 | do_automute(codec, cfg->speaker_outs, cfg->speaker_pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3393 | |
| 3394 | /* toggle line-out mutes if needed, too */ |
| 3395 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 3396 | if (cfg->line_out_pins[0] == cfg->hp_pins[0] || |
| 3397 | cfg->line_out_pins[0] == cfg->speaker_pins[0]) |
| 3398 | return; |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3399 | if (spec->auto_mute) { |
| 3400 | /* mute LO in auto-mode when HP jack is present */ |
| 3401 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT || |
| 3402 | spec->automute_lines) |
| 3403 | on = !spec->hp_present; |
| 3404 | else |
| 3405 | on = 1; |
| 3406 | } |
| 3407 | do_automute(codec, cfg->line_outs, cfg->line_out_pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3408 | } |
| 3409 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3410 | static void cx_auto_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3411 | { |
| 3412 | struct conexant_spec *spec = codec->spec; |
| 3413 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3414 | |
| 3415 | if (!spec->auto_mute) |
| 3416 | return; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3417 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, cfg->hp_pins); |
| 3418 | cx_auto_update_speakers(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3419 | } |
| 3420 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3421 | static void cx_auto_line_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3422 | { |
| 3423 | struct conexant_spec *spec = codec->spec; |
| 3424 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3425 | |
| 3426 | if (!spec->auto_mute || !spec->detect_line) |
| 3427 | return; |
| 3428 | spec->line_present = detect_jacks(codec, cfg->line_outs, |
| 3429 | cfg->line_out_pins); |
| 3430 | cx_auto_update_speakers(codec); |
| 3431 | } |
| 3432 | |
| 3433 | static int cx_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 3434 | struct snd_ctl_elem_info *uinfo) |
| 3435 | { |
| 3436 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3437 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3438 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 3439 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3440 | }; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3441 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 3442 | if (spec->automute_hp_lo) |
| 3443 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 3444 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3445 | } |
| 3446 | |
| 3447 | static int cx_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 3448 | struct snd_ctl_elem_value *ucontrol) |
| 3449 | { |
| 3450 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3451 | struct conexant_spec *spec = codec->spec; |
| 3452 | unsigned int val; |
| 3453 | if (!spec->auto_mute) |
| 3454 | val = 0; |
| 3455 | else if (!spec->automute_lines) |
| 3456 | val = 1; |
| 3457 | else |
| 3458 | val = 2; |
| 3459 | ucontrol->value.enumerated.item[0] = val; |
| 3460 | return 0; |
| 3461 | } |
| 3462 | |
| 3463 | static int cx_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 3464 | struct snd_ctl_elem_value *ucontrol) |
| 3465 | { |
| 3466 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3467 | struct conexant_spec *spec = codec->spec; |
| 3468 | |
| 3469 | switch (ucontrol->value.enumerated.item[0]) { |
| 3470 | case 0: |
| 3471 | if (!spec->auto_mute) |
| 3472 | return 0; |
| 3473 | spec->auto_mute = 0; |
| 3474 | break; |
| 3475 | case 1: |
| 3476 | if (spec->auto_mute && !spec->automute_lines) |
| 3477 | return 0; |
| 3478 | spec->auto_mute = 1; |
| 3479 | spec->automute_lines = 0; |
| 3480 | break; |
| 3481 | case 2: |
| 3482 | if (!spec->automute_hp_lo) |
| 3483 | return -EINVAL; |
| 3484 | if (spec->auto_mute && spec->automute_lines) |
| 3485 | return 0; |
| 3486 | spec->auto_mute = 1; |
| 3487 | spec->automute_lines = 1; |
| 3488 | break; |
| 3489 | default: |
| 3490 | return -EINVAL; |
| 3491 | } |
| 3492 | cx_auto_update_speakers(codec); |
| 3493 | return 1; |
| 3494 | } |
| 3495 | |
| 3496 | static const struct snd_kcontrol_new cx_automute_mode_enum[] = { |
| 3497 | { |
| 3498 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3499 | .name = "Auto-Mute Mode", |
| 3500 | .info = cx_automute_mode_info, |
| 3501 | .get = cx_automute_mode_get, |
| 3502 | .put = cx_automute_mode_put, |
| 3503 | }, |
| 3504 | { } |
| 3505 | }; |
| 3506 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3507 | static int cx_auto_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 3508 | struct snd_ctl_elem_info *uinfo) |
| 3509 | { |
| 3510 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3511 | struct conexant_spec *spec = codec->spec; |
| 3512 | |
| 3513 | return snd_hda_input_mux_info(&spec->private_imux, uinfo); |
| 3514 | } |
| 3515 | |
| 3516 | static int cx_auto_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 3517 | struct snd_ctl_elem_value *ucontrol) |
| 3518 | { |
| 3519 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3520 | struct conexant_spec *spec = codec->spec; |
| 3521 | |
| 3522 | ucontrol->value.enumerated.item[0] = spec->cur_mux[0]; |
| 3523 | return 0; |
| 3524 | } |
| 3525 | |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3526 | /* look for the route the given pin from mux and return the index; |
| 3527 | * if do_select is set, actually select the route. |
| 3528 | */ |
| 3529 | static int __select_input_connection(struct hda_codec *codec, hda_nid_t mux, |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3530 | hda_nid_t pin, hda_nid_t *srcp, |
| 3531 | bool do_select, int depth) |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3532 | { |
David Henningsson | 739572a | 2012-09-20 15:41:21 +0200 | [diff] [blame] | 3533 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3534 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
David Henningsson | 739572a | 2012-09-20 15:41:21 +0200 | [diff] [blame] | 3535 | int startidx, i, nums; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3536 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3537 | switch (get_wcaps_type(get_wcaps(codec, mux))) { |
| 3538 | case AC_WID_AUD_IN: |
| 3539 | case AC_WID_AUD_SEL: |
| 3540 | case AC_WID_AUD_MIX: |
| 3541 | break; |
| 3542 | default: |
| 3543 | return -1; |
| 3544 | } |
| 3545 | |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3546 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 3547 | for (i = 0; i < nums; i++) |
| 3548 | if (conn[i] == pin) { |
| 3549 | if (do_select) |
| 3550 | snd_hda_codec_write(codec, mux, 0, |
| 3551 | AC_VERB_SET_CONNECT_SEL, i); |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3552 | if (srcp) |
| 3553 | *srcp = mux; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3554 | return i; |
| 3555 | } |
| 3556 | depth++; |
| 3557 | if (depth == 2) |
| 3558 | return -1; |
David Henningsson | 739572a | 2012-09-20 15:41:21 +0200 | [diff] [blame] | 3559 | |
| 3560 | /* Try to rotate around connections to avoid one boost controlling |
| 3561 | another input path as well */ |
| 3562 | startidx = 0; |
| 3563 | for (i = 0; i < spec->private_imux.num_items; i++) |
| 3564 | if (spec->imux_info[i].pin == pin) { |
| 3565 | startidx = i; |
| 3566 | break; |
| 3567 | } |
| 3568 | |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3569 | for (i = 0; i < nums; i++) { |
David Henningsson | 739572a | 2012-09-20 15:41:21 +0200 | [diff] [blame] | 3570 | int j = (i + startidx) % nums; |
| 3571 | int ret = __select_input_connection(codec, conn[j], pin, srcp, |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3572 | do_select, depth); |
| 3573 | if (ret >= 0) { |
| 3574 | if (do_select) |
| 3575 | snd_hda_codec_write(codec, mux, 0, |
David Henningsson | 739572a | 2012-09-20 15:41:21 +0200 | [diff] [blame] | 3576 | AC_VERB_SET_CONNECT_SEL, j); |
| 3577 | return j; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | return -1; |
| 3581 | } |
| 3582 | |
| 3583 | static void select_input_connection(struct hda_codec *codec, hda_nid_t mux, |
| 3584 | hda_nid_t pin) |
| 3585 | { |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3586 | __select_input_connection(codec, mux, pin, NULL, true, 0); |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3587 | } |
| 3588 | |
| 3589 | static int get_input_connection(struct hda_codec *codec, hda_nid_t mux, |
| 3590 | hda_nid_t pin) |
| 3591 | { |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3592 | return __select_input_connection(codec, mux, pin, NULL, false, 0); |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3593 | } |
| 3594 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3595 | static int cx_auto_mux_enum_update(struct hda_codec *codec, |
| 3596 | const struct hda_input_mux *imux, |
| 3597 | unsigned int idx) |
| 3598 | { |
| 3599 | struct conexant_spec *spec = codec->spec; |
| 3600 | hda_nid_t adc; |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3601 | int changed = 1; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3602 | |
| 3603 | if (!imux->num_items) |
| 3604 | return 0; |
| 3605 | if (idx >= imux->num_items) |
| 3606 | idx = imux->num_items - 1; |
| 3607 | if (spec->cur_mux[0] == idx) |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3608 | changed = 0; |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3609 | adc = spec->imux_info[idx].adc; |
| 3610 | select_input_connection(codec, spec->imux_info[idx].adc, |
| 3611 | spec->imux_info[idx].pin); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3612 | if (spec->cur_adc && spec->cur_adc != adc) { |
| 3613 | /* stream is running, let's swap the current ADC */ |
| 3614 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 3615 | spec->cur_adc = adc; |
| 3616 | snd_hda_codec_setup_stream(codec, adc, |
| 3617 | spec->cur_adc_stream_tag, 0, |
| 3618 | spec->cur_adc_format); |
| 3619 | } |
| 3620 | spec->cur_mux[0] = idx; |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3621 | return changed; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | static int cx_auto_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 3625 | struct snd_ctl_elem_value *ucontrol) |
| 3626 | { |
| 3627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3628 | struct conexant_spec *spec = codec->spec; |
| 3629 | |
| 3630 | return cx_auto_mux_enum_update(codec, &spec->private_imux, |
| 3631 | ucontrol->value.enumerated.item[0]); |
| 3632 | } |
| 3633 | |
| 3634 | static const struct snd_kcontrol_new cx_auto_capture_mixers[] = { |
| 3635 | { |
| 3636 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3637 | .name = "Capture Source", |
| 3638 | .info = cx_auto_mux_enum_info, |
| 3639 | .get = cx_auto_mux_enum_get, |
| 3640 | .put = cx_auto_mux_enum_put |
| 3641 | }, |
| 3642 | {} |
| 3643 | }; |
| 3644 | |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3645 | static bool select_automic(struct hda_codec *codec, int idx, bool detect) |
| 3646 | { |
| 3647 | struct conexant_spec *spec = codec->spec; |
| 3648 | if (idx < 0) |
| 3649 | return false; |
| 3650 | if (detect && !snd_hda_jack_detect(codec, spec->imux_info[idx].pin)) |
| 3651 | return false; |
| 3652 | cx_auto_mux_enum_update(codec, &spec->private_imux, idx); |
| 3653 | return true; |
| 3654 | } |
| 3655 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3656 | /* automatic switch internal and external mic */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3657 | static void cx_auto_automic(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3658 | { |
| 3659 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3660 | |
| 3661 | if (!spec->auto_mic) |
| 3662 | return; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3663 | if (!select_automic(codec, spec->auto_mic_ext, true)) |
| 3664 | if (!select_automic(codec, spec->auto_mic_dock, true)) |
| 3665 | select_automic(codec, spec->auto_mic_int, false); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3666 | } |
| 3667 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3668 | /* check whether the pin config is suitable for auto-mic switching; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3669 | * auto-mic is enabled only when one int-mic and one ext- and/or |
| 3670 | * one dock-mic exist |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3671 | */ |
| 3672 | static void cx_auto_check_auto_mic(struct hda_codec *codec) |
| 3673 | { |
| 3674 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3675 | int pset[INPUT_PIN_ATTR_NORMAL + 1]; |
| 3676 | int i; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3677 | |
Takashi Iwai | 506a419 | 2011-05-23 20:07:15 +0200 | [diff] [blame] | 3678 | for (i = 0; i < ARRAY_SIZE(pset); i++) |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3679 | pset[i] = -1; |
| 3680 | for (i = 0; i < spec->private_imux.num_items; i++) { |
| 3681 | hda_nid_t pin = spec->imux_info[i].pin; |
| 3682 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3683 | int type, attr; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3684 | attr = snd_hda_get_input_pin_attr(def_conf); |
| 3685 | if (attr == INPUT_PIN_ATTR_UNUSED) |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3686 | return; /* invalid entry */ |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3687 | if (attr > INPUT_PIN_ATTR_NORMAL) |
| 3688 | attr = INPUT_PIN_ATTR_NORMAL; |
| 3689 | if (attr != INPUT_PIN_ATTR_INT && |
| 3690 | !is_jack_detectable(codec, pin)) |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3691 | return; /* non-detectable pin */ |
| 3692 | type = get_defcfg_device(def_conf); |
| 3693 | if (type != AC_JACK_MIC_IN && |
| 3694 | (attr != INPUT_PIN_ATTR_DOCK || type != AC_JACK_LINE_IN)) |
| 3695 | return; /* no valid input type */ |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3696 | if (pset[attr] >= 0) |
| 3697 | return; /* already occupied */ |
| 3698 | pset[attr] = i; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3699 | } |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3700 | if (pset[INPUT_PIN_ATTR_INT] < 0 || |
| 3701 | (pset[INPUT_PIN_ATTR_NORMAL] < 0 && pset[INPUT_PIN_ATTR_DOCK])) |
| 3702 | return; /* no input to switch*/ |
| 3703 | spec->auto_mic = 1; |
| 3704 | spec->auto_mic_ext = pset[INPUT_PIN_ATTR_NORMAL]; |
| 3705 | spec->auto_mic_dock = pset[INPUT_PIN_ATTR_DOCK]; |
| 3706 | spec->auto_mic_int = pset[INPUT_PIN_ATTR_INT]; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3707 | } |
| 3708 | |
| 3709 | static void cx_auto_parse_input(struct hda_codec *codec) |
| 3710 | { |
| 3711 | struct conexant_spec *spec = codec->spec; |
| 3712 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3713 | struct hda_input_mux *imux; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3714 | int i, j; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3715 | |
| 3716 | imux = &spec->private_imux; |
| 3717 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3718 | for (j = 0; j < spec->num_adc_nids; j++) { |
| 3719 | hda_nid_t adc = spec->adc_nids[j]; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3720 | int idx = get_input_connection(codec, adc, |
| 3721 | cfg->inputs[i].pin); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3722 | if (idx >= 0) { |
| 3723 | const char *label; |
| 3724 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3725 | spec->imux_info[imux->num_items].index = i; |
| 3726 | spec->imux_info[imux->num_items].boost = 0; |
| 3727 | spec->imux_info[imux->num_items].adc = adc; |
| 3728 | spec->imux_info[imux->num_items].pin = |
Takashi Iwai | f6100bb | 2011-05-13 18:26:39 +0200 | [diff] [blame] | 3729 | cfg->inputs[i].pin; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3730 | snd_hda_add_imux_item(imux, label, idx, NULL); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3731 | break; |
| 3732 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3733 | } |
| 3734 | } |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3735 | if (imux->num_items >= 2 && cfg->num_inputs == imux->num_items) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3736 | cx_auto_check_auto_mic(codec); |
Takashi Iwai | 7675535 | 2011-08-24 10:53:10 +0200 | [diff] [blame] | 3737 | if (imux->num_items > 1) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3738 | for (i = 1; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3739 | if (spec->imux_info[i].adc != spec->imux_info[0].adc) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3740 | spec->adc_switching = 1; |
| 3741 | break; |
| 3742 | } |
| 3743 | } |
| 3744 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3745 | } |
| 3746 | |
| 3747 | /* get digital-input audio widget corresponding to the given pin */ |
| 3748 | static hda_nid_t cx_auto_get_dig_in(struct hda_codec *codec, hda_nid_t pin) |
| 3749 | { |
| 3750 | hda_nid_t nid, end_nid; |
| 3751 | |
| 3752 | end_nid = codec->start_nid + codec->num_nodes; |
| 3753 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3754 | unsigned int wcaps = get_wcaps(codec, nid); |
| 3755 | unsigned int type = get_wcaps_type(wcaps); |
| 3756 | if (type == AC_WID_AUD_IN && (wcaps & AC_WCAP_DIGITAL)) { |
| 3757 | if (get_connection_index(codec, nid, pin) >= 0) |
| 3758 | return nid; |
| 3759 | } |
| 3760 | } |
| 3761 | return 0; |
| 3762 | } |
| 3763 | |
| 3764 | static void cx_auto_parse_digital(struct hda_codec *codec) |
| 3765 | { |
| 3766 | struct conexant_spec *spec = codec->spec; |
| 3767 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3768 | hda_nid_t nid; |
| 3769 | |
| 3770 | if (cfg->dig_outs && |
| 3771 | snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) == 1) |
| 3772 | spec->multiout.dig_out_nid = nid; |
| 3773 | if (cfg->dig_in_pin) |
| 3774 | spec->dig_in_nid = cx_auto_get_dig_in(codec, cfg->dig_in_pin); |
| 3775 | } |
| 3776 | |
| 3777 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3778 | static void cx_auto_parse_beep(struct hda_codec *codec) |
| 3779 | { |
| 3780 | struct conexant_spec *spec = codec->spec; |
| 3781 | hda_nid_t nid, end_nid; |
| 3782 | |
| 3783 | end_nid = codec->start_nid + codec->num_nodes; |
| 3784 | for (nid = codec->start_nid; nid < end_nid; nid++) |
| 3785 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { |
| 3786 | set_beep_amp(spec, nid, 0, HDA_OUTPUT); |
| 3787 | break; |
| 3788 | } |
| 3789 | } |
| 3790 | #else |
| 3791 | #define cx_auto_parse_beep(codec) |
| 3792 | #endif |
| 3793 | |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3794 | /* parse EAPDs */ |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3795 | static void cx_auto_parse_eapd(struct hda_codec *codec) |
| 3796 | { |
| 3797 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3798 | hda_nid_t nid, end_nid; |
| 3799 | |
| 3800 | end_nid = codec->start_nid + codec->num_nodes; |
| 3801 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3802 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 3803 | continue; |
| 3804 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) |
| 3805 | continue; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3806 | spec->eapds[spec->num_eapds++] = nid; |
| 3807 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) |
| 3808 | break; |
| 3809 | } |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3810 | |
| 3811 | /* NOTE: below is a wild guess; if we have more than two EAPDs, |
| 3812 | * it's a new chip, where EAPDs are supposed to be associated to |
| 3813 | * pins, and we can control EAPD per pin. |
| 3814 | * OTOH, if only one or two EAPDs are found, it's an old chip, |
| 3815 | * thus it might control over all pins. |
| 3816 | */ |
| 3817 | spec->pin_eapd_ctrls = spec->num_eapds > 2; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3818 | } |
| 3819 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3820 | static int cx_auto_parse_auto_config(struct hda_codec *codec) |
| 3821 | { |
| 3822 | struct conexant_spec *spec = codec->spec; |
| 3823 | int err; |
| 3824 | |
| 3825 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
| 3826 | if (err < 0) |
| 3827 | return err; |
| 3828 | |
| 3829 | cx_auto_parse_output(codec); |
| 3830 | cx_auto_parse_input(codec); |
| 3831 | cx_auto_parse_digital(codec); |
| 3832 | cx_auto_parse_beep(codec); |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3833 | cx_auto_parse_eapd(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3834 | return 0; |
| 3835 | } |
| 3836 | |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3837 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
| 3838 | hda_nid_t *pins, bool on) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3839 | { |
| 3840 | int i; |
| 3841 | for (i = 0; i < num_pins; i++) { |
| 3842 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) |
| 3843 | snd_hda_codec_write(codec, pins[i], 0, |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3844 | AC_VERB_SET_EAPD_BTLENABLE, |
| 3845 | on ? 0x02 : 0); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3846 | } |
| 3847 | } |
| 3848 | |
| 3849 | static void select_connection(struct hda_codec *codec, hda_nid_t pin, |
| 3850 | hda_nid_t src) |
| 3851 | { |
| 3852 | int idx = get_connection_index(codec, pin, src); |
| 3853 | if (idx >= 0) |
| 3854 | snd_hda_codec_write(codec, pin, 0, |
| 3855 | AC_VERB_SET_CONNECT_SEL, idx); |
| 3856 | } |
| 3857 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3858 | static void mute_outputs(struct hda_codec *codec, int num_nids, |
| 3859 | const hda_nid_t *nids) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3860 | { |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3861 | int i, val; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3862 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3863 | for (i = 0; i < num_nids; i++) { |
| 3864 | hda_nid_t nid = nids[i]; |
| 3865 | if (!(get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
| 3866 | continue; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3867 | if (query_amp_caps(codec, nid, HDA_OUTPUT) & AC_AMPCAP_MUTE) |
| 3868 | val = AMP_OUT_MUTE; |
| 3869 | else |
| 3870 | val = AMP_OUT_ZERO; |
| 3871 | snd_hda_codec_write(codec, nid, 0, |
| 3872 | AC_VERB_SET_AMP_GAIN_MUTE, val); |
| 3873 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3874 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3875 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3876 | static void enable_unsol_pins(struct hda_codec *codec, int num_pins, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3877 | hda_nid_t *pins, unsigned int action, |
| 3878 | hda_jack_callback cb) |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3879 | { |
| 3880 | int i; |
| 3881 | for (i = 0; i < num_pins; i++) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3882 | snd_hda_jack_detect_enable_callback(codec, pins[i], action, cb); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3883 | } |
| 3884 | |
Takashi Iwai | 07cafff | 2012-02-20 12:30:59 +0100 | [diff] [blame] | 3885 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 3886 | { |
| 3887 | int i; |
| 3888 | for (i = 0; i < nums; i++) |
| 3889 | if (list[i] == nid) |
| 3890 | return true; |
| 3891 | return false; |
| 3892 | } |
| 3893 | |
| 3894 | /* is the given NID found in any of autocfg items? */ |
| 3895 | static bool found_in_autocfg(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3896 | { |
| 3897 | int i; |
| 3898 | |
| 3899 | if (found_in_nid_list(nid, cfg->line_out_pins, cfg->line_outs) || |
| 3900 | found_in_nid_list(nid, cfg->hp_pins, cfg->hp_outs) || |
| 3901 | found_in_nid_list(nid, cfg->speaker_pins, cfg->speaker_outs) || |
| 3902 | found_in_nid_list(nid, cfg->dig_out_pins, cfg->dig_outs)) |
| 3903 | return true; |
| 3904 | for (i = 0; i < cfg->num_inputs; i++) |
| 3905 | if (cfg->inputs[i].pin == nid) |
| 3906 | return true; |
| 3907 | if (cfg->dig_in_pin == nid) |
| 3908 | return true; |
| 3909 | return false; |
| 3910 | } |
| 3911 | |
| 3912 | /* clear unsol-event tags on unused pins; Conexant codecs seem to leave |
| 3913 | * invalid unsol tags by some reason |
| 3914 | */ |
| 3915 | static void clear_unsol_on_unused_pins(struct hda_codec *codec) |
| 3916 | { |
| 3917 | struct conexant_spec *spec = codec->spec; |
| 3918 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3919 | int i; |
| 3920 | |
| 3921 | for (i = 0; i < codec->init_pins.used; i++) { |
| 3922 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
| 3923 | if (!found_in_autocfg(cfg, pin->nid)) |
| 3924 | snd_hda_codec_write(codec, pin->nid, 0, |
| 3925 | AC_VERB_SET_UNSOLICITED_ENABLE, 0); |
| 3926 | } |
| 3927 | } |
| 3928 | |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3929 | /* turn on/off EAPD according to Master switch */ |
| 3930 | static void cx_auto_vmaster_hook(void *private_data, int enabled) |
| 3931 | { |
| 3932 | struct hda_codec *codec = private_data; |
| 3933 | struct conexant_spec *spec = codec->spec; |
| 3934 | |
| 3935 | if (enabled && spec->pin_eapd_ctrls) { |
| 3936 | cx_auto_update_speakers(codec); |
| 3937 | return; |
| 3938 | } |
| 3939 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); |
| 3940 | } |
| 3941 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3942 | static void cx_auto_init_output(struct hda_codec *codec) |
| 3943 | { |
| 3944 | struct conexant_spec *spec = codec->spec; |
| 3945 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3946 | hda_nid_t nid; |
| 3947 | int i; |
| 3948 | |
| 3949 | mute_outputs(codec, spec->multiout.num_dacs, spec->multiout.dac_nids); |
Takashi Iwai | ca3649d | 2012-04-19 15:15:25 +0200 | [diff] [blame] | 3950 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3951 | unsigned int val = PIN_OUT; |
| 3952 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & |
| 3953 | AC_PINCAP_HP_DRV) |
| 3954 | val |= AC_PINCTL_HP_EN; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3955 | snd_hda_set_pin_ctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | ca3649d | 2012-04-19 15:15:25 +0200 | [diff] [blame] | 3956 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3957 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); |
| 3958 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); |
| 3959 | mute_outputs(codec, cfg->speaker_outs, cfg->speaker_pins); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3960 | for (i = 0; i < spec->dac_info_filled; i++) { |
| 3961 | nid = spec->dac_info[i].dac; |
| 3962 | if (!nid) |
| 3963 | nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3964 | else if (nid & DAC_SLAVE_FLAG) |
| 3965 | nid &= ~DAC_SLAVE_FLAG; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3966 | select_connection(codec, spec->dac_info[i].pin, nid); |
| 3967 | } |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3968 | if (spec->auto_mute) { |
| 3969 | enable_unsol_pins(codec, cfg->hp_outs, cfg->hp_pins, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3970 | CONEXANT_HP_EVENT, cx_auto_hp_automute); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3971 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, |
| 3972 | cfg->hp_pins); |
| 3973 | if (spec->detect_line) { |
| 3974 | enable_unsol_pins(codec, cfg->line_outs, |
| 3975 | cfg->line_out_pins, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 3976 | CONEXANT_LINE_EVENT, |
| 3977 | cx_auto_line_automute); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3978 | spec->line_present = |
| 3979 | detect_jacks(codec, cfg->line_outs, |
| 3980 | cfg->line_out_pins); |
| 3981 | } |
| 3982 | } |
| 3983 | cx_auto_update_speakers(codec); |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3984 | /* turn on all EAPDs if no individual EAPD control is available */ |
| 3985 | if (!spec->pin_eapd_ctrls) |
| 3986 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); |
Takashi Iwai | 07cafff | 2012-02-20 12:30:59 +0100 | [diff] [blame] | 3987 | clear_unsol_on_unused_pins(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3988 | } |
| 3989 | |
| 3990 | static void cx_auto_init_input(struct hda_codec *codec) |
| 3991 | { |
| 3992 | struct conexant_spec *spec = codec->spec; |
| 3993 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3994 | int i, val; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3995 | |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3996 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 3997 | hda_nid_t nid = spec->adc_nids[i]; |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3998 | if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) |
| 3999 | continue; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 4000 | if (query_amp_caps(codec, nid, HDA_INPUT) & AC_AMPCAP_MUTE) |
| 4001 | val = AMP_IN_MUTE(0); |
| 4002 | else |
| 4003 | val = AMP_IN_UNMUTE(0); |
| 4004 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4005 | val); |
| 4006 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4007 | |
| 4008 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 4009 | hda_nid_t pin = cfg->inputs[i].pin; |
| 4010 | unsigned int type = PIN_IN; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4011 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 4012 | type |= snd_hda_get_default_vref(codec, pin); |
| 4013 | snd_hda_set_pin_ctl(codec, pin, type); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4014 | } |
| 4015 | |
| 4016 | if (spec->auto_mic) { |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4017 | if (spec->auto_mic_ext >= 0) { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4018 | snd_hda_jack_detect_enable_callback(codec, |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 4019 | cfg->inputs[spec->auto_mic_ext].pin, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4020 | CONEXANT_MIC_EVENT, cx_auto_automic); |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4021 | } |
| 4022 | if (spec->auto_mic_dock >= 0) { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4023 | snd_hda_jack_detect_enable_callback(codec, |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 4024 | cfg->inputs[spec->auto_mic_dock].pin, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4025 | CONEXANT_MIC_EVENT, cx_auto_automic); |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4026 | } |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4027 | cx_auto_automic(codec, NULL); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4028 | } else { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4029 | select_input_connection(codec, spec->imux_info[0].adc, |
| 4030 | spec->imux_info[0].pin); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4031 | } |
| 4032 | } |
| 4033 | |
| 4034 | static void cx_auto_init_digital(struct hda_codec *codec) |
| 4035 | { |
| 4036 | struct conexant_spec *spec = codec->spec; |
| 4037 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4038 | |
| 4039 | if (spec->multiout.dig_out_nid) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4040 | snd_hda_set_pin_ctl(codec, cfg->dig_out_pins[0], PIN_OUT); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4041 | if (spec->dig_in_nid) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4042 | snd_hda_set_pin_ctl(codec, cfg->dig_in_pin, PIN_IN); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4043 | } |
| 4044 | |
| 4045 | static int cx_auto_init(struct hda_codec *codec) |
| 4046 | { |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4047 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 4048 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4049 | cx_auto_init_output(codec); |
| 4050 | cx_auto_init_input(codec); |
| 4051 | cx_auto_init_digital(codec); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 4052 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4053 | return 0; |
| 4054 | } |
| 4055 | |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4056 | static int cx_auto_add_volume_idx(struct hda_codec *codec, const char *basename, |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4057 | const char *dir, int cidx, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4058 | hda_nid_t nid, int hda_dir, int amp_idx, int chs) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4059 | { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4060 | static char name[44]; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4061 | static struct snd_kcontrol_new knew[] = { |
| 4062 | HDA_CODEC_VOLUME(name, 0, 0, 0), |
| 4063 | HDA_CODEC_MUTE(name, 0, 0, 0), |
| 4064 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4065 | static const char * const sfx[2] = { "Volume", "Switch" }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4066 | int i, err; |
| 4067 | |
| 4068 | for (i = 0; i < 2; i++) { |
| 4069 | struct snd_kcontrol *kctl; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4070 | knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, chs, amp_idx, |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4071 | hda_dir); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4072 | knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; |
| 4073 | knew[i].index = cidx; |
| 4074 | snprintf(name, sizeof(name), "%s%s %s", basename, dir, sfx[i]); |
| 4075 | kctl = snd_ctl_new1(&knew[i], codec); |
| 4076 | if (!kctl) |
| 4077 | return -ENOMEM; |
| 4078 | err = snd_hda_ctl_add(codec, nid, kctl); |
| 4079 | if (err < 0) |
| 4080 | return err; |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4081 | if (!(query_amp_caps(codec, nid, hda_dir) & |
| 4082 | (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4083 | break; |
| 4084 | } |
| 4085 | return 0; |
| 4086 | } |
| 4087 | |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4088 | #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \ |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4089 | cx_auto_add_volume_idx(codec, str, dir, cidx, nid, hda_dir, 0, 3) |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4090 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4091 | #define cx_auto_add_pb_volume(codec, nid, str, idx) \ |
| 4092 | cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) |
| 4093 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4094 | static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac, |
| 4095 | hda_nid_t pin, const char *name, int idx) |
| 4096 | { |
| 4097 | unsigned int caps; |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 4098 | if (dac && !(dac & DAC_SLAVE_FLAG)) { |
| 4099 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); |
| 4100 | if (caps & AC_AMPCAP_NUM_STEPS) |
| 4101 | return cx_auto_add_pb_volume(codec, dac, name, idx); |
| 4102 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4103 | caps = query_amp_caps(codec, pin, HDA_OUTPUT); |
| 4104 | if (caps & AC_AMPCAP_NUM_STEPS) |
| 4105 | return cx_auto_add_pb_volume(codec, pin, name, idx); |
| 4106 | return 0; |
| 4107 | } |
| 4108 | |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4109 | static bool is_2_1_speaker(struct conexant_spec *spec) |
| 4110 | { |
| 4111 | int i, type, num_spk = 0; |
| 4112 | |
| 4113 | for (i = 0; i < spec->dac_info_filled; i++) { |
| 4114 | type = spec->dac_info[i].type; |
| 4115 | if (type == AUTO_PIN_LINE_OUT) |
| 4116 | type = spec->autocfg.line_out_type; |
| 4117 | if (type == AUTO_PIN_SPEAKER_OUT) |
| 4118 | num_spk++; |
| 4119 | } |
| 4120 | return (num_spk == 2 && spec->autocfg.line_out_type != AUTO_PIN_LINE_OUT); |
| 4121 | } |
| 4122 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4123 | static int cx_auto_build_output_controls(struct hda_codec *codec) |
| 4124 | { |
| 4125 | struct conexant_spec *spec = codec->spec; |
| 4126 | int i, err; |
| 4127 | int num_line = 0, num_hp = 0, num_spk = 0; |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4128 | bool speaker_2_1; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4129 | static const char * const texts[3] = { "Front", "Surround", "CLFE" }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4130 | |
| 4131 | if (spec->dac_info_filled == 1) |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4132 | return try_add_pb_volume(codec, spec->dac_info[0].dac, |
| 4133 | spec->dac_info[0].pin, |
| 4134 | "Master", 0); |
| 4135 | |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4136 | speaker_2_1 = is_2_1_speaker(spec); |
| 4137 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4138 | for (i = 0; i < spec->dac_info_filled; i++) { |
| 4139 | const char *label; |
| 4140 | int idx, type; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 4141 | hda_nid_t dac = spec->dac_info[i].dac; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4142 | type = spec->dac_info[i].type; |
| 4143 | if (type == AUTO_PIN_LINE_OUT) |
| 4144 | type = spec->autocfg.line_out_type; |
| 4145 | switch (type) { |
| 4146 | case AUTO_PIN_LINE_OUT: |
| 4147 | default: |
| 4148 | label = texts[num_line++]; |
| 4149 | idx = 0; |
| 4150 | break; |
| 4151 | case AUTO_PIN_HP_OUT: |
| 4152 | label = "Headphone"; |
| 4153 | idx = num_hp++; |
| 4154 | break; |
| 4155 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4156 | if (speaker_2_1) { |
| 4157 | label = num_spk++ ? "Bass Speaker" : "Speaker"; |
| 4158 | idx = 0; |
| 4159 | } else { |
| 4160 | label = "Speaker"; |
| 4161 | idx = num_spk++; |
| 4162 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4163 | break; |
| 4164 | } |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 4165 | err = try_add_pb_volume(codec, dac, |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4166 | spec->dac_info[i].pin, |
| 4167 | label, idx); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4168 | if (err < 0) |
| 4169 | return err; |
| 4170 | } |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 4171 | |
| 4172 | if (spec->auto_mute) { |
| 4173 | err = snd_hda_add_new_ctls(codec, cx_automute_mode_enum); |
| 4174 | if (err < 0) |
| 4175 | return err; |
| 4176 | } |
| 4177 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4178 | return 0; |
| 4179 | } |
| 4180 | |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4181 | /* Returns zero if this is a normal stereo channel, and non-zero if it should |
| 4182 | be split in two independent channels. |
| 4183 | dest_label must be at least 44 characters. */ |
| 4184 | static int cx_auto_get_rightch_label(struct hda_codec *codec, const char *label, |
| 4185 | char *dest_label, int nid) |
| 4186 | { |
| 4187 | struct conexant_spec *spec = codec->spec; |
| 4188 | int i; |
| 4189 | |
| 4190 | if (!spec->fixup_stereo_dmic) |
| 4191 | return 0; |
| 4192 | |
| 4193 | for (i = 0; i < AUTO_CFG_MAX_INS; i++) { |
| 4194 | int def_conf; |
| 4195 | if (spec->autocfg.inputs[i].pin != nid) |
| 4196 | continue; |
| 4197 | |
| 4198 | if (spec->autocfg.inputs[i].type != AUTO_PIN_MIC) |
| 4199 | return 0; |
| 4200 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4201 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) |
| 4202 | return 0; |
| 4203 | |
| 4204 | /* Finally found the inverted internal mic! */ |
| 4205 | snprintf(dest_label, 44, "Inverted %s", label); |
| 4206 | return 1; |
| 4207 | } |
| 4208 | return 0; |
| 4209 | } |
| 4210 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4211 | static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, |
| 4212 | const char *label, const char *pfx, |
| 4213 | int cidx) |
| 4214 | { |
| 4215 | struct conexant_spec *spec = codec->spec; |
| 4216 | int i; |
| 4217 | |
| 4218 | for (i = 0; i < spec->num_adc_nids; i++) { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4219 | char rightch_label[44]; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4220 | hda_nid_t adc_nid = spec->adc_nids[i]; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 4221 | int idx = get_input_connection(codec, adc_nid, nid); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4222 | if (idx < 0) |
| 4223 | continue; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4224 | if (codec->single_adc_amp) |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4225 | idx = 0; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4226 | |
| 4227 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { |
| 4228 | /* Make two independent kcontrols for left and right */ |
| 4229 | int err = cx_auto_add_volume_idx(codec, label, pfx, |
| 4230 | cidx, adc_nid, HDA_INPUT, idx, 1); |
| 4231 | if (err < 0) |
| 4232 | return err; |
| 4233 | return cx_auto_add_volume_idx(codec, rightch_label, pfx, |
| 4234 | cidx, adc_nid, HDA_INPUT, idx, 2); |
| 4235 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4236 | return cx_auto_add_volume_idx(codec, label, pfx, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4237 | cidx, adc_nid, HDA_INPUT, idx, 3); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4238 | } |
| 4239 | return 0; |
| 4240 | } |
| 4241 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4242 | static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, |
| 4243 | const char *label, int cidx) |
| 4244 | { |
| 4245 | struct conexant_spec *spec = codec->spec; |
| 4246 | hda_nid_t mux, nid; |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4247 | int i, con; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4248 | |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4249 | nid = spec->imux_info[idx].pin; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4250 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4251 | char rightch_label[44]; |
| 4252 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { |
| 4253 | int err = cx_auto_add_volume_idx(codec, label, " Boost", |
| 4254 | cidx, nid, HDA_INPUT, 0, 1); |
| 4255 | if (err < 0) |
| 4256 | return err; |
| 4257 | return cx_auto_add_volume_idx(codec, rightch_label, " Boost", |
| 4258 | cidx, nid, HDA_INPUT, 0, 2); |
| 4259 | } |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4260 | return cx_auto_add_volume(codec, label, " Boost", cidx, |
| 4261 | nid, HDA_INPUT); |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4262 | } |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4263 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, |
| 4264 | &mux, false, 0); |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4265 | if (con < 0) |
| 4266 | return 0; |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4267 | for (i = 0; i < idx; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4268 | if (spec->imux_info[i].boost == mux) |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4269 | return 0; /* already present */ |
| 4270 | } |
| 4271 | |
| 4272 | if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4273 | spec->imux_info[idx].boost = mux; |
David Henningsson | 74d3e697 | 2012-10-02 10:14:23 +0200 | [diff] [blame] | 4274 | return cx_auto_add_volume(codec, label, " Boost", cidx, |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4275 | mux, HDA_OUTPUT); |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4276 | } |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4277 | return 0; |
| 4278 | } |
| 4279 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4280 | static int cx_auto_build_input_controls(struct hda_codec *codec) |
| 4281 | { |
| 4282 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4283 | struct hda_input_mux *imux = &spec->private_imux; |
| 4284 | const char *prev_label; |
| 4285 | int input_conn[HDA_MAX_NUM_INPUTS]; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4286 | int i, j, err, cidx; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4287 | int multi_connection; |
| 4288 | |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4289 | if (!imux->num_items) |
| 4290 | return 0; |
| 4291 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4292 | multi_connection = 0; |
| 4293 | for (i = 0; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4294 | cidx = get_input_connection(codec, spec->imux_info[i].adc, |
| 4295 | spec->imux_info[i].pin); |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4296 | if (cidx < 0) |
| 4297 | continue; |
| 4298 | input_conn[i] = spec->imux_info[i].adc; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4299 | if (!codec->single_adc_amp) |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4300 | input_conn[i] |= cidx << 8; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4301 | if (i > 0 && input_conn[i] != input_conn[0]) |
| 4302 | multi_connection = 1; |
| 4303 | } |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4304 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4305 | prev_label = NULL; |
| 4306 | cidx = 0; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4307 | for (i = 0; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4308 | hda_nid_t nid = spec->imux_info[i].pin; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4309 | const char *label; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4310 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4311 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4312 | spec->imux_info[i].index); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4313 | if (label == prev_label) |
| 4314 | cidx++; |
| 4315 | else |
| 4316 | cidx = 0; |
| 4317 | prev_label = label; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4318 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4319 | err = cx_auto_add_boost_volume(codec, i, label, cidx); |
| 4320 | if (err < 0) |
| 4321 | return err; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4322 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4323 | if (!multi_connection) { |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4324 | if (i > 0) |
| 4325 | continue; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4326 | err = cx_auto_add_capture_volume(codec, nid, |
| 4327 | "Capture", "", cidx); |
| 4328 | } else { |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4329 | bool dup_found = false; |
| 4330 | for (j = 0; j < i; j++) { |
| 4331 | if (input_conn[j] == input_conn[i]) { |
| 4332 | dup_found = true; |
| 4333 | break; |
| 4334 | } |
| 4335 | } |
| 4336 | if (dup_found) |
| 4337 | continue; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4338 | err = cx_auto_add_capture_volume(codec, nid, |
| 4339 | label, " Capture", cidx); |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4340 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4341 | if (err < 0) |
| 4342 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4343 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4344 | |
| 4345 | if (spec->private_imux.num_items > 1 && !spec->auto_mic) { |
| 4346 | err = snd_hda_add_new_ctls(codec, cx_auto_capture_mixers); |
| 4347 | if (err < 0) |
| 4348 | return err; |
| 4349 | } |
| 4350 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4351 | return 0; |
| 4352 | } |
| 4353 | |
| 4354 | static int cx_auto_build_controls(struct hda_codec *codec) |
| 4355 | { |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4356 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4357 | int err; |
| 4358 | |
| 4359 | err = cx_auto_build_output_controls(codec); |
| 4360 | if (err < 0) |
| 4361 | return err; |
| 4362 | err = cx_auto_build_input_controls(codec); |
| 4363 | if (err < 0) |
| 4364 | return err; |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4365 | err = conexant_build_controls(codec); |
| 4366 | if (err < 0) |
| 4367 | return err; |
| 4368 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 4369 | if (err < 0) |
| 4370 | return err; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4371 | if (spec->vmaster_mute.sw_kctl) { |
| 4372 | spec->vmaster_mute.hook = cx_auto_vmaster_hook; |
| 4373 | err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, |
| 4374 | spec->vmaster_mute_led); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 4375 | if (err < 0) |
| 4376 | return err; |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4377 | } |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4378 | return 0; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4379 | } |
| 4380 | |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 4381 | static int cx_auto_search_adcs(struct hda_codec *codec) |
| 4382 | { |
| 4383 | struct conexant_spec *spec = codec->spec; |
| 4384 | hda_nid_t nid, end_nid; |
| 4385 | |
| 4386 | end_nid = codec->start_nid + codec->num_nodes; |
| 4387 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 4388 | unsigned int caps = get_wcaps(codec, nid); |
| 4389 | if (get_wcaps_type(caps) != AC_WID_AUD_IN) |
| 4390 | continue; |
| 4391 | if (caps & AC_WCAP_DIGITAL) |
| 4392 | continue; |
| 4393 | if (snd_BUG_ON(spec->num_adc_nids >= |
| 4394 | ARRAY_SIZE(spec->private_adc_nids))) |
| 4395 | break; |
| 4396 | spec->private_adc_nids[spec->num_adc_nids++] = nid; |
| 4397 | } |
| 4398 | spec->adc_nids = spec->private_adc_nids; |
| 4399 | return 0; |
| 4400 | } |
| 4401 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4402 | static const struct hda_codec_ops cx_auto_patch_ops = { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4403 | .build_controls = cx_auto_build_controls, |
| 4404 | .build_pcms = conexant_build_pcms, |
| 4405 | .init = cx_auto_init, |
| 4406 | .free = conexant_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4407 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 4408 | #ifdef CONFIG_PM |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4409 | .suspend = conexant_suspend, |
| 4410 | #endif |
| 4411 | .reboot_notify = snd_hda_shutup_pins, |
| 4412 | }; |
| 4413 | |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4414 | /* |
| 4415 | * pin fix-up |
| 4416 | */ |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4417 | enum { |
| 4418 | CXT_PINCFG_LENOVO_X200, |
Takashi Iwai | d398011 | 2012-04-19 17:17:59 +0200 | [diff] [blame] | 4419 | CXT_PINCFG_LENOVO_TP410, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4420 | CXT_PINCFG_LEMOTE_A1004, |
| 4421 | CXT_PINCFG_LEMOTE_A1205, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4422 | CXT_FIXUP_STEREO_DMIC, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4423 | CXT_FIXUP_INC_MIC_BOOST, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4424 | }; |
| 4425 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4426 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec, |
| 4427 | const struct hda_fixup *fix, int action) |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4428 | { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4429 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4430 | spec->fixup_stereo_dmic = 1; |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4431 | } |
| 4432 | |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4433 | static void cxt5066_increase_mic_boost(struct hda_codec *codec, |
| 4434 | const struct hda_fixup *fix, int action) |
| 4435 | { |
| 4436 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 4437 | return; |
| 4438 | |
| 4439 | snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, |
| 4440 | (0x3 << AC_AMPCAP_OFFSET_SHIFT) | |
| 4441 | (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4442 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4443 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 4444 | } |
| 4445 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4446 | /* ThinkPad X200 & co with cxt5051 */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4447 | static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4448 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ |
| 4449 | { 0x17, 0x21a11000 }, /* dock-mic */ |
| 4450 | { 0x19, 0x2121103f }, /* dock-HP */ |
Takashi Iwai | 3e93f5e | 2012-02-28 21:49:55 +0100 | [diff] [blame] | 4451 | { 0x1c, 0x21440100 }, /* dock SPDIF out */ |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4452 | {} |
| 4453 | }; |
| 4454 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4455 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4456 | static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4457 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ |
| 4458 | { 0x1a, 0x21a190f0 }, /* dock-mic */ |
| 4459 | { 0x1c, 0x212140ff }, /* dock-HP */ |
| 4460 | {} |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4461 | }; |
| 4462 | |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4463 | /* Lemote A1004/A1205 with cxt5066 */ |
| 4464 | static const struct hda_pintbl cxt_pincfg_lemote[] = { |
| 4465 | { 0x1a, 0x90a10020 }, /* Internal mic */ |
| 4466 | { 0x1b, 0x03a11020 }, /* External mic */ |
| 4467 | { 0x1d, 0x400101f0 }, /* Not used */ |
| 4468 | { 0x1e, 0x40a701f0 }, /* Not used */ |
| 4469 | { 0x20, 0x404501f0 }, /* Not used */ |
| 4470 | { 0x22, 0x404401f0 }, /* Not used */ |
| 4471 | { 0x23, 0x40a701f0 }, /* Not used */ |
| 4472 | {} |
| 4473 | }; |
| 4474 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4475 | static const struct hda_fixup cxt_fixups[] = { |
| 4476 | [CXT_PINCFG_LENOVO_X200] = { |
| 4477 | .type = HDA_FIXUP_PINS, |
| 4478 | .v.pins = cxt_pincfg_lenovo_x200, |
| 4479 | }, |
| 4480 | [CXT_PINCFG_LENOVO_TP410] = { |
| 4481 | .type = HDA_FIXUP_PINS, |
| 4482 | .v.pins = cxt_pincfg_lenovo_tp410, |
| 4483 | }, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4484 | [CXT_PINCFG_LEMOTE_A1004] = { |
| 4485 | .type = HDA_FIXUP_PINS, |
| 4486 | .chained = true, |
| 4487 | .chain_id = CXT_FIXUP_INC_MIC_BOOST, |
| 4488 | .v.pins = cxt_pincfg_lemote, |
| 4489 | }, |
| 4490 | [CXT_PINCFG_LEMOTE_A1205] = { |
| 4491 | .type = HDA_FIXUP_PINS, |
| 4492 | .v.pins = cxt_pincfg_lemote, |
| 4493 | }, |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4494 | [CXT_FIXUP_STEREO_DMIC] = { |
| 4495 | .type = HDA_FIXUP_FUNC, |
| 4496 | .v.func = cxt_fixup_stereo_dmic, |
| 4497 | }, |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4498 | [CXT_FIXUP_INC_MIC_BOOST] = { |
| 4499 | .type = HDA_FIXUP_FUNC, |
| 4500 | .v.func = cxt5066_increase_mic_boost, |
| 4501 | }, |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4502 | }; |
| 4503 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4504 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4505 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), |
| 4506 | {} |
| 4507 | }; |
| 4508 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4509 | static const struct snd_pci_quirk cxt5066_fixups[] = { |
Takashi Iwai | 63a077e | 2012-12-12 12:10:01 +0100 | [diff] [blame^] | 4510 | SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4511 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), |
| 4512 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), |
| 4513 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), |
| 4514 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), |
| 4515 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4516 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), |
Felix Kaechele | e4db095 | 2012-09-26 01:20:44 +0200 | [diff] [blame] | 4517 | SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), |
David Henningsson | b3c5dce | 2012-06-21 16:03:01 +0200 | [diff] [blame] | 4518 | SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), |
Huacai Chen | 239fb86 | 2012-10-05 21:25:09 +0800 | [diff] [blame] | 4519 | SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), |
| 4520 | SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4521 | {} |
| 4522 | }; |
| 4523 | |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4524 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches |
| 4525 | * can be created (bko#42825) |
| 4526 | */ |
| 4527 | static void add_cx5051_fake_mutes(struct hda_codec *codec) |
| 4528 | { |
| 4529 | static hda_nid_t out_nids[] = { |
| 4530 | 0x10, 0x11, 0 |
| 4531 | }; |
| 4532 | hda_nid_t *p; |
| 4533 | |
| 4534 | for (p = out_nids; *p; p++) |
| 4535 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, |
| 4536 | AC_AMPCAP_MIN_MUTE | |
| 4537 | query_amp_caps(codec, *p, HDA_OUTPUT)); |
| 4538 | } |
| 4539 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4540 | static int patch_conexant_auto(struct hda_codec *codec) |
| 4541 | { |
| 4542 | struct conexant_spec *spec; |
| 4543 | int err; |
| 4544 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4545 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4546 | codec->chip_name); |
| 4547 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4548 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4549 | if (!spec) |
| 4550 | return -ENOMEM; |
| 4551 | codec->spec = spec; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4552 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4553 | |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4554 | switch (codec->vendor_id) { |
| 4555 | case 0x14f15045: |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4556 | codec->single_adc_amp = 1; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4557 | break; |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4558 | case 0x14f15051: |
| 4559 | add_cx5051_fake_mutes(codec); |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 4560 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4561 | snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4562 | break; |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 4563 | default: |
| 4564 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4565 | snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); |
| 4566 | break; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4567 | } |
| 4568 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4569 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 4570 | |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4571 | /* Show mute-led control only on HP laptops |
| 4572 | * This is a sort of white-list: on HP laptops, EAPD corresponds |
| 4573 | * only to the mute-LED without actualy amp function. Meanwhile, |
| 4574 | * others may use EAPD really as an amp switch, so it might be |
| 4575 | * not good to expose it blindly. |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4576 | */ |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4577 | switch (codec->subsystem_id >> 16) { |
| 4578 | case 0x103c: |
| 4579 | spec->vmaster_mute_led = 1; |
| 4580 | break; |
| 4581 | } |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4582 | |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 4583 | err = cx_auto_search_adcs(codec); |
| 4584 | if (err < 0) |
| 4585 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4586 | err = cx_auto_parse_auto_config(codec); |
| 4587 | if (err < 0) { |
| 4588 | kfree(codec->spec); |
| 4589 | codec->spec = NULL; |
| 4590 | return err; |
| 4591 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4592 | spec->capture_stream = &cx_auto_pcm_analog_capture; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4593 | codec->patch_ops = cx_auto_patch_ops; |
| 4594 | if (spec->beep_amp) |
| 4595 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
Takashi Iwai | 4f2864a | 2012-01-25 11:54:19 +0100 | [diff] [blame] | 4596 | |
| 4597 | /* Some laptops with Conexant chips show stalls in S3 resume, |
| 4598 | * which falls into the single-cmd mode. |
| 4599 | * Better to make reset, then. |
| 4600 | */ |
| 4601 | if (!codec->bus->sync_write) { |
| 4602 | snd_printd("hda_codec: " |
| 4603 | "Enable sync_write for stable communication\n"); |
| 4604 | codec->bus->sync_write = 1; |
| 4605 | codec->bus->allow_bus_reset = 1; |
| 4606 | } |
| 4607 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4608 | return 0; |
| 4609 | } |
| 4610 | |
| 4611 | /* |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 4612 | */ |
| 4613 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4614 | static const struct hda_codec_preset snd_hda_preset_conexant[] = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 4615 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
| 4616 | .patch = patch_cxt5045 }, |
| 4617 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", |
| 4618 | .patch = patch_cxt5047 }, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 4619 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
| 4620 | .patch = patch_cxt5051 }, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 4621 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
| 4622 | .patch = patch_cxt5066 }, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 4623 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
| 4624 | .patch = patch_cxt5066 }, |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 4625 | { .id = 0x14f15068, .name = "CX20584", |
| 4626 | .patch = patch_cxt5066 }, |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 4627 | { .id = 0x14f15069, .name = "CX20585", |
| 4628 | .patch = patch_cxt5066 }, |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 4629 | { .id = 0x14f1506c, .name = "CX20588", |
| 4630 | .patch = patch_cxt5066 }, |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 4631 | { .id = 0x14f1506e, .name = "CX20590", |
| 4632 | .patch = patch_cxt5066 }, |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4633 | { .id = 0x14f15097, .name = "CX20631", |
| 4634 | .patch = patch_conexant_auto }, |
| 4635 | { .id = 0x14f15098, .name = "CX20632", |
| 4636 | .patch = patch_conexant_auto }, |
| 4637 | { .id = 0x14f150a1, .name = "CX20641", |
| 4638 | .patch = patch_conexant_auto }, |
| 4639 | { .id = 0x14f150a2, .name = "CX20642", |
| 4640 | .patch = patch_conexant_auto }, |
| 4641 | { .id = 0x14f150ab, .name = "CX20651", |
| 4642 | .patch = patch_conexant_auto }, |
| 4643 | { .id = 0x14f150ac, .name = "CX20652", |
| 4644 | .patch = patch_conexant_auto }, |
| 4645 | { .id = 0x14f150b8, .name = "CX20664", |
| 4646 | .patch = patch_conexant_auto }, |
| 4647 | { .id = 0x14f150b9, .name = "CX20665", |
| 4648 | .patch = patch_conexant_auto }, |
Takashi Iwai | 2d825fd | 2012-05-11 08:39:24 +0200 | [diff] [blame] | 4649 | { .id = 0x14f1510f, .name = "CX20751/2", |
| 4650 | .patch = patch_conexant_auto }, |
| 4651 | { .id = 0x14f15110, .name = "CX20751/2", |
| 4652 | .patch = patch_conexant_auto }, |
| 4653 | { .id = 0x14f15111, .name = "CX20753/4", |
| 4654 | .patch = patch_conexant_auto }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 4655 | {} /* terminator */ |
| 4656 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4657 | |
| 4658 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); |
| 4659 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
| 4660 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 4661 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 4662 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 4663 | MODULE_ALIAS("snd-hda-codec-id:14f15068"); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 4664 | MODULE_ALIAS("snd-hda-codec-id:14f15069"); |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 4665 | MODULE_ALIAS("snd-hda-codec-id:14f1506c"); |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 4666 | MODULE_ALIAS("snd-hda-codec-id:14f1506e"); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4667 | MODULE_ALIAS("snd-hda-codec-id:14f15097"); |
| 4668 | MODULE_ALIAS("snd-hda-codec-id:14f15098"); |
| 4669 | MODULE_ALIAS("snd-hda-codec-id:14f150a1"); |
| 4670 | MODULE_ALIAS("snd-hda-codec-id:14f150a2"); |
| 4671 | MODULE_ALIAS("snd-hda-codec-id:14f150ab"); |
| 4672 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); |
| 4673 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); |
| 4674 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); |
Takashi Iwai | 2d825fd | 2012-05-11 08:39:24 +0200 | [diff] [blame] | 4675 | MODULE_ALIAS("snd-hda-codec-id:14f1510f"); |
| 4676 | MODULE_ALIAS("snd-hda-codec-id:14f15110"); |
| 4677 | MODULE_ALIAS("snd-hda-codec-id:14f15111"); |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4678 | |
| 4679 | MODULE_LICENSE("GPL"); |
| 4680 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
| 4681 | |
| 4682 | static struct hda_codec_preset_list conexant_list = { |
| 4683 | .preset = snd_hda_preset_conexant, |
| 4684 | .owner = THIS_MODULE, |
| 4685 | }; |
| 4686 | |
| 4687 | static int __init patch_conexant_init(void) |
| 4688 | { |
| 4689 | return snd_hda_add_codec_preset(&conexant_list); |
| 4690 | } |
| 4691 | |
| 4692 | static void __exit patch_conexant_exit(void) |
| 4693 | { |
| 4694 | snd_hda_delete_codec_preset(&conexant_list); |
| 4695 | } |
| 4696 | |
| 4697 | module_init(patch_conexant_init) |
| 4698 | module_exit(patch_conexant_exit) |