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