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