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