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