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