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