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