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