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