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