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