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; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1605 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
Takashi Iwai | 23d2df5 | 2010-01-24 11:19:27 +0100 | [diff] [blame] | 1606 | /* speaker pin */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1607 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1608 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
Justin P. Mattock | a80581d | 2012-02-11 05:55:58 -0800 | [diff] [blame] | 1609 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1610 | if (spec->ideapad) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1611 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1612 | } |
| 1613 | |
| 1614 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 1615 | static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1616 | struct snd_ctl_elem_value *ucontrol) |
| 1617 | { |
| 1618 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1619 | |
| 1620 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 1621 | return 0; |
| 1622 | cxt5051_update_speaker(codec); |
| 1623 | return 1; |
| 1624 | } |
| 1625 | |
| 1626 | /* toggle input of built-in and mic jack appropriately */ |
| 1627 | static void cxt5051_portb_automic(struct hda_codec *codec) |
| 1628 | { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1629 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1630 | unsigned int present; |
| 1631 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1632 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1633 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1634 | present = snd_hda_jack_detect(codec, 0x17); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1635 | snd_hda_codec_write(codec, 0x14, 0, |
| 1636 | AC_VERB_SET_CONNECT_SEL, |
| 1637 | present ? 0x01 : 0x00); |
| 1638 | } |
| 1639 | |
| 1640 | /* switch the current ADC according to the jack state */ |
| 1641 | static void cxt5051_portc_automic(struct hda_codec *codec) |
| 1642 | { |
| 1643 | struct conexant_spec *spec = codec->spec; |
| 1644 | unsigned int present; |
| 1645 | hda_nid_t new_adc; |
| 1646 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1647 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1648 | return; |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1649 | present = snd_hda_jack_detect(codec, 0x18); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1650 | if (present) |
| 1651 | spec->cur_adc_idx = 1; |
| 1652 | else |
| 1653 | spec->cur_adc_idx = 0; |
| 1654 | new_adc = spec->adc_nids[spec->cur_adc_idx]; |
| 1655 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 1656 | /* stream is running, let's swap the current ADC */ |
Takashi Iwai | f0cea79 | 2010-08-13 11:56:53 +0200 | [diff] [blame] | 1657 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1658 | spec->cur_adc = new_adc; |
| 1659 | snd_hda_codec_setup_stream(codec, new_adc, |
| 1660 | spec->cur_adc_stream_tag, 0, |
| 1661 | spec->cur_adc_format); |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | /* mute internal speaker if HP is plugged */ |
| 1666 | static void cxt5051_hp_automute(struct hda_codec *codec) |
| 1667 | { |
| 1668 | struct conexant_spec *spec = codec->spec; |
| 1669 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1670 | spec->hp_present = snd_hda_jack_detect(codec, 0x16); |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1671 | cxt5051_update_speaker(codec); |
| 1672 | } |
| 1673 | |
| 1674 | /* unsolicited event for HP jack sensing */ |
| 1675 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, |
| 1676 | unsigned int res) |
| 1677 | { |
| 1678 | switch (res >> 26) { |
| 1679 | case CONEXANT_HP_EVENT: |
| 1680 | cxt5051_hp_automute(codec); |
| 1681 | break; |
| 1682 | case CXT5051_PORTB_EVENT: |
| 1683 | cxt5051_portb_automic(codec); |
| 1684 | break; |
| 1685 | case CXT5051_PORTC_EVENT: |
| 1686 | cxt5051_portc_automic(codec); |
| 1687 | break; |
| 1688 | } |
| 1689 | } |
| 1690 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1691 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1692 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 1693 | { |
| 1694 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1695 | .name = "Master Playback Switch", |
| 1696 | .info = cxt_eapd_info, |
| 1697 | .get = cxt_eapd_get, |
| 1698 | .put = cxt5051_hp_master_sw_put, |
| 1699 | .private_value = 0x1a, |
| 1700 | }, |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1701 | {} |
| 1702 | }; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1703 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1704 | static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1705 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1706 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1707 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1708 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1709 | HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1710 | HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1711 | {} |
| 1712 | }; |
| 1713 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1714 | static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1715 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1716 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1717 | HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), |
| 1718 | HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1719 | {} |
| 1720 | }; |
| 1721 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1722 | static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
Takashi Iwai | 4e4ac60 | 2010-01-23 22:29:54 +0100 | [diff] [blame] | 1723 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
| 1724 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1725 | {} |
| 1726 | }; |
| 1727 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1728 | static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1729 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), |
| 1730 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1731 | {} |
| 1732 | }; |
| 1733 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1734 | static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1735 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), |
| 1736 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
David Henningsson | 8607f7c | 2010-12-20 14:43:54 +0100 | [diff] [blame] | 1737 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), |
| 1738 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1739 | {} |
| 1740 | }; |
| 1741 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1742 | static const struct hda_verb cxt5051_init_verbs[] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1743 | /* Line in, Mic */ |
| 1744 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1745 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1746 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1747 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1748 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 1749 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1750 | /* SPK */ |
| 1751 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1752 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1753 | /* HP, Amp */ |
| 1754 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1755 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1756 | /* DAC1 */ |
| 1757 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1758 | /* Record selector: Internal mic */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1759 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1760 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1761 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, |
| 1762 | /* SPDIF route: PCM */ |
Pierre-Louis Bossart | 1965c44 | 2010-05-06 16:37:03 -0500 | [diff] [blame] | 1763 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1764 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1765 | /* EAPD */ |
| 1766 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1767 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1768 | { } /* end */ |
| 1769 | }; |
| 1770 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1771 | static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1772 | /* Line in, Mic */ |
| 1773 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
| 1774 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1775 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1776 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1777 | /* SPK */ |
| 1778 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1779 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1780 | /* HP, Amp */ |
| 1781 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1782 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1783 | /* DAC1 */ |
| 1784 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1785 | /* Record selector: Internal mic */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1786 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1787 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1788 | /* SPDIF route: PCM */ |
| 1789 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1790 | /* EAPD */ |
| 1791 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1792 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1793 | { } /* end */ |
| 1794 | }; |
| 1795 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1796 | static const struct hda_verb cxt5051_f700_init_verbs[] = { |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1797 | /* Line in, Mic */ |
Takashi Iwai | 30ed7ed | 2010-01-28 17:11:45 +0100 | [diff] [blame] | 1798 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1799 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 1800 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1801 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, |
| 1802 | /* SPK */ |
| 1803 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1804 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1805 | /* HP, Amp */ |
| 1806 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 1807 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1808 | /* DAC1 */ |
| 1809 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 1810 | /* Record selector: Internal mic */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1811 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, |
| 1812 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1813 | /* SPDIF route: PCM */ |
| 1814 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 1815 | /* EAPD */ |
| 1816 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 1817 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1818 | { } /* end */ |
| 1819 | }; |
| 1820 | |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1821 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, |
| 1822 | unsigned int event) |
| 1823 | { |
| 1824 | snd_hda_codec_write(codec, nid, 0, |
| 1825 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1826 | AC_USRSP_EN | event); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1827 | } |
| 1828 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1829 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1830 | /* Subwoofer */ |
| 1831 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 1832 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 1833 | { } /* end */ |
| 1834 | }; |
| 1835 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1836 | /* initialize jack-sensing, too */ |
| 1837 | static int cxt5051_init(struct hda_codec *codec) |
| 1838 | { |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1839 | struct conexant_spec *spec = codec->spec; |
| 1840 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1841 | conexant_init(codec); |
Takashi Iwai | 6953e55 | 2010-01-24 11:00:27 +0100 | [diff] [blame] | 1842 | |
| 1843 | if (spec->auto_mic & AUTO_MIC_PORTB) |
| 1844 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); |
| 1845 | if (spec->auto_mic & AUTO_MIC_PORTC) |
| 1846 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); |
| 1847 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1848 | if (codec->patch_ops.unsol_event) { |
| 1849 | cxt5051_hp_automute(codec); |
| 1850 | cxt5051_portb_automic(codec); |
| 1851 | cxt5051_portc_automic(codec); |
| 1852 | } |
| 1853 | return 0; |
| 1854 | } |
| 1855 | |
| 1856 | |
| 1857 | enum { |
| 1858 | CXT5051_LAPTOP, /* Laptops w/ EAPD support */ |
| 1859 | CXT5051_HP, /* no docking */ |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1860 | CXT5051_HP_DV6736, /* HP without mic switch */ |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1861 | CXT5051_F700, /* HP Compaq Presario F700 */ |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1862 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1863 | CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1864 | CXT5051_AUTO, /* auto-parser */ |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1865 | CXT5051_MODELS |
| 1866 | }; |
| 1867 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1868 | static const char *const cxt5051_models[CXT5051_MODELS] = { |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1869 | [CXT5051_LAPTOP] = "laptop", |
| 1870 | [CXT5051_HP] = "hp", |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1871 | [CXT5051_HP_DV6736] = "hp-dv6736", |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1872 | [CXT5051_F700] = "hp-700", |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1873 | [CXT5051_TOSHIBA] = "toshiba", |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1874 | [CXT5051_IDEAPAD] = "ideapad", |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1875 | [CXT5051_AUTO] = "auto", |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1876 | }; |
| 1877 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1878 | static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1879 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
Tony Vroon | 1812e67 | 2009-05-27 21:00:41 +0100 | [diff] [blame] | 1880 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
Takashi Iwai | 5f6c3de | 2010-01-23 22:19:29 +0100 | [diff] [blame] | 1881 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1882 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1883 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 1884 | CXT5051_LAPTOP), |
| 1885 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1886 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1887 | {} |
| 1888 | }; |
| 1889 | |
| 1890 | static int patch_cxt5051(struct hda_codec *codec) |
| 1891 | { |
| 1892 | struct conexant_spec *spec; |
| 1893 | int board_config; |
| 1894 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1895 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
| 1896 | cxt5051_models, |
| 1897 | cxt5051_cfg_tbl); |
| 1898 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 1899 | board_config = CXT5051_AUTO; /* model=auto as default */ |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 1900 | if (board_config == CXT5051_AUTO) |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1901 | return patch_conexant_auto(codec); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 1902 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1903 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1904 | if (!spec) |
| 1905 | return -ENOMEM; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1906 | codec->spec = spec; |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 1907 | codec->pin_amp_workaround = 1; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1908 | |
| 1909 | codec->patch_ops = conexant_patch_ops; |
| 1910 | codec->patch_ops.init = cxt5051_init; |
| 1911 | |
| 1912 | spec->multiout.max_channels = 2; |
| 1913 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); |
| 1914 | spec->multiout.dac_nids = cxt5051_dac_nids; |
| 1915 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; |
| 1916 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ |
| 1917 | spec->adc_nids = cxt5051_adc_nids; |
Takashi Iwai | 2c7a3fb | 2010-01-24 10:47:02 +0100 | [diff] [blame] | 1918 | spec->num_mixers = 2; |
| 1919 | spec->mixers[0] = cxt5051_capture_mixers; |
| 1920 | spec->mixers[1] = cxt5051_playback_mixers; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1921 | spec->num_init_verbs = 1; |
| 1922 | spec->init_verbs[0] = cxt5051_init_verbs; |
| 1923 | spec->spdif_route = 0; |
| 1924 | spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); |
| 1925 | spec->channel_mode = cxt5051_modes; |
| 1926 | spec->cur_adc = 0; |
| 1927 | spec->cur_adc_idx = 0; |
| 1928 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1929 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 1930 | |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1931 | codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; |
| 1932 | |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1933 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1934 | switch (board_config) { |
| 1935 | case CXT5051_HP: |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1936 | spec->mixers[0] = cxt5051_hp_mixers; |
| 1937 | break; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1938 | case CXT5051_HP_DV6736: |
| 1939 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; |
| 1940 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1941 | spec->auto_mic = 0; |
Takashi Iwai | 79d7d53 | 2009-03-04 09:03:50 +0100 | [diff] [blame] | 1942 | break; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1943 | case CXT5051_F700: |
| 1944 | spec->init_verbs[0] = cxt5051_f700_init_verbs; |
| 1945 | spec->mixers[0] = cxt5051_f700_mixers; |
Takashi Iwai | faddaa5 | 2010-01-23 22:31:36 +0100 | [diff] [blame] | 1946 | spec->auto_mic = 0; |
| 1947 | break; |
| 1948 | case CXT5051_TOSHIBA: |
| 1949 | spec->mixers[0] = cxt5051_toshiba_mixers; |
| 1950 | spec->auto_mic = AUTO_MIC_PORTB; |
Ken Prox | cd9d95a | 2010-01-08 09:01:47 +0100 | [diff] [blame] | 1951 | break; |
Herton Ronaldo Krzesinski | f7154de2 | 2010-06-17 14:15:06 -0300 | [diff] [blame] | 1952 | case CXT5051_IDEAPAD: |
| 1953 | spec->init_verbs[spec->num_init_verbs++] = |
| 1954 | cxt5051_ideapad_init_verbs; |
| 1955 | spec->ideapad = 1; |
| 1956 | break; |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1957 | } |
| 1958 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 1959 | if (spec->beep_amp) |
| 1960 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
| 1961 | |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 1962 | return 0; |
| 1963 | } |
| 1964 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1965 | /* Conexant 5066 specific */ |
| 1966 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1967 | static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; |
| 1968 | static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; |
| 1969 | static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; |
| 1970 | static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1971 | |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 1972 | /* OLPC's microphone port is DC coupled for use with external sensors, |
| 1973 | * therefore we use a 50% mic bias in order to center the input signal with |
| 1974 | * the DC input range of the codec. */ |
| 1975 | #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 |
| 1976 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 1977 | static const struct hda_channel_mode cxt5066_modes[1] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1978 | { 2, NULL }, |
| 1979 | }; |
| 1980 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1981 | #define HP_PRESENT_PORT_A (1 << 0) |
| 1982 | #define HP_PRESENT_PORT_D (1 << 1) |
| 1983 | #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) |
| 1984 | #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) |
| 1985 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1986 | static void cxt5066_update_speaker(struct hda_codec *codec) |
| 1987 | { |
| 1988 | struct conexant_spec *spec = codec->spec; |
| 1989 | unsigned int pinctl; |
| 1990 | |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 1991 | snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", |
| 1992 | spec->hp_present, spec->cur_eapd); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1993 | |
| 1994 | /* Port A (HP) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1995 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1996 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 1997 | |
| 1998 | /* Port D (HP/LO) */ |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 1999 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
| 2000 | if (spec->dell_automute || spec->thinkpad) { |
| 2001 | /* Mute if Port A is connected */ |
| 2002 | if (hp_port_a_present(spec)) |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 2003 | pinctl = 0; |
| 2004 | } else { |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2005 | /* Thinkpad/Dell doesn't give pin-D status */ |
| 2006 | if (!hp_port_d_present(spec)) |
| 2007 | pinctl = 0; |
John Baboval | 3a25344 | 2010-12-02 11:21:31 -0500 | [diff] [blame] | 2008 | } |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2009 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2010 | |
| 2011 | /* CLASS_D AMP */ |
| 2012 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2013 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
| 2017 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
| 2018 | struct snd_ctl_elem_value *ucontrol) |
| 2019 | { |
| 2020 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2021 | |
| 2022 | if (!cxt_eapd_put(kcontrol, ucontrol)) |
| 2023 | return 0; |
| 2024 | |
| 2025 | cxt5066_update_speaker(codec); |
| 2026 | return 1; |
| 2027 | } |
| 2028 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2029 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { |
| 2030 | .num_items = 3, |
| 2031 | .items = { |
| 2032 | { "Off", PIN_IN }, |
| 2033 | { "50%", PIN_VREF50 }, |
| 2034 | { "80%", PIN_VREF80 }, |
| 2035 | }, |
| 2036 | }; |
| 2037 | |
| 2038 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) |
| 2039 | { |
| 2040 | struct conexant_spec *spec = codec->spec; |
| 2041 | /* Even though port F is the DC input, the bias is controlled on port B. |
| 2042 | * we also leave that port as an active input (but unselected) in DC mode |
| 2043 | * just in case that is necessary to make the bias setting take effect. */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2044 | return snd_hda_set_pin_ctl_cache(codec, 0x1a, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2045 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); |
| 2046 | } |
| 2047 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2048 | /* OLPC defers mic widget control until when capture is started because the |
| 2049 | * microphone LED comes on as soon as these settings are put in place. if we |
| 2050 | * did this before recording, it would give the false indication that recording |
| 2051 | * is happening when it is not. */ |
| 2052 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2053 | { |
Daniel Drake | dbaccc0 | 2009-11-09 15:17:24 +0000 | [diff] [blame] | 2054 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2055 | if (!spec->recording) |
| 2056 | return; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2057 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2058 | if (spec->dc_enable) { |
| 2059 | /* in DC mode we ignore presence detection and just use the jack |
| 2060 | * through our special DC port */ |
| 2061 | const struct hda_verb enable_dc_mode[] = { |
| 2062 | /* disble internal mic, port C */ |
| 2063 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2064 | |
| 2065 | /* enable DC capture, port F */ |
| 2066 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2067 | {}, |
| 2068 | }; |
| 2069 | |
| 2070 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2071 | /* port B input disabled (and bias set) through the following call */ |
| 2072 | cxt5066_set_olpc_dc_bias(codec); |
| 2073 | return; |
| 2074 | } |
| 2075 | |
| 2076 | /* disable DC (port F) */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2077 | snd_hda_set_pin_ctl(codec, 0x1e, 0); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2078 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2079 | /* external mic, port B */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2080 | snd_hda_set_pin_ctl(codec, 0x1a, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2081 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2082 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2083 | /* internal mic, port C */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2084 | snd_hda_set_pin_ctl(codec, 0x1b, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2085 | spec->ext_mic_present ? 0 : PIN_VREF80); |
| 2086 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2087 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2088 | /* toggle input of built-in and mic jack appropriately */ |
| 2089 | static void cxt5066_olpc_automic(struct hda_codec *codec) |
| 2090 | { |
| 2091 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2092 | unsigned int present; |
| 2093 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2094 | if (spec->dc_enable) /* don't do presence detection in DC mode */ |
| 2095 | return; |
| 2096 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2097 | present = snd_hda_codec_read(codec, 0x1a, 0, |
| 2098 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
| 2099 | if (present) |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2100 | snd_printdd("CXT5066: external microphone detected\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2101 | else |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2102 | snd_printdd("CXT5066: external microphone absent\n"); |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2103 | |
| 2104 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2105 | present ? 0 : 1); |
| 2106 | spec->ext_mic_present = !!present; |
| 2107 | |
| 2108 | cxt5066_olpc_select_mic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2109 | } |
| 2110 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2111 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2112 | static void cxt5066_vostro_automic(struct hda_codec *codec) |
| 2113 | { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2114 | unsigned int present; |
| 2115 | |
| 2116 | struct hda_verb ext_mic_present[] = { |
| 2117 | /* enable external mic, port B */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2118 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2119 | |
| 2120 | /* switch to external mic input */ |
| 2121 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2122 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2123 | |
| 2124 | /* disable internal digital mic */ |
| 2125 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2126 | {} |
| 2127 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2128 | static const struct hda_verb ext_mic_absent[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2129 | /* enable internal mic, port C */ |
| 2130 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2131 | |
| 2132 | /* switch to internal mic input */ |
| 2133 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2134 | |
| 2135 | /* disable external mic, port B */ |
| 2136 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2137 | {} |
| 2138 | }; |
| 2139 | |
| 2140 | present = snd_hda_jack_detect(codec, 0x1a); |
| 2141 | if (present) { |
| 2142 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2143 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2144 | } else { |
| 2145 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2146 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2147 | } |
| 2148 | } |
| 2149 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2150 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2151 | static void cxt5066_ideapad_automic(struct hda_codec *codec) |
| 2152 | { |
| 2153 | unsigned int present; |
| 2154 | |
| 2155 | struct hda_verb ext_mic_present[] = { |
| 2156 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2157 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2158 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2159 | {} |
| 2160 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2161 | static const struct hda_verb ext_mic_absent[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2162 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2163 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2164 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2165 | {} |
| 2166 | }; |
| 2167 | |
| 2168 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2169 | if (present) { |
| 2170 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2171 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2172 | } else { |
| 2173 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2174 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2175 | } |
| 2176 | } |
| 2177 | |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2178 | |
| 2179 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2180 | static void cxt5066_asus_automic(struct hda_codec *codec) |
| 2181 | { |
| 2182 | unsigned int present; |
| 2183 | |
| 2184 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2185 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2186 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2187 | present ? 1 : 0); |
| 2188 | } |
| 2189 | |
| 2190 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2191 | /* toggle input of built-in digital mic and mic jack appropriately */ |
| 2192 | static void cxt5066_hp_laptop_automic(struct hda_codec *codec) |
| 2193 | { |
| 2194 | unsigned int present; |
| 2195 | |
| 2196 | present = snd_hda_jack_detect(codec, 0x1b); |
| 2197 | snd_printdd("CXT5066: external microphone present=%d\n", present); |
| 2198 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, |
| 2199 | present ? 1 : 3); |
| 2200 | } |
| 2201 | |
| 2202 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2203 | /* toggle input of built-in digital mic and mic jack appropriately |
| 2204 | order is: external mic -> dock mic -> interal mic */ |
| 2205 | static void cxt5066_thinkpad_automic(struct hda_codec *codec) |
| 2206 | { |
| 2207 | unsigned int ext_present, dock_present; |
| 2208 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2209 | static const struct hda_verb ext_mic_present[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2210 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
| 2211 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, |
| 2212 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2213 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2214 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2215 | {} |
| 2216 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2217 | static const struct hda_verb dock_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, 0}, |
| 2220 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
| 2221 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2222 | {0x1b, 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 ext_mic_absent[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2226 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
| 2227 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2228 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2229 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2230 | {} |
| 2231 | }; |
| 2232 | |
| 2233 | ext_present = snd_hda_jack_detect(codec, 0x1b); |
| 2234 | dock_present = snd_hda_jack_detect(codec, 0x1a); |
| 2235 | if (ext_present) { |
| 2236 | snd_printdd("CXT5066: external microphone detected\n"); |
| 2237 | snd_hda_sequence_write(codec, ext_mic_present); |
| 2238 | } else if (dock_present) { |
| 2239 | snd_printdd("CXT5066: dock microphone detected\n"); |
| 2240 | snd_hda_sequence_write(codec, dock_mic_present); |
| 2241 | } else { |
| 2242 | snd_printdd("CXT5066: external microphone absent\n"); |
| 2243 | snd_hda_sequence_write(codec, ext_mic_absent); |
| 2244 | } |
| 2245 | } |
| 2246 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2247 | /* mute internal speaker if HP is plugged */ |
| 2248 | static void cxt5066_hp_automute(struct hda_codec *codec) |
| 2249 | { |
| 2250 | struct conexant_spec *spec = codec->spec; |
| 2251 | unsigned int portA, portD; |
| 2252 | |
| 2253 | /* Port A */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2254 | portA = snd_hda_jack_detect(codec, 0x19); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2255 | |
| 2256 | /* Port D */ |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2257 | portD = snd_hda_jack_detect(codec, 0x1c); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2258 | |
Takashi Iwai | a3de8ab | 2010-12-03 12:29:14 +0100 | [diff] [blame] | 2259 | spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; |
| 2260 | spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2261 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", |
| 2262 | portA, portD, spec->hp_present); |
| 2263 | cxt5066_update_speaker(codec); |
| 2264 | } |
| 2265 | |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2266 | /* Dispatch the right mic autoswitch function */ |
| 2267 | static void cxt5066_automic(struct hda_codec *codec) |
| 2268 | { |
| 2269 | struct conexant_spec *spec = codec->spec; |
| 2270 | |
| 2271 | if (spec->dell_vostro) |
| 2272 | cxt5066_vostro_automic(codec); |
| 2273 | else if (spec->ideapad) |
| 2274 | cxt5066_ideapad_automic(codec); |
| 2275 | else if (spec->thinkpad) |
| 2276 | cxt5066_thinkpad_automic(codec); |
| 2277 | else if (spec->hp_laptop) |
| 2278 | cxt5066_hp_laptop_automic(codec); |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2279 | else if (spec->asus) |
| 2280 | cxt5066_asus_automic(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2281 | } |
| 2282 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2283 | /* unsolicited event for jack sensing */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2284 | 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] | 2285 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2286 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2287 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
| 2288 | switch (res >> 26) { |
| 2289 | case CONEXANT_HP_EVENT: |
| 2290 | cxt5066_hp_automute(codec); |
| 2291 | break; |
| 2292 | case CONEXANT_MIC_EVENT: |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2293 | /* ignore mic events in DC mode; we're always using the jack */ |
| 2294 | if (!spec->dc_enable) |
| 2295 | cxt5066_olpc_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2296 | break; |
| 2297 | } |
| 2298 | } |
| 2299 | |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2300 | /* unsolicited event for jack sensing */ |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2301 | 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] | 2302 | { |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2303 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2304 | switch (res >> 26) { |
| 2305 | case CONEXANT_HP_EVENT: |
| 2306 | cxt5066_hp_automute(codec); |
| 2307 | break; |
| 2308 | case CONEXANT_MIC_EVENT: |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2309 | cxt5066_automic(codec); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2310 | break; |
| 2311 | } |
| 2312 | } |
| 2313 | |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2314 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2315 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
| 2316 | .num_items = 5, |
| 2317 | .items = { |
| 2318 | { "0dB", 0 }, |
| 2319 | { "10dB", 1 }, |
| 2320 | { "20dB", 2 }, |
| 2321 | { "30dB", 3 }, |
| 2322 | { "40dB", 4 }, |
| 2323 | }, |
| 2324 | }; |
| 2325 | |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2326 | static void cxt5066_set_mic_boost(struct hda_codec *codec) |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2327 | { |
| 2328 | struct conexant_spec *spec = codec->spec; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2329 | snd_hda_codec_write_cache(codec, 0x17, 0, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2330 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2331 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | |
| 2332 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2333 | if (spec->ideapad || spec->thinkpad) { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2334 | /* adjust the internal mic as well...it is not through 0x17 */ |
| 2335 | snd_hda_codec_write_cache(codec, 0x23, 0, |
| 2336 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2337 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | |
| 2338 | cxt5066_analog_mic_boost. |
| 2339 | items[spec->mic_boost].index); |
| 2340 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2341 | } |
| 2342 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2343 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 2344 | struct snd_ctl_elem_info *uinfo) |
| 2345 | { |
| 2346 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); |
| 2347 | } |
| 2348 | |
| 2349 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 2350 | struct snd_ctl_elem_value *ucontrol) |
| 2351 | { |
| 2352 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2353 | struct conexant_spec *spec = codec->spec; |
| 2354 | ucontrol->value.enumerated.item[0] = spec->mic_boost; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2355 | return 0; |
| 2356 | } |
| 2357 | |
| 2358 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 2359 | struct snd_ctl_elem_value *ucontrol) |
| 2360 | { |
| 2361 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2362 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2363 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2364 | unsigned int idx; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2365 | idx = ucontrol->value.enumerated.item[0]; |
| 2366 | if (idx >= imux->num_items) |
| 2367 | idx = imux->num_items - 1; |
| 2368 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2369 | spec->mic_boost = idx; |
| 2370 | if (!spec->dc_enable) |
| 2371 | cxt5066_set_mic_boost(codec); |
| 2372 | return 1; |
| 2373 | } |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2374 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2375 | static void cxt5066_enable_dc(struct hda_codec *codec) |
| 2376 | { |
| 2377 | const struct hda_verb enable_dc_mode[] = { |
| 2378 | /* disable gain */ |
| 2379 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2380 | |
| 2381 | /* switch to DC input */ |
| 2382 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, |
| 2383 | {} |
| 2384 | }; |
| 2385 | |
| 2386 | /* configure as input source */ |
| 2387 | snd_hda_sequence_write(codec, enable_dc_mode); |
| 2388 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ |
| 2389 | } |
| 2390 | |
| 2391 | static void cxt5066_disable_dc(struct hda_codec *codec) |
| 2392 | { |
| 2393 | /* reconfigure input source */ |
| 2394 | cxt5066_set_mic_boost(codec); |
| 2395 | /* automic also selects the right mic if we're recording */ |
| 2396 | cxt5066_olpc_automic(codec); |
| 2397 | } |
| 2398 | |
| 2399 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, |
| 2400 | struct snd_ctl_elem_value *ucontrol) |
| 2401 | { |
| 2402 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2403 | struct conexant_spec *spec = codec->spec; |
| 2404 | ucontrol->value.integer.value[0] = spec->dc_enable; |
| 2405 | return 0; |
| 2406 | } |
| 2407 | |
| 2408 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
| 2409 | struct snd_ctl_elem_value *ucontrol) |
| 2410 | { |
| 2411 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2412 | struct conexant_spec *spec = codec->spec; |
| 2413 | int dc_enable = !!ucontrol->value.integer.value[0]; |
| 2414 | |
| 2415 | if (dc_enable == spec->dc_enable) |
| 2416 | return 0; |
| 2417 | |
| 2418 | spec->dc_enable = dc_enable; |
| 2419 | if (dc_enable) |
| 2420 | cxt5066_enable_dc(codec); |
| 2421 | else |
| 2422 | cxt5066_disable_dc(codec); |
| 2423 | |
| 2424 | return 1; |
| 2425 | } |
| 2426 | |
| 2427 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, |
| 2428 | struct snd_ctl_elem_info *uinfo) |
| 2429 | { |
| 2430 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); |
| 2431 | } |
| 2432 | |
| 2433 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, |
| 2434 | struct snd_ctl_elem_value *ucontrol) |
| 2435 | { |
| 2436 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2437 | struct conexant_spec *spec = codec->spec; |
| 2438 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; |
| 2439 | return 0; |
| 2440 | } |
| 2441 | |
| 2442 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, |
| 2443 | struct snd_ctl_elem_value *ucontrol) |
| 2444 | { |
| 2445 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2446 | struct conexant_spec *spec = codec->spec; |
| 2447 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
| 2448 | unsigned int idx; |
| 2449 | |
| 2450 | idx = ucontrol->value.enumerated.item[0]; |
| 2451 | if (idx >= imux->num_items) |
| 2452 | idx = imux->num_items - 1; |
| 2453 | |
| 2454 | spec->dc_input_bias = idx; |
| 2455 | if (spec->dc_enable) |
| 2456 | cxt5066_set_olpc_dc_bias(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2457 | return 1; |
| 2458 | } |
| 2459 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2460 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) |
| 2461 | { |
| 2462 | struct conexant_spec *spec = codec->spec; |
| 2463 | /* mark as recording and configure the microphone widget so that the |
| 2464 | * recording LED comes on. */ |
| 2465 | spec->recording = 1; |
| 2466 | cxt5066_olpc_select_mic(codec); |
| 2467 | } |
| 2468 | |
| 2469 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) |
| 2470 | { |
| 2471 | struct conexant_spec *spec = codec->spec; |
| 2472 | const struct hda_verb disable_mics[] = { |
| 2473 | /* disable external mic, port B */ |
| 2474 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2475 | |
| 2476 | /* disble internal mic, port C */ |
| 2477 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2478 | |
| 2479 | /* disable DC capture, port F */ |
| 2480 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2481 | {}, |
| 2482 | }; |
| 2483 | |
| 2484 | snd_hda_sequence_write(codec, disable_mics); |
| 2485 | spec->recording = 0; |
| 2486 | } |
| 2487 | |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2488 | static void conexant_check_dig_outs(struct hda_codec *codec, |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2489 | const hda_nid_t *dig_pins, |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2490 | int num_pins) |
| 2491 | { |
| 2492 | struct conexant_spec *spec = codec->spec; |
| 2493 | hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; |
| 2494 | int i; |
| 2495 | |
| 2496 | for (i = 0; i < num_pins; i++, dig_pins++) { |
| 2497 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); |
| 2498 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) |
| 2499 | continue; |
| 2500 | if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) |
| 2501 | continue; |
| 2502 | if (spec->slave_dig_outs[0]) |
| 2503 | nid_loc++; |
| 2504 | else |
| 2505 | nid_loc = spec->slave_dig_outs; |
| 2506 | } |
| 2507 | } |
| 2508 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2509 | static const struct hda_input_mux cxt5066_capture_source = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2510 | .num_items = 4, |
| 2511 | .items = { |
| 2512 | { "Mic B", 0 }, |
| 2513 | { "Mic C", 1 }, |
| 2514 | { "Mic E", 2 }, |
| 2515 | { "Mic F", 3 }, |
| 2516 | }, |
| 2517 | }; |
| 2518 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2519 | static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2520 | .ops = &snd_hda_bind_vol, |
| 2521 | .values = { |
| 2522 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2523 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2524 | 0 |
| 2525 | }, |
| 2526 | }; |
| 2527 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2528 | static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2529 | .ops = &snd_hda_bind_sw, |
| 2530 | .values = { |
| 2531 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), |
| 2532 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), |
| 2533 | 0 |
| 2534 | }, |
| 2535 | }; |
| 2536 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2537 | static const struct snd_kcontrol_new cxt5066_mixer_master[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2538 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
| 2539 | {} |
| 2540 | }; |
| 2541 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2542 | static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2543 | { |
| 2544 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2545 | .name = "Master Playback Volume", |
| 2546 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2547 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2548 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2549 | .subdevice = HDA_SUBDEV_AMP_FLAG, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2550 | .info = snd_hda_mixer_amp_volume_info, |
| 2551 | .get = snd_hda_mixer_amp_volume_get, |
| 2552 | .put = snd_hda_mixer_amp_volume_put, |
| 2553 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
| 2554 | /* offset by 28 volume steps to limit minimum gain to -46dB */ |
| 2555 | .private_value = |
| 2556 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), |
| 2557 | }, |
| 2558 | {} |
| 2559 | }; |
| 2560 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2561 | static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2562 | { |
| 2563 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2564 | .name = "DC Mode Enable Switch", |
| 2565 | .info = snd_ctl_boolean_mono_info, |
| 2566 | .get = cxt5066_olpc_dc_get, |
| 2567 | .put = cxt5066_olpc_dc_put, |
| 2568 | }, |
| 2569 | { |
| 2570 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2571 | .name = "DC Input Bias Enum", |
| 2572 | .info = cxt5066_olpc_dc_bias_enum_info, |
| 2573 | .get = cxt5066_olpc_dc_bias_enum_get, |
| 2574 | .put = cxt5066_olpc_dc_bias_enum_put, |
| 2575 | }, |
| 2576 | {} |
| 2577 | }; |
| 2578 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2579 | static const struct snd_kcontrol_new cxt5066_mixers[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2580 | { |
| 2581 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2582 | .name = "Master Playback Switch", |
| 2583 | .info = cxt_eapd_info, |
| 2584 | .get = cxt_eapd_get, |
| 2585 | .put = cxt5066_hp_master_sw_put, |
| 2586 | .private_value = 0x1d, |
| 2587 | }, |
| 2588 | |
| 2589 | { |
| 2590 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2591 | .name = "Analog Mic Boost Capture Enum", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2592 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2593 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2594 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2595 | }, |
| 2596 | |
| 2597 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
| 2598 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), |
| 2599 | {} |
| 2600 | }; |
| 2601 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2602 | static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2603 | { |
| 2604 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2605 | .name = "Internal Mic Boost Capture Enum", |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 2606 | .info = cxt5066_mic_boost_mux_enum_info, |
| 2607 | .get = cxt5066_mic_boost_mux_enum_get, |
| 2608 | .put = cxt5066_mic_boost_mux_enum_put, |
| 2609 | .private_value = 0x23 | 0x100, |
| 2610 | }, |
| 2611 | {} |
| 2612 | }; |
| 2613 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2614 | static const struct hda_verb cxt5066_init_verbs[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2615 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2616 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2617 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2618 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2619 | |
| 2620 | /* Speakers */ |
| 2621 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2622 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2623 | |
| 2624 | /* HP, Amp */ |
| 2625 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2626 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2627 | |
| 2628 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2629 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2630 | |
| 2631 | /* DAC1 */ |
| 2632 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2633 | |
| 2634 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2635 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2636 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2637 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2638 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2639 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2640 | |
| 2641 | /* no digital microphone support yet */ |
| 2642 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2643 | |
| 2644 | /* Audio input selector */ |
| 2645 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2646 | |
| 2647 | /* SPDIF route: PCM */ |
| 2648 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2649 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2650 | |
| 2651 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2652 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2653 | |
| 2654 | /* EAPD */ |
| 2655 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2656 | |
| 2657 | /* not handling these yet */ |
| 2658 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2659 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2660 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2661 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2662 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2663 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2664 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2665 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, |
| 2666 | { } /* end */ |
| 2667 | }; |
| 2668 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2669 | static const struct hda_verb cxt5066_init_verbs_olpc[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2670 | /* Port A: headphones */ |
| 2671 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2672 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2673 | |
| 2674 | /* Port B: external microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2675 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2676 | |
| 2677 | /* Port C: internal microphone */ |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2678 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2679 | |
| 2680 | /* Port D: unused */ |
| 2681 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2682 | |
| 2683 | /* Port E: unused, but has primary EAPD */ |
| 2684 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2685 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2686 | |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2687 | /* Port F: external DC input through microphone port */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2688 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2689 | |
| 2690 | /* Port G: internal speakers */ |
| 2691 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2692 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2693 | |
| 2694 | /* DAC1 */ |
| 2695 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2696 | |
| 2697 | /* DAC2: unused */ |
| 2698 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2699 | |
| 2700 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2701 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2702 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2703 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2704 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2705 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2706 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2707 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2708 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2709 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2710 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2711 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2712 | |
| 2713 | /* Disable digital microphone port */ |
| 2714 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2715 | |
| 2716 | /* Audio input selectors */ |
| 2717 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2718 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2719 | |
| 2720 | /* Disable SPDIF */ |
| 2721 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2722 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2723 | |
| 2724 | /* enable unsolicited events for Port A and B */ |
| 2725 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2726 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2727 | { } /* end */ |
| 2728 | }; |
| 2729 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2730 | static const struct hda_verb cxt5066_init_verbs_vostro[] = { |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 2731 | /* Port A: headphones */ |
| 2732 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2733 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2734 | |
| 2735 | /* Port B: external microphone */ |
| 2736 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2737 | |
| 2738 | /* Port C: unused */ |
| 2739 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2740 | |
| 2741 | /* Port D: unused */ |
| 2742 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2743 | |
| 2744 | /* Port E: unused, but has primary EAPD */ |
| 2745 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2746 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2747 | |
| 2748 | /* Port F: unused */ |
| 2749 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2750 | |
| 2751 | /* Port G: internal speakers */ |
| 2752 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2753 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2754 | |
| 2755 | /* DAC1 */ |
| 2756 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2757 | |
| 2758 | /* DAC2: unused */ |
| 2759 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
| 2760 | |
| 2761 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2762 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2763 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2764 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2765 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2766 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2767 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2768 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2769 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 2770 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2771 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 2772 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2773 | |
| 2774 | /* Digital microphone port */ |
| 2775 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
| 2776 | |
| 2777 | /* Audio input selectors */ |
| 2778 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, |
| 2779 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
| 2780 | |
| 2781 | /* Disable SPDIF */ |
| 2782 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2783 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2784 | |
| 2785 | /* enable unsolicited events for Port A and B */ |
| 2786 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2787 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2788 | { } /* end */ |
| 2789 | }; |
| 2790 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2791 | static const struct hda_verb cxt5066_init_verbs_ideapad[] = { |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2792 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ |
| 2793 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ |
| 2794 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2795 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2796 | |
| 2797 | /* Speakers */ |
| 2798 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2799 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2800 | |
| 2801 | /* HP, Amp */ |
| 2802 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2803 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2804 | |
| 2805 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
| 2806 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2807 | |
| 2808 | /* DAC1 */ |
| 2809 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2810 | |
| 2811 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2812 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2813 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2814 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2815 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2816 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2817 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2818 | |
| 2819 | /* Audio input selector */ |
| 2820 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2821 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2822 | |
| 2823 | /* SPDIF route: PCM */ |
| 2824 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2825 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2826 | |
| 2827 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2828 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2829 | |
| 2830 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2831 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2832 | |
| 2833 | /* EAPD */ |
| 2834 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2835 | |
| 2836 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2837 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2838 | { } /* end */ |
| 2839 | }; |
| 2840 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2841 | static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2842 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ |
| 2843 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ |
| 2844 | |
| 2845 | /* Port G: internal speakers */ |
| 2846 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2847 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2848 | |
| 2849 | /* Port A: HP, Amp */ |
| 2850 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2851 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2852 | |
| 2853 | /* Port B: Mic Dock */ |
| 2854 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2855 | |
| 2856 | /* Port C: Mic */ |
| 2857 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2858 | |
| 2859 | /* Port D: HP Dock, Amp */ |
| 2860 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
| 2861 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
| 2862 | |
| 2863 | /* DAC1 */ |
| 2864 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 2865 | |
| 2866 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ |
| 2867 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, |
| 2868 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 2869 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, |
| 2870 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 2871 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 2872 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ |
| 2873 | |
| 2874 | /* Audio input selector */ |
| 2875 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, |
| 2876 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ |
| 2877 | |
| 2878 | /* SPDIF route: PCM */ |
| 2879 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2880 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2881 | |
| 2882 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2883 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2884 | |
| 2885 | /* internal microphone */ |
David Henningsson | 28c4edb | 2010-12-20 14:24:29 +0100 | [diff] [blame] | 2886 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2887 | |
| 2888 | /* EAPD */ |
| 2889 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
| 2890 | |
| 2891 | /* enable unsolicited events for Port A, B, C and D */ |
| 2892 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2893 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2894 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2895 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2896 | { } /* end */ |
| 2897 | }; |
| 2898 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2899 | static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2900 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 2901 | { } /* end */ |
| 2902 | }; |
| 2903 | |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2904 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2905 | static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2906 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2907 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, |
| 2908 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, |
| 2909 | { } /* end */ |
| 2910 | }; |
| 2911 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2912 | /* initialize jack-sensing, too */ |
| 2913 | static int cxt5066_init(struct hda_codec *codec) |
| 2914 | { |
| 2915 | snd_printdd("CXT5066: init\n"); |
| 2916 | conexant_init(codec); |
| 2917 | if (codec->patch_ops.unsol_event) { |
| 2918 | cxt5066_hp_automute(codec); |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 2919 | cxt5066_automic(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2920 | } |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2921 | cxt5066_set_mic_boost(codec); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2922 | return 0; |
| 2923 | } |
| 2924 | |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2925 | static int cxt5066_olpc_init(struct hda_codec *codec) |
| 2926 | { |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2927 | struct conexant_spec *spec = codec->spec; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2928 | snd_printdd("CXT5066: init\n"); |
| 2929 | conexant_init(codec); |
| 2930 | cxt5066_hp_automute(codec); |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 2931 | if (!spec->dc_enable) { |
| 2932 | cxt5066_set_mic_boost(codec); |
| 2933 | cxt5066_olpc_automic(codec); |
| 2934 | } else { |
| 2935 | cxt5066_enable_dc(codec); |
| 2936 | } |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 2937 | return 0; |
| 2938 | } |
| 2939 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2940 | enum { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2941 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2942 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
| 2943 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2944 | CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2945 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2946 | CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2947 | 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] | 2948 | CXT5066_HP_LAPTOP, /* HP Laptop */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2949 | CXT5066_AUTO, /* BIOS auto-parser */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2950 | CXT5066_MODELS |
| 2951 | }; |
| 2952 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2953 | static const char * const cxt5066_models[CXT5066_MODELS] = { |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2954 | [CXT5066_LAPTOP] = "laptop", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2955 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
| 2956 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2957 | [CXT5066_DELL_VOSTRO] = "dell-vostro", |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 2958 | [CXT5066_IDEAPAD] = "ideapad", |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 2959 | [CXT5066_THINKPAD] = "thinkpad", |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2960 | [CXT5066_ASUS] = "asus", |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2961 | [CXT5066_HP_LAPTOP] = "hp-laptop", |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 2962 | [CXT5066_AUTO] = "auto", |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2963 | }; |
| 2964 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 2965 | static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
David Henningsson | 9966db22 | 2011-06-21 21:01:52 +0200 | [diff] [blame] | 2966 | SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT5066_AUTO), |
Takashi Iwai | 00cd0bb | 2010-10-21 09:57:40 +0200 | [diff] [blame] | 2967 | SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2968 | SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), |
David Henningsson | 8a96b1e | 2010-12-09 07:17:27 +0100 | [diff] [blame] | 2969 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), |
Daniel T Chen | ca6cd85 | 2011-01-08 18:25:27 -0500 | [diff] [blame] | 2970 | SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 2971 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), |
Anisse Astier | 231f50b | 2010-04-28 18:05:06 +0200 | [diff] [blame] | 2972 | SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), |
David Henningsson | ebbd224 | 2011-02-23 13:15:56 +0100 | [diff] [blame] | 2973 | SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), |
| 2974 | SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 2975 | SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2976 | SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2977 | SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 2978 | SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), |
Anisse Astier | 2ca9cac | 2010-09-10 15:47:55 +0200 | [diff] [blame] | 2979 | SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), |
Daniel T Chen | c536668 | 2010-05-04 22:07:58 -0400 | [diff] [blame] | 2980 | 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] | 2981 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
| 2982 | CXT5066_LAPTOP), |
| 2983 | 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] | 2984 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), |
Manoj Iyer | ef61d4e | 2010-12-03 18:43:55 -0600 | [diff] [blame] | 2985 | SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), |
David Henningsson | 1959387 | 2011-01-27 10:28:46 +0100 | [diff] [blame] | 2986 | SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), |
David Henningsson | 29c5fbb | 2012-01-23 16:39:55 +0100 | [diff] [blame] | 2987 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T510", CXT5066_AUTO), |
Daniel Suchy | ca201c0 | 2011-10-18 11:09:44 +0200 | [diff] [blame] | 2988 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520 & W520", CXT5066_AUTO), |
David Henningsson | 8401265 | 2011-03-31 09:36:19 +0200 | [diff] [blame] | 2989 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD), |
David Henningsson | b2cb129 | 2011-04-05 07:55:24 +0200 | [diff] [blame] | 2990 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), |
David Henningsson | d2859fd | 2011-05-23 08:26:16 +0200 | [diff] [blame] | 2991 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 2992 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), |
Takashi Iwai | af4ccf4 | 2011-05-25 07:33:20 +0200 | [diff] [blame] | 2993 | SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G565", CXT5066_AUTO), |
Daniel T Chen | 7ab1fc0 | 2011-06-10 10:14:01 -0400 | [diff] [blame] | 2994 | SND_PCI_QUIRK(0x1b0a, 0x2092, "CyberpowerPC Gamer Xplorer N57001", CXT5066_AUTO), |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 2995 | {} |
| 2996 | }; |
| 2997 | |
| 2998 | static int patch_cxt5066(struct hda_codec *codec) |
| 2999 | { |
| 3000 | struct conexant_spec *spec; |
| 3001 | int board_config; |
| 3002 | |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3003 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, |
| 3004 | cxt5066_models, cxt5066_cfg_tbl); |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3005 | if (board_config < 0) |
Takashi Iwai | c82693d | 2011-06-28 14:17:17 +0200 | [diff] [blame] | 3006 | board_config = CXT5066_AUTO; /* model=auto as default */ |
Takashi Iwai | fea4a4f | 2011-05-16 11:49:12 +0200 | [diff] [blame] | 3007 | if (board_config == CXT5066_AUTO) |
| 3008 | return patch_conexant_auto(codec); |
| 3009 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3010 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3011 | if (!spec) |
| 3012 | return -ENOMEM; |
| 3013 | codec->spec = spec; |
| 3014 | |
| 3015 | codec->patch_ops = conexant_patch_ops; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3016 | codec->patch_ops.init = conexant_init; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3017 | |
| 3018 | spec->dell_automute = 0; |
| 3019 | spec->multiout.max_channels = 2; |
| 3020 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); |
| 3021 | spec->multiout.dac_nids = cxt5066_dac_nids; |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 3022 | conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, |
| 3023 | ARRAY_SIZE(cxt5066_digout_pin_nids)); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3024 | spec->num_adc_nids = 1; |
| 3025 | spec->adc_nids = cxt5066_adc_nids; |
| 3026 | spec->capsrc_nids = cxt5066_capsrc_nids; |
| 3027 | spec->input_mux = &cxt5066_capture_source; |
| 3028 | |
| 3029 | spec->port_d_mode = PIN_HP; |
| 3030 | |
| 3031 | spec->num_init_verbs = 1; |
| 3032 | spec->init_verbs[0] = cxt5066_init_verbs; |
| 3033 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); |
| 3034 | spec->channel_mode = cxt5066_modes; |
| 3035 | spec->cur_adc = 0; |
| 3036 | spec->cur_adc_idx = 0; |
| 3037 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3038 | set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); |
| 3039 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3040 | switch (board_config) { |
| 3041 | default: |
| 3042 | case CXT5066_LAPTOP: |
| 3043 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3044 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3045 | break; |
| 3046 | case CXT5066_DELL_LAPTOP: |
| 3047 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3048 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3049 | |
| 3050 | spec->port_d_mode = PIN_OUT; |
| 3051 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; |
| 3052 | spec->num_init_verbs++; |
| 3053 | spec->dell_automute = 1; |
| 3054 | break; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3055 | case CXT5066_ASUS: |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3056 | case CXT5066_HP_LAPTOP: |
| 3057 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3058 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3059 | spec->init_verbs[spec->num_init_verbs] = |
| 3060 | cxt5066_init_verbs_hp_laptop; |
| 3061 | spec->num_init_verbs++; |
David Henningsson | a1d6906 | 2011-01-21 13:33:28 +0100 | [diff] [blame] | 3062 | spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; |
| 3063 | spec->asus = board_config == CXT5066_ASUS; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3064 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3065 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3066 | /* no S/PDIF out */ |
Andy Robinson | f6a2491 | 2011-01-24 10:12:37 -0500 | [diff] [blame] | 3067 | if (board_config == CXT5066_HP_LAPTOP) |
| 3068 | spec->multiout.dig_out_nid = 0; |
David Henningsson | 048e78a | 2010-09-02 08:35:47 +0200 | [diff] [blame] | 3069 | /* input source automatically selected */ |
| 3070 | spec->input_mux = NULL; |
| 3071 | spec->port_d_mode = 0; |
| 3072 | spec->mic_boost = 3; /* default 30dB gain */ |
| 3073 | break; |
| 3074 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3075 | case CXT5066_OLPC_XO_1_5: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3076 | codec->patch_ops.init = cxt5066_olpc_init; |
| 3077 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3078 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
| 3079 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3080 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3081 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3082 | spec->port_d_mode = 0; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3083 | spec->mic_boost = 3; /* default 30dB gain */ |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3084 | |
| 3085 | /* no S/PDIF out */ |
| 3086 | spec->multiout.dig_out_nid = 0; |
| 3087 | |
| 3088 | /* input source automatically selected */ |
| 3089 | spec->input_mux = NULL; |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3090 | |
| 3091 | /* our capture hooks which allow us to turn on the microphone LED |
| 3092 | * at the right time */ |
| 3093 | spec->capture_prepare = cxt5066_olpc_capture_prepare; |
| 3094 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3095 | break; |
David Henningsson | 1feba3b | 2010-09-17 10:52:50 +0200 | [diff] [blame] | 3096 | case CXT5066_DELL_VOSTRO: |
Daniel Drake | 75f8991 | 2010-01-07 13:46:25 +0100 | [diff] [blame] | 3097 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3098 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3099 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
| 3100 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
| 3101 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3102 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3103 | spec->port_d_mode = 0; |
Einar Rünkaru | 254bba6 | 2009-12-16 22:16:13 +0200 | [diff] [blame] | 3104 | spec->dell_vostro = 1; |
Daniel Drake | c4cfe66 | 2010-01-07 13:47:04 +0100 | [diff] [blame] | 3105 | spec->mic_boost = 3; /* default 30dB gain */ |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 3106 | |
| 3107 | /* no S/PDIF out */ |
| 3108 | spec->multiout.dig_out_nid = 0; |
| 3109 | |
| 3110 | /* input source automatically selected */ |
| 3111 | spec->input_mux = NULL; |
| 3112 | break; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3113 | case CXT5066_IDEAPAD: |
| 3114 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3115 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Greg Alexander | cfd3d8d | 2010-02-13 02:02:25 -0500 | [diff] [blame] | 3116 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3117 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3118 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; |
| 3119 | spec->port_d_mode = 0; |
| 3120 | spec->ideapad = 1; |
| 3121 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3122 | |
| 3123 | /* no S/PDIF out */ |
| 3124 | spec->multiout.dig_out_nid = 0; |
| 3125 | |
| 3126 | /* input source automatically selected */ |
| 3127 | spec->input_mux = NULL; |
| 3128 | break; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3129 | case CXT5066_THINKPAD: |
| 3130 | codec->patch_ops.init = cxt5066_init; |
David Henningsson | 02b6b5b | 2011-01-21 13:27:39 +0100 | [diff] [blame] | 3131 | codec->patch_ops.unsol_event = cxt5066_unsol_event; |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 3132 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; |
| 3133 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
| 3134 | spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; |
| 3135 | spec->thinkpad = 1; |
| 3136 | spec->port_d_mode = PIN_OUT; |
| 3137 | spec->mic_boost = 2; /* default 20dB gain */ |
| 3138 | |
| 3139 | /* no S/PDIF out */ |
| 3140 | spec->multiout.dig_out_nid = 0; |
| 3141 | |
| 3142 | /* input source automatically selected */ |
| 3143 | spec->input_mux = NULL; |
| 3144 | break; |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3145 | } |
| 3146 | |
Takashi Iwai | 3507e2a | 2010-07-08 18:39:00 +0200 | [diff] [blame] | 3147 | if (spec->beep_amp) |
| 3148 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
| 3149 | |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 3150 | return 0; |
| 3151 | } |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 3152 | |
| 3153 | /* |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3154 | * Automatic parser for CX20641 & co |
| 3155 | */ |
| 3156 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3157 | static int cx_auto_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3158 | struct hda_codec *codec, |
| 3159 | unsigned int stream_tag, |
| 3160 | unsigned int format, |
| 3161 | struct snd_pcm_substream *substream) |
| 3162 | { |
| 3163 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3164 | hda_nid_t adc = spec->imux_info[spec->cur_mux[0]].adc; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3165 | if (spec->adc_switching) { |
| 3166 | spec->cur_adc = adc; |
| 3167 | spec->cur_adc_stream_tag = stream_tag; |
| 3168 | spec->cur_adc_format = format; |
| 3169 | } |
| 3170 | snd_hda_codec_setup_stream(codec, adc, stream_tag, 0, format); |
| 3171 | return 0; |
| 3172 | } |
| 3173 | |
| 3174 | static int cx_auto_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3175 | struct hda_codec *codec, |
| 3176 | struct snd_pcm_substream *substream) |
| 3177 | { |
| 3178 | struct conexant_spec *spec = codec->spec; |
| 3179 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 3180 | spec->cur_adc = 0; |
| 3181 | return 0; |
| 3182 | } |
| 3183 | |
| 3184 | static const struct hda_pcm_stream cx_auto_pcm_analog_capture = { |
| 3185 | .substreams = 1, |
| 3186 | .channels_min = 2, |
| 3187 | .channels_max = 2, |
| 3188 | .nid = 0, /* fill later */ |
| 3189 | .ops = { |
| 3190 | .prepare = cx_auto_capture_pcm_prepare, |
| 3191 | .cleanup = cx_auto_capture_pcm_cleanup |
| 3192 | }, |
| 3193 | }; |
| 3194 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 3195 | static const hda_nid_t cx_auto_adc_nids[] = { 0x14 }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3196 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 3197 | #define get_connection_index(codec, mux, nid)\ |
| 3198 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3199 | |
| 3200 | /* get an unassigned DAC from the given list. |
| 3201 | * Return the nid if found and reduce the DAC list, or return zero if |
| 3202 | * not found |
| 3203 | */ |
| 3204 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin, |
| 3205 | hda_nid_t *dacs, int *num_dacs) |
| 3206 | { |
| 3207 | int i, nums = *num_dacs; |
| 3208 | hda_nid_t ret = 0; |
| 3209 | |
| 3210 | for (i = 0; i < nums; i++) { |
| 3211 | if (get_connection_index(codec, pin, dacs[i]) >= 0) { |
| 3212 | ret = dacs[i]; |
| 3213 | break; |
| 3214 | } |
| 3215 | } |
| 3216 | if (!ret) |
| 3217 | return 0; |
| 3218 | if (--nums > 0) |
| 3219 | memmove(dacs, dacs + 1, nums * sizeof(hda_nid_t)); |
| 3220 | *num_dacs = nums; |
| 3221 | return ret; |
| 3222 | } |
| 3223 | |
| 3224 | #define MAX_AUTO_DACS 5 |
| 3225 | |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3226 | #define DAC_SLAVE_FLAG 0x8000 /* filled dac is a slave */ |
| 3227 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3228 | /* fill analog DAC list from the widget tree */ |
| 3229 | static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) |
| 3230 | { |
| 3231 | hda_nid_t nid, end_nid; |
| 3232 | int nums = 0; |
| 3233 | |
| 3234 | end_nid = codec->start_nid + codec->num_nodes; |
| 3235 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3236 | unsigned int wcaps = get_wcaps(codec, nid); |
| 3237 | unsigned int type = get_wcaps_type(wcaps); |
| 3238 | if (type == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) { |
| 3239 | dacs[nums++] = nid; |
| 3240 | if (nums >= MAX_AUTO_DACS) |
| 3241 | break; |
| 3242 | } |
| 3243 | } |
| 3244 | return nums; |
| 3245 | } |
| 3246 | |
| 3247 | /* fill pin_dac_pair list from the pin and dac list */ |
| 3248 | static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, |
| 3249 | int num_pins, hda_nid_t *dacs, int *rest, |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3250 | struct pin_dac_pair *filled, int nums, |
| 3251 | int type) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3252 | { |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3253 | int i, start = nums; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3254 | |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3255 | for (i = 0; i < num_pins; i++, nums++) { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3256 | filled[nums].pin = pins[i]; |
| 3257 | filled[nums].type = type; |
| 3258 | filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3259 | if (filled[nums].dac) |
| 3260 | continue; |
| 3261 | if (filled[start].dac && get_connection_index(codec, pins[i], filled[start].dac) >= 0) { |
| 3262 | filled[nums].dac = filled[start].dac | DAC_SLAVE_FLAG; |
| 3263 | continue; |
| 3264 | } |
| 3265 | 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] | 3266 | filled[nums].dac = filled[0].dac | DAC_SLAVE_FLAG; |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 3267 | continue; |
| 3268 | } |
| 3269 | 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] | 3270 | } |
| 3271 | return nums; |
| 3272 | } |
| 3273 | |
| 3274 | /* parse analog output paths */ |
| 3275 | static void cx_auto_parse_output(struct hda_codec *codec) |
| 3276 | { |
| 3277 | struct conexant_spec *spec = codec->spec; |
| 3278 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3279 | hda_nid_t dacs[MAX_AUTO_DACS]; |
| 3280 | int i, j, nums, rest; |
| 3281 | |
| 3282 | rest = fill_cx_auto_dacs(codec, dacs); |
| 3283 | /* parse all analog output pins */ |
| 3284 | 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] | 3285 | dacs, &rest, spec->dac_info, 0, |
| 3286 | AUTO_PIN_LINE_OUT); |
| 3287 | nums = fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, |
| 3288 | dacs, &rest, spec->dac_info, nums, |
| 3289 | AUTO_PIN_HP_OUT); |
| 3290 | nums = fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, |
| 3291 | dacs, &rest, spec->dac_info, nums, |
| 3292 | AUTO_PIN_SPEAKER_OUT); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3293 | spec->dac_info_filled = nums; |
| 3294 | /* fill multiout struct */ |
| 3295 | for (i = 0; i < nums; i++) { |
| 3296 | hda_nid_t dac = spec->dac_info[i].dac; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3297 | if (!dac || (dac & DAC_SLAVE_FLAG)) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3298 | continue; |
| 3299 | switch (spec->dac_info[i].type) { |
| 3300 | case AUTO_PIN_LINE_OUT: |
| 3301 | spec->private_dac_nids[spec->multiout.num_dacs] = dac; |
| 3302 | spec->multiout.num_dacs++; |
| 3303 | break; |
| 3304 | case AUTO_PIN_HP_OUT: |
| 3305 | case AUTO_PIN_SPEAKER_OUT: |
| 3306 | if (!spec->multiout.hp_nid) { |
| 3307 | spec->multiout.hp_nid = dac; |
| 3308 | break; |
| 3309 | } |
| 3310 | for (j = 0; j < ARRAY_SIZE(spec->multiout.extra_out_nid); j++) |
| 3311 | if (!spec->multiout.extra_out_nid[j]) { |
| 3312 | spec->multiout.extra_out_nid[j] = dac; |
| 3313 | break; |
| 3314 | } |
| 3315 | break; |
| 3316 | } |
| 3317 | } |
| 3318 | spec->multiout.dac_nids = spec->private_dac_nids; |
David Henningsson | 8972495 | 2011-02-16 21:34:04 +0100 | [diff] [blame] | 3319 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3320 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3321 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3322 | if (is_jack_detectable(codec, cfg->hp_pins[i])) { |
| 3323 | spec->auto_mute = 1; |
| 3324 | break; |
| 3325 | } |
| 3326 | } |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3327 | if (spec->auto_mute && |
| 3328 | cfg->line_out_pins[0] && |
| 3329 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3330 | cfg->line_out_pins[0] != cfg->hp_pins[0] && |
| 3331 | cfg->line_out_pins[0] != cfg->speaker_pins[0]) { |
| 3332 | for (i = 0; i < cfg->line_outs; i++) { |
| 3333 | if (is_jack_detectable(codec, cfg->line_out_pins[i])) { |
| 3334 | spec->detect_line = 1; |
| 3335 | break; |
| 3336 | } |
| 3337 | } |
| 3338 | spec->automute_lines = spec->detect_line; |
| 3339 | } |
| 3340 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3341 | spec->vmaster_nid = spec->private_dac_nids[0]; |
| 3342 | } |
| 3343 | |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3344 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
| 3345 | hda_nid_t *pins, bool on); |
| 3346 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3347 | static void do_automute(struct hda_codec *codec, int num_pins, |
| 3348 | hda_nid_t *pins, bool on) |
| 3349 | { |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3350 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3351 | int i; |
| 3352 | for (i = 0; i < num_pins; i++) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3353 | snd_hda_set_pin_ctl(codec, pins[i], on ? PIN_OUT : 0); |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3354 | if (spec->pin_eapd_ctrls) |
| 3355 | cx_auto_turn_eapd(codec, num_pins, pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3356 | } |
| 3357 | |
| 3358 | static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) |
| 3359 | { |
| 3360 | int i, present = 0; |
| 3361 | |
| 3362 | for (i = 0; i < num_pins; i++) { |
| 3363 | hda_nid_t nid = pins[i]; |
| 3364 | if (!nid || !is_jack_detectable(codec, nid)) |
| 3365 | break; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3366 | present |= snd_hda_jack_detect(codec, nid); |
| 3367 | } |
| 3368 | return present; |
| 3369 | } |
| 3370 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3371 | /* auto-mute/unmute speaker and line outs according to headphone jack */ |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3372 | static void cx_auto_update_speakers(struct hda_codec *codec) |
| 3373 | { |
| 3374 | struct conexant_spec *spec = codec->spec; |
| 3375 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3376 | int on = 1; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3377 | |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3378 | /* turn on HP EAPD when HP jacks are present */ |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3379 | if (spec->pin_eapd_ctrls) { |
| 3380 | if (spec->auto_mute) |
| 3381 | on = spec->hp_present; |
| 3382 | cx_auto_turn_eapd(codec, cfg->hp_outs, cfg->hp_pins, on); |
| 3383 | } |
| 3384 | |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3385 | /* mute speakers in auto-mode if HP or LO jacks are plugged */ |
| 3386 | if (spec->auto_mute) |
| 3387 | on = !(spec->hp_present || |
| 3388 | (spec->detect_line && spec->line_present)); |
| 3389 | do_automute(codec, cfg->speaker_outs, cfg->speaker_pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3390 | |
| 3391 | /* toggle line-out mutes if needed, too */ |
| 3392 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 3393 | if (cfg->line_out_pins[0] == cfg->hp_pins[0] || |
| 3394 | cfg->line_out_pins[0] == cfg->speaker_pins[0]) |
| 3395 | return; |
Takashi Iwai | e2df82f | 2011-05-24 11:49:12 +0200 | [diff] [blame] | 3396 | if (spec->auto_mute) { |
| 3397 | /* mute LO in auto-mode when HP jack is present */ |
| 3398 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT || |
| 3399 | spec->automute_lines) |
| 3400 | on = !spec->hp_present; |
| 3401 | else |
| 3402 | on = 1; |
| 3403 | } |
| 3404 | do_automute(codec, cfg->line_outs, cfg->line_out_pins, on); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3405 | } |
| 3406 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3407 | static void cx_auto_hp_automute(struct hda_codec *codec) |
| 3408 | { |
| 3409 | struct conexant_spec *spec = codec->spec; |
| 3410 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3411 | |
| 3412 | if (!spec->auto_mute) |
| 3413 | return; |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3414 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, cfg->hp_pins); |
| 3415 | cx_auto_update_speakers(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3416 | } |
| 3417 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3418 | static void cx_auto_line_automute(struct hda_codec *codec) |
| 3419 | { |
| 3420 | struct conexant_spec *spec = codec->spec; |
| 3421 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3422 | |
| 3423 | if (!spec->auto_mute || !spec->detect_line) |
| 3424 | return; |
| 3425 | spec->line_present = detect_jacks(codec, cfg->line_outs, |
| 3426 | cfg->line_out_pins); |
| 3427 | cx_auto_update_speakers(codec); |
| 3428 | } |
| 3429 | |
| 3430 | static int cx_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 3431 | struct snd_ctl_elem_info *uinfo) |
| 3432 | { |
| 3433 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3434 | struct conexant_spec *spec = codec->spec; |
| 3435 | static const char * const texts2[] = { |
| 3436 | "Disabled", "Enabled" |
| 3437 | }; |
| 3438 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 3439 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3440 | }; |
| 3441 | const char * const *texts; |
| 3442 | |
| 3443 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3444 | uinfo->count = 1; |
| 3445 | if (spec->automute_hp_lo) { |
| 3446 | uinfo->value.enumerated.items = 3; |
| 3447 | texts = texts3; |
| 3448 | } else { |
| 3449 | uinfo->value.enumerated.items = 2; |
| 3450 | texts = texts2; |
| 3451 | } |
| 3452 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 3453 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
| 3454 | strcpy(uinfo->value.enumerated.name, |
| 3455 | texts[uinfo->value.enumerated.item]); |
| 3456 | return 0; |
| 3457 | } |
| 3458 | |
| 3459 | static int cx_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 3460 | struct snd_ctl_elem_value *ucontrol) |
| 3461 | { |
| 3462 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3463 | struct conexant_spec *spec = codec->spec; |
| 3464 | unsigned int val; |
| 3465 | if (!spec->auto_mute) |
| 3466 | val = 0; |
| 3467 | else if (!spec->automute_lines) |
| 3468 | val = 1; |
| 3469 | else |
| 3470 | val = 2; |
| 3471 | ucontrol->value.enumerated.item[0] = val; |
| 3472 | return 0; |
| 3473 | } |
| 3474 | |
| 3475 | static int cx_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 3476 | struct snd_ctl_elem_value *ucontrol) |
| 3477 | { |
| 3478 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3479 | struct conexant_spec *spec = codec->spec; |
| 3480 | |
| 3481 | switch (ucontrol->value.enumerated.item[0]) { |
| 3482 | case 0: |
| 3483 | if (!spec->auto_mute) |
| 3484 | return 0; |
| 3485 | spec->auto_mute = 0; |
| 3486 | break; |
| 3487 | case 1: |
| 3488 | if (spec->auto_mute && !spec->automute_lines) |
| 3489 | return 0; |
| 3490 | spec->auto_mute = 1; |
| 3491 | spec->automute_lines = 0; |
| 3492 | break; |
| 3493 | case 2: |
| 3494 | if (!spec->automute_hp_lo) |
| 3495 | return -EINVAL; |
| 3496 | if (spec->auto_mute && spec->automute_lines) |
| 3497 | return 0; |
| 3498 | spec->auto_mute = 1; |
| 3499 | spec->automute_lines = 1; |
| 3500 | break; |
| 3501 | default: |
| 3502 | return -EINVAL; |
| 3503 | } |
| 3504 | cx_auto_update_speakers(codec); |
| 3505 | return 1; |
| 3506 | } |
| 3507 | |
| 3508 | static const struct snd_kcontrol_new cx_automute_mode_enum[] = { |
| 3509 | { |
| 3510 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3511 | .name = "Auto-Mute Mode", |
| 3512 | .info = cx_automute_mode_info, |
| 3513 | .get = cx_automute_mode_get, |
| 3514 | .put = cx_automute_mode_put, |
| 3515 | }, |
| 3516 | { } |
| 3517 | }; |
| 3518 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3519 | static int cx_auto_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 3520 | struct snd_ctl_elem_info *uinfo) |
| 3521 | { |
| 3522 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3523 | struct conexant_spec *spec = codec->spec; |
| 3524 | |
| 3525 | return snd_hda_input_mux_info(&spec->private_imux, uinfo); |
| 3526 | } |
| 3527 | |
| 3528 | static int cx_auto_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 3529 | struct snd_ctl_elem_value *ucontrol) |
| 3530 | { |
| 3531 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3532 | struct conexant_spec *spec = codec->spec; |
| 3533 | |
| 3534 | ucontrol->value.enumerated.item[0] = spec->cur_mux[0]; |
| 3535 | return 0; |
| 3536 | } |
| 3537 | |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3538 | /* look for the route the given pin from mux and return the index; |
| 3539 | * if do_select is set, actually select the route. |
| 3540 | */ |
| 3541 | 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] | 3542 | hda_nid_t pin, hda_nid_t *srcp, |
| 3543 | bool do_select, int depth) |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3544 | { |
| 3545 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 3546 | int i, nums; |
| 3547 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3548 | switch (get_wcaps_type(get_wcaps(codec, mux))) { |
| 3549 | case AC_WID_AUD_IN: |
| 3550 | case AC_WID_AUD_SEL: |
| 3551 | case AC_WID_AUD_MIX: |
| 3552 | break; |
| 3553 | default: |
| 3554 | return -1; |
| 3555 | } |
| 3556 | |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3557 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 3558 | for (i = 0; i < nums; i++) |
| 3559 | if (conn[i] == pin) { |
| 3560 | if (do_select) |
| 3561 | snd_hda_codec_write(codec, mux, 0, |
| 3562 | AC_VERB_SET_CONNECT_SEL, i); |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3563 | if (srcp) |
| 3564 | *srcp = mux; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3565 | return i; |
| 3566 | } |
| 3567 | depth++; |
| 3568 | if (depth == 2) |
| 3569 | return -1; |
| 3570 | for (i = 0; i < nums; i++) { |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3571 | int ret = __select_input_connection(codec, conn[i], pin, srcp, |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3572 | do_select, depth); |
| 3573 | if (ret >= 0) { |
| 3574 | if (do_select) |
| 3575 | snd_hda_codec_write(codec, mux, 0, |
| 3576 | AC_VERB_SET_CONNECT_SEL, i); |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3577 | return i; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | return -1; |
| 3581 | } |
| 3582 | |
| 3583 | static void select_input_connection(struct hda_codec *codec, hda_nid_t mux, |
| 3584 | hda_nid_t pin) |
| 3585 | { |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3586 | __select_input_connection(codec, mux, pin, NULL, true, 0); |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3587 | } |
| 3588 | |
| 3589 | static int get_input_connection(struct hda_codec *codec, hda_nid_t mux, |
| 3590 | hda_nid_t pin) |
| 3591 | { |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 3592 | return __select_input_connection(codec, mux, pin, NULL, false, 0); |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3593 | } |
| 3594 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3595 | static int cx_auto_mux_enum_update(struct hda_codec *codec, |
| 3596 | const struct hda_input_mux *imux, |
| 3597 | unsigned int idx) |
| 3598 | { |
| 3599 | struct conexant_spec *spec = codec->spec; |
| 3600 | hda_nid_t adc; |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3601 | int changed = 1; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3602 | |
| 3603 | if (!imux->num_items) |
| 3604 | return 0; |
| 3605 | if (idx >= imux->num_items) |
| 3606 | idx = imux->num_items - 1; |
| 3607 | if (spec->cur_mux[0] == idx) |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3608 | changed = 0; |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3609 | adc = spec->imux_info[idx].adc; |
| 3610 | select_input_connection(codec, spec->imux_info[idx].adc, |
| 3611 | spec->imux_info[idx].pin); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3612 | if (spec->cur_adc && spec->cur_adc != adc) { |
| 3613 | /* stream is running, let's swap the current ADC */ |
| 3614 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 3615 | spec->cur_adc = adc; |
| 3616 | snd_hda_codec_setup_stream(codec, adc, |
| 3617 | spec->cur_adc_stream_tag, 0, |
| 3618 | spec->cur_adc_format); |
| 3619 | } |
| 3620 | spec->cur_mux[0] = idx; |
Takashi Iwai | 313d2c0 | 2011-05-23 20:27:02 +0200 | [diff] [blame] | 3621 | return changed; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3622 | } |
| 3623 | |
| 3624 | static int cx_auto_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 3625 | struct snd_ctl_elem_value *ucontrol) |
| 3626 | { |
| 3627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3628 | struct conexant_spec *spec = codec->spec; |
| 3629 | |
| 3630 | return cx_auto_mux_enum_update(codec, &spec->private_imux, |
| 3631 | ucontrol->value.enumerated.item[0]); |
| 3632 | } |
| 3633 | |
| 3634 | static const struct snd_kcontrol_new cx_auto_capture_mixers[] = { |
| 3635 | { |
| 3636 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3637 | .name = "Capture Source", |
| 3638 | .info = cx_auto_mux_enum_info, |
| 3639 | .get = cx_auto_mux_enum_get, |
| 3640 | .put = cx_auto_mux_enum_put |
| 3641 | }, |
| 3642 | {} |
| 3643 | }; |
| 3644 | |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3645 | static bool select_automic(struct hda_codec *codec, int idx, bool detect) |
| 3646 | { |
| 3647 | struct conexant_spec *spec = codec->spec; |
| 3648 | if (idx < 0) |
| 3649 | return false; |
| 3650 | if (detect && !snd_hda_jack_detect(codec, spec->imux_info[idx].pin)) |
| 3651 | return false; |
| 3652 | cx_auto_mux_enum_update(codec, &spec->private_imux, idx); |
| 3653 | return true; |
| 3654 | } |
| 3655 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3656 | /* automatic switch internal and external mic */ |
| 3657 | static void cx_auto_automic(struct hda_codec *codec) |
| 3658 | { |
| 3659 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3660 | |
| 3661 | if (!spec->auto_mic) |
| 3662 | return; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3663 | if (!select_automic(codec, spec->auto_mic_ext, true)) |
| 3664 | if (!select_automic(codec, spec->auto_mic_dock, true)) |
| 3665 | select_automic(codec, spec->auto_mic_int, false); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3666 | } |
| 3667 | |
| 3668 | static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) |
| 3669 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 3670 | switch (snd_hda_jack_get_action(codec, res >> 26)) { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3671 | case CONEXANT_HP_EVENT: |
| 3672 | cx_auto_hp_automute(codec); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3673 | break; |
| 3674 | case CONEXANT_LINE_EVENT: |
| 3675 | cx_auto_line_automute(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3676 | break; |
| 3677 | case CONEXANT_MIC_EVENT: |
| 3678 | cx_auto_automic(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3679 | break; |
| 3680 | } |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 3681 | snd_hda_jack_report_sync(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3682 | } |
| 3683 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3684 | /* check whether the pin config is suitable for auto-mic switching; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3685 | * auto-mic is enabled only when one int-mic and one ext- and/or |
| 3686 | * one dock-mic exist |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3687 | */ |
| 3688 | static void cx_auto_check_auto_mic(struct hda_codec *codec) |
| 3689 | { |
| 3690 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3691 | int pset[INPUT_PIN_ATTR_NORMAL + 1]; |
| 3692 | int i; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3693 | |
Takashi Iwai | 506a419 | 2011-05-23 20:07:15 +0200 | [diff] [blame] | 3694 | for (i = 0; i < ARRAY_SIZE(pset); i++) |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3695 | pset[i] = -1; |
| 3696 | for (i = 0; i < spec->private_imux.num_items; i++) { |
| 3697 | hda_nid_t pin = spec->imux_info[i].pin; |
| 3698 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3699 | int type, attr; |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3700 | attr = snd_hda_get_input_pin_attr(def_conf); |
| 3701 | if (attr == INPUT_PIN_ATTR_UNUSED) |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3702 | return; /* invalid entry */ |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3703 | if (attr > INPUT_PIN_ATTR_NORMAL) |
| 3704 | attr = INPUT_PIN_ATTR_NORMAL; |
| 3705 | if (attr != INPUT_PIN_ATTR_INT && |
| 3706 | !is_jack_detectable(codec, pin)) |
Takashi Iwai | b55fcb5 | 2011-05-17 12:57:46 +0200 | [diff] [blame] | 3707 | return; /* non-detectable pin */ |
| 3708 | type = get_defcfg_device(def_conf); |
| 3709 | if (type != AC_JACK_MIC_IN && |
| 3710 | (attr != INPUT_PIN_ATTR_DOCK || type != AC_JACK_LINE_IN)) |
| 3711 | return; /* no valid input type */ |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3712 | if (pset[attr] >= 0) |
| 3713 | return; /* already occupied */ |
| 3714 | pset[attr] = i; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3715 | } |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3716 | if (pset[INPUT_PIN_ATTR_INT] < 0 || |
| 3717 | (pset[INPUT_PIN_ATTR_NORMAL] < 0 && pset[INPUT_PIN_ATTR_DOCK])) |
| 3718 | return; /* no input to switch*/ |
| 3719 | spec->auto_mic = 1; |
| 3720 | spec->auto_mic_ext = pset[INPUT_PIN_ATTR_NORMAL]; |
| 3721 | spec->auto_mic_dock = pset[INPUT_PIN_ATTR_DOCK]; |
| 3722 | spec->auto_mic_int = pset[INPUT_PIN_ATTR_INT]; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3723 | } |
| 3724 | |
| 3725 | static void cx_auto_parse_input(struct hda_codec *codec) |
| 3726 | { |
| 3727 | struct conexant_spec *spec = codec->spec; |
| 3728 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3729 | struct hda_input_mux *imux; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3730 | int i, j; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3731 | |
| 3732 | imux = &spec->private_imux; |
| 3733 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3734 | for (j = 0; j < spec->num_adc_nids; j++) { |
| 3735 | hda_nid_t adc = spec->adc_nids[j]; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 3736 | int idx = get_input_connection(codec, adc, |
| 3737 | cfg->inputs[i].pin); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3738 | if (idx >= 0) { |
| 3739 | const char *label; |
| 3740 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3741 | spec->imux_info[imux->num_items].index = i; |
| 3742 | spec->imux_info[imux->num_items].boost = 0; |
| 3743 | spec->imux_info[imux->num_items].adc = adc; |
| 3744 | spec->imux_info[imux->num_items].pin = |
Takashi Iwai | f6100bb | 2011-05-13 18:26:39 +0200 | [diff] [blame] | 3745 | cfg->inputs[i].pin; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3746 | snd_hda_add_imux_item(imux, label, idx, NULL); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3747 | break; |
| 3748 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3749 | } |
| 3750 | } |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 3751 | if (imux->num_items >= 2 && cfg->num_inputs == imux->num_items) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3752 | cx_auto_check_auto_mic(codec); |
Takashi Iwai | 7675535 | 2011-08-24 10:53:10 +0200 | [diff] [blame] | 3753 | if (imux->num_items > 1) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3754 | for (i = 1; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 3755 | if (spec->imux_info[i].adc != spec->imux_info[0].adc) { |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 3756 | spec->adc_switching = 1; |
| 3757 | break; |
| 3758 | } |
| 3759 | } |
| 3760 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3761 | } |
| 3762 | |
| 3763 | /* get digital-input audio widget corresponding to the given pin */ |
| 3764 | static hda_nid_t cx_auto_get_dig_in(struct hda_codec *codec, hda_nid_t pin) |
| 3765 | { |
| 3766 | hda_nid_t nid, end_nid; |
| 3767 | |
| 3768 | end_nid = codec->start_nid + codec->num_nodes; |
| 3769 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3770 | unsigned int wcaps = get_wcaps(codec, nid); |
| 3771 | unsigned int type = get_wcaps_type(wcaps); |
| 3772 | if (type == AC_WID_AUD_IN && (wcaps & AC_WCAP_DIGITAL)) { |
| 3773 | if (get_connection_index(codec, nid, pin) >= 0) |
| 3774 | return nid; |
| 3775 | } |
| 3776 | } |
| 3777 | return 0; |
| 3778 | } |
| 3779 | |
| 3780 | static void cx_auto_parse_digital(struct hda_codec *codec) |
| 3781 | { |
| 3782 | struct conexant_spec *spec = codec->spec; |
| 3783 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3784 | hda_nid_t nid; |
| 3785 | |
| 3786 | if (cfg->dig_outs && |
| 3787 | snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) == 1) |
| 3788 | spec->multiout.dig_out_nid = nid; |
| 3789 | if (cfg->dig_in_pin) |
| 3790 | spec->dig_in_nid = cx_auto_get_dig_in(codec, cfg->dig_in_pin); |
| 3791 | } |
| 3792 | |
| 3793 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3794 | static void cx_auto_parse_beep(struct hda_codec *codec) |
| 3795 | { |
| 3796 | struct conexant_spec *spec = codec->spec; |
| 3797 | hda_nid_t nid, end_nid; |
| 3798 | |
| 3799 | end_nid = codec->start_nid + codec->num_nodes; |
| 3800 | for (nid = codec->start_nid; nid < end_nid; nid++) |
| 3801 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { |
| 3802 | set_beep_amp(spec, nid, 0, HDA_OUTPUT); |
| 3803 | break; |
| 3804 | } |
| 3805 | } |
| 3806 | #else |
| 3807 | #define cx_auto_parse_beep(codec) |
| 3808 | #endif |
| 3809 | |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3810 | /* parse EAPDs */ |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3811 | static void cx_auto_parse_eapd(struct hda_codec *codec) |
| 3812 | { |
| 3813 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3814 | hda_nid_t nid, end_nid; |
| 3815 | |
| 3816 | end_nid = codec->start_nid + codec->num_nodes; |
| 3817 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 3818 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 3819 | continue; |
| 3820 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) |
| 3821 | continue; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3822 | spec->eapds[spec->num_eapds++] = nid; |
| 3823 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) |
| 3824 | break; |
| 3825 | } |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3826 | |
| 3827 | /* NOTE: below is a wild guess; if we have more than two EAPDs, |
| 3828 | * it's a new chip, where EAPDs are supposed to be associated to |
| 3829 | * pins, and we can control EAPD per pin. |
| 3830 | * OTOH, if only one or two EAPDs are found, it's an old chip, |
| 3831 | * thus it might control over all pins. |
| 3832 | */ |
| 3833 | spec->pin_eapd_ctrls = spec->num_eapds > 2; |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3834 | } |
| 3835 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3836 | static int cx_auto_parse_auto_config(struct hda_codec *codec) |
| 3837 | { |
| 3838 | struct conexant_spec *spec = codec->spec; |
| 3839 | int err; |
| 3840 | |
| 3841 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
| 3842 | if (err < 0) |
| 3843 | return err; |
| 3844 | |
| 3845 | cx_auto_parse_output(codec); |
| 3846 | cx_auto_parse_input(codec); |
| 3847 | cx_auto_parse_digital(codec); |
| 3848 | cx_auto_parse_beep(codec); |
Takashi Iwai | 1911059 | 2011-07-11 14:46:44 +0200 | [diff] [blame] | 3849 | cx_auto_parse_eapd(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3850 | return 0; |
| 3851 | } |
| 3852 | |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3853 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, |
| 3854 | hda_nid_t *pins, bool on) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3855 | { |
| 3856 | int i; |
| 3857 | for (i = 0; i < num_pins; i++) { |
| 3858 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) |
| 3859 | snd_hda_codec_write(codec, pins[i], 0, |
Takashi Iwai | da33986 | 2011-05-13 16:24:15 +0200 | [diff] [blame] | 3860 | AC_VERB_SET_EAPD_BTLENABLE, |
| 3861 | on ? 0x02 : 0); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3862 | } |
| 3863 | } |
| 3864 | |
| 3865 | static void select_connection(struct hda_codec *codec, hda_nid_t pin, |
| 3866 | hda_nid_t src) |
| 3867 | { |
| 3868 | int idx = get_connection_index(codec, pin, src); |
| 3869 | if (idx >= 0) |
| 3870 | snd_hda_codec_write(codec, pin, 0, |
| 3871 | AC_VERB_SET_CONNECT_SEL, idx); |
| 3872 | } |
| 3873 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3874 | static void mute_outputs(struct hda_codec *codec, int num_nids, |
| 3875 | const hda_nid_t *nids) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3876 | { |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3877 | int i, val; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3878 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3879 | for (i = 0; i < num_nids; i++) { |
| 3880 | hda_nid_t nid = nids[i]; |
| 3881 | if (!(get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
| 3882 | continue; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 3883 | if (query_amp_caps(codec, nid, HDA_OUTPUT) & AC_AMPCAP_MUTE) |
| 3884 | val = AMP_OUT_MUTE; |
| 3885 | else |
| 3886 | val = AMP_OUT_ZERO; |
| 3887 | snd_hda_codec_write(codec, nid, 0, |
| 3888 | AC_VERB_SET_AMP_GAIN_MUTE, val); |
| 3889 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3890 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3891 | |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3892 | static void enable_unsol_pins(struct hda_codec *codec, int num_pins, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 3893 | hda_nid_t *pins, unsigned int action) |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3894 | { |
| 3895 | int i; |
| 3896 | for (i = 0; i < num_pins; i++) |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 3897 | snd_hda_jack_detect_enable(codec, pins[i], action); |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3898 | } |
| 3899 | |
Takashi Iwai | 07cafff | 2012-02-20 12:30:59 +0100 | [diff] [blame] | 3900 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 3901 | { |
| 3902 | int i; |
| 3903 | for (i = 0; i < nums; i++) |
| 3904 | if (list[i] == nid) |
| 3905 | return true; |
| 3906 | return false; |
| 3907 | } |
| 3908 | |
| 3909 | /* is the given NID found in any of autocfg items? */ |
| 3910 | static bool found_in_autocfg(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3911 | { |
| 3912 | int i; |
| 3913 | |
| 3914 | if (found_in_nid_list(nid, cfg->line_out_pins, cfg->line_outs) || |
| 3915 | found_in_nid_list(nid, cfg->hp_pins, cfg->hp_outs) || |
| 3916 | found_in_nid_list(nid, cfg->speaker_pins, cfg->speaker_outs) || |
| 3917 | found_in_nid_list(nid, cfg->dig_out_pins, cfg->dig_outs)) |
| 3918 | return true; |
| 3919 | for (i = 0; i < cfg->num_inputs; i++) |
| 3920 | if (cfg->inputs[i].pin == nid) |
| 3921 | return true; |
| 3922 | if (cfg->dig_in_pin == nid) |
| 3923 | return true; |
| 3924 | return false; |
| 3925 | } |
| 3926 | |
| 3927 | /* clear unsol-event tags on unused pins; Conexant codecs seem to leave |
| 3928 | * invalid unsol tags by some reason |
| 3929 | */ |
| 3930 | static void clear_unsol_on_unused_pins(struct hda_codec *codec) |
| 3931 | { |
| 3932 | struct conexant_spec *spec = codec->spec; |
| 3933 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3934 | int i; |
| 3935 | |
| 3936 | for (i = 0; i < codec->init_pins.used; i++) { |
| 3937 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
| 3938 | if (!found_in_autocfg(cfg, pin->nid)) |
| 3939 | snd_hda_codec_write(codec, pin->nid, 0, |
| 3940 | AC_VERB_SET_UNSOLICITED_ENABLE, 0); |
| 3941 | } |
| 3942 | } |
| 3943 | |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 3944 | /* turn on/off EAPD according to Master switch */ |
| 3945 | static void cx_auto_vmaster_hook(void *private_data, int enabled) |
| 3946 | { |
| 3947 | struct hda_codec *codec = private_data; |
| 3948 | struct conexant_spec *spec = codec->spec; |
| 3949 | |
| 3950 | if (enabled && spec->pin_eapd_ctrls) { |
| 3951 | cx_auto_update_speakers(codec); |
| 3952 | return; |
| 3953 | } |
| 3954 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); |
| 3955 | } |
| 3956 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3957 | static void cx_auto_init_output(struct hda_codec *codec) |
| 3958 | { |
| 3959 | struct conexant_spec *spec = codec->spec; |
| 3960 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3961 | hda_nid_t nid; |
| 3962 | int i; |
| 3963 | |
| 3964 | mute_outputs(codec, spec->multiout.num_dacs, spec->multiout.dac_nids); |
Takashi Iwai | ca3649d | 2012-04-19 15:15:25 +0200 | [diff] [blame] | 3965 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3966 | unsigned int val = PIN_OUT; |
| 3967 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & |
| 3968 | AC_PINCAP_HP_DRV) |
| 3969 | val |= AC_PINCTL_HP_EN; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3970 | snd_hda_set_pin_ctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | ca3649d | 2012-04-19 15:15:25 +0200 | [diff] [blame] | 3971 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 3972 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); |
| 3973 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); |
| 3974 | mute_outputs(codec, cfg->speaker_outs, cfg->speaker_pins); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3975 | for (i = 0; i < spec->dac_info_filled; i++) { |
| 3976 | nid = spec->dac_info[i].dac; |
| 3977 | if (!nid) |
| 3978 | nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 3979 | else if (nid & DAC_SLAVE_FLAG) |
| 3980 | nid &= ~DAC_SLAVE_FLAG; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 3981 | select_connection(codec, spec->dac_info[i].pin, nid); |
| 3982 | } |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 3983 | if (spec->auto_mute) { |
| 3984 | enable_unsol_pins(codec, cfg->hp_outs, cfg->hp_pins, |
| 3985 | CONEXANT_HP_EVENT); |
| 3986 | spec->hp_present = detect_jacks(codec, cfg->hp_outs, |
| 3987 | cfg->hp_pins); |
| 3988 | if (spec->detect_line) { |
| 3989 | enable_unsol_pins(codec, cfg->line_outs, |
| 3990 | cfg->line_out_pins, |
| 3991 | CONEXANT_LINE_EVENT); |
| 3992 | spec->line_present = |
| 3993 | detect_jacks(codec, cfg->line_outs, |
| 3994 | cfg->line_out_pins); |
| 3995 | } |
| 3996 | } |
| 3997 | cx_auto_update_speakers(codec); |
Takashi Iwai | 254f296 | 2011-10-14 15:22:34 +0200 | [diff] [blame] | 3998 | /* turn on all EAPDs if no individual EAPD control is available */ |
| 3999 | if (!spec->pin_eapd_ctrls) |
| 4000 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); |
Takashi Iwai | 07cafff | 2012-02-20 12:30:59 +0100 | [diff] [blame] | 4001 | clear_unsol_on_unused_pins(codec); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4002 | } |
| 4003 | |
| 4004 | static void cx_auto_init_input(struct hda_codec *codec) |
| 4005 | { |
| 4006 | struct conexant_spec *spec = codec->spec; |
| 4007 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 4008 | int i, val; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4009 | |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 4010 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 4011 | hda_nid_t nid = spec->adc_nids[i]; |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4012 | if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) |
| 4013 | continue; |
Takashi Iwai | 0ad1b5b | 2011-05-13 16:43:12 +0200 | [diff] [blame] | 4014 | if (query_amp_caps(codec, nid, HDA_INPUT) & AC_AMPCAP_MUTE) |
| 4015 | val = AMP_IN_MUTE(0); |
| 4016 | else |
| 4017 | val = AMP_IN_UNMUTE(0); |
| 4018 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 4019 | val); |
| 4020 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4021 | |
| 4022 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame^] | 4023 | hda_nid_t pin = cfg->inputs[i].pin; |
| 4024 | unsigned int type = PIN_IN; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4025 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame^] | 4026 | type |= snd_hda_get_default_vref(codec, pin); |
| 4027 | snd_hda_set_pin_ctl(codec, pin, type); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4028 | } |
| 4029 | |
| 4030 | if (spec->auto_mic) { |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4031 | if (spec->auto_mic_ext >= 0) { |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 4032 | snd_hda_jack_detect_enable(codec, |
| 4033 | cfg->inputs[spec->auto_mic_ext].pin, |
| 4034 | CONEXANT_MIC_EVENT); |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4035 | } |
| 4036 | if (spec->auto_mic_dock >= 0) { |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 4037 | snd_hda_jack_detect_enable(codec, |
| 4038 | cfg->inputs[spec->auto_mic_dock].pin, |
| 4039 | CONEXANT_MIC_EVENT); |
Takashi Iwai | 43c1b2e | 2011-05-17 10:35:15 +0200 | [diff] [blame] | 4040 | } |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4041 | cx_auto_automic(codec); |
| 4042 | } else { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4043 | select_input_connection(codec, spec->imux_info[0].adc, |
| 4044 | spec->imux_info[0].pin); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4045 | } |
| 4046 | } |
| 4047 | |
| 4048 | static void cx_auto_init_digital(struct hda_codec *codec) |
| 4049 | { |
| 4050 | struct conexant_spec *spec = codec->spec; |
| 4051 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4052 | |
| 4053 | if (spec->multiout.dig_out_nid) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4054 | snd_hda_set_pin_ctl(codec, cfg->dig_out_pins[0], PIN_OUT); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4055 | if (spec->dig_in_nid) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4056 | snd_hda_set_pin_ctl(codec, cfg->dig_in_pin, PIN_IN); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4057 | } |
| 4058 | |
| 4059 | static int cx_auto_init(struct hda_codec *codec) |
| 4060 | { |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4061 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4062 | /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/ |
| 4063 | cx_auto_init_output(codec); |
| 4064 | cx_auto_init_input(codec); |
| 4065 | cx_auto_init_digital(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 4066 | snd_hda_jack_report_sync(codec); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 4067 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4068 | return 0; |
| 4069 | } |
| 4070 | |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4071 | 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] | 4072 | const char *dir, int cidx, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4073 | hda_nid_t nid, int hda_dir, int amp_idx, int chs) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4074 | { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4075 | static char name[44]; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4076 | static struct snd_kcontrol_new knew[] = { |
| 4077 | HDA_CODEC_VOLUME(name, 0, 0, 0), |
| 4078 | HDA_CODEC_MUTE(name, 0, 0, 0), |
| 4079 | }; |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4080 | static const char * const sfx[2] = { "Volume", "Switch" }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4081 | int i, err; |
| 4082 | |
| 4083 | for (i = 0; i < 2; i++) { |
| 4084 | struct snd_kcontrol *kctl; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4085 | knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, chs, amp_idx, |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4086 | hda_dir); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4087 | knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; |
| 4088 | knew[i].index = cidx; |
| 4089 | snprintf(name, sizeof(name), "%s%s %s", basename, dir, sfx[i]); |
| 4090 | kctl = snd_ctl_new1(&knew[i], codec); |
| 4091 | if (!kctl) |
| 4092 | return -ENOMEM; |
| 4093 | err = snd_hda_ctl_add(codec, nid, kctl); |
| 4094 | if (err < 0) |
| 4095 | return err; |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4096 | if (!(query_amp_caps(codec, nid, hda_dir) & |
| 4097 | (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))) |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4098 | break; |
| 4099 | } |
| 4100 | return 0; |
| 4101 | } |
| 4102 | |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4103 | #define cx_auto_add_volume(codec, str, dir, cidx, nid, hda_dir) \ |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4104 | 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] | 4105 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4106 | #define cx_auto_add_pb_volume(codec, nid, str, idx) \ |
| 4107 | cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) |
| 4108 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4109 | static int try_add_pb_volume(struct hda_codec *codec, hda_nid_t dac, |
| 4110 | hda_nid_t pin, const char *name, int idx) |
| 4111 | { |
| 4112 | unsigned int caps; |
David Henningsson | 468c545 | 2011-08-25 13:16:02 +0200 | [diff] [blame] | 4113 | if (dac && !(dac & DAC_SLAVE_FLAG)) { |
| 4114 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); |
| 4115 | if (caps & AC_AMPCAP_NUM_STEPS) |
| 4116 | return cx_auto_add_pb_volume(codec, dac, name, idx); |
| 4117 | } |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4118 | caps = query_amp_caps(codec, pin, HDA_OUTPUT); |
| 4119 | if (caps & AC_AMPCAP_NUM_STEPS) |
| 4120 | return cx_auto_add_pb_volume(codec, pin, name, idx); |
| 4121 | return 0; |
| 4122 | } |
| 4123 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4124 | static int cx_auto_build_output_controls(struct hda_codec *codec) |
| 4125 | { |
| 4126 | struct conexant_spec *spec = codec->spec; |
| 4127 | int i, err; |
| 4128 | int num_line = 0, num_hp = 0, num_spk = 0; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4129 | static const char * const texts[3] = { "Front", "Surround", "CLFE" }; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4130 | |
| 4131 | if (spec->dac_info_filled == 1) |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4132 | return try_add_pb_volume(codec, spec->dac_info[0].dac, |
| 4133 | spec->dac_info[0].pin, |
| 4134 | "Master", 0); |
| 4135 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4136 | for (i = 0; i < spec->dac_info_filled; i++) { |
| 4137 | const char *label; |
| 4138 | int idx, type; |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 4139 | hda_nid_t dac = spec->dac_info[i].dac; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4140 | type = spec->dac_info[i].type; |
| 4141 | if (type == AUTO_PIN_LINE_OUT) |
| 4142 | type = spec->autocfg.line_out_type; |
| 4143 | switch (type) { |
| 4144 | case AUTO_PIN_LINE_OUT: |
| 4145 | default: |
| 4146 | label = texts[num_line++]; |
| 4147 | idx = 0; |
| 4148 | break; |
| 4149 | case AUTO_PIN_HP_OUT: |
| 4150 | label = "Headphone"; |
| 4151 | idx = num_hp++; |
| 4152 | break; |
| 4153 | case AUTO_PIN_SPEAKER_OUT: |
| 4154 | label = "Speaker"; |
| 4155 | idx = num_spk++; |
| 4156 | break; |
| 4157 | } |
Takashi Iwai | 1f015f5 | 2011-08-23 14:57:08 +0200 | [diff] [blame] | 4158 | err = try_add_pb_volume(codec, dac, |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4159 | spec->dac_info[i].pin, |
| 4160 | label, idx); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4161 | if (err < 0) |
| 4162 | return err; |
| 4163 | } |
Takashi Iwai | 03697e2 | 2011-05-17 09:53:31 +0200 | [diff] [blame] | 4164 | |
| 4165 | if (spec->auto_mute) { |
| 4166 | err = snd_hda_add_new_ctls(codec, cx_automute_mode_enum); |
| 4167 | if (err < 0) |
| 4168 | return err; |
| 4169 | } |
| 4170 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4171 | return 0; |
| 4172 | } |
| 4173 | |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4174 | /* Returns zero if this is a normal stereo channel, and non-zero if it should |
| 4175 | be split in two independent channels. |
| 4176 | dest_label must be at least 44 characters. */ |
| 4177 | static int cx_auto_get_rightch_label(struct hda_codec *codec, const char *label, |
| 4178 | char *dest_label, int nid) |
| 4179 | { |
| 4180 | struct conexant_spec *spec = codec->spec; |
| 4181 | int i; |
| 4182 | |
| 4183 | if (!spec->fixup_stereo_dmic) |
| 4184 | return 0; |
| 4185 | |
| 4186 | for (i = 0; i < AUTO_CFG_MAX_INS; i++) { |
| 4187 | int def_conf; |
| 4188 | if (spec->autocfg.inputs[i].pin != nid) |
| 4189 | continue; |
| 4190 | |
| 4191 | if (spec->autocfg.inputs[i].type != AUTO_PIN_MIC) |
| 4192 | return 0; |
| 4193 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4194 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) |
| 4195 | return 0; |
| 4196 | |
| 4197 | /* Finally found the inverted internal mic! */ |
| 4198 | snprintf(dest_label, 44, "Inverted %s", label); |
| 4199 | return 1; |
| 4200 | } |
| 4201 | return 0; |
| 4202 | } |
| 4203 | |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4204 | static int cx_auto_add_capture_volume(struct hda_codec *codec, hda_nid_t nid, |
| 4205 | const char *label, const char *pfx, |
| 4206 | int cidx) |
| 4207 | { |
| 4208 | struct conexant_spec *spec = codec->spec; |
| 4209 | int i; |
| 4210 | |
| 4211 | for (i = 0; i < spec->num_adc_nids; i++) { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4212 | char rightch_label[44]; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4213 | hda_nid_t adc_nid = spec->adc_nids[i]; |
Takashi Iwai | 5c9887e | 2011-05-13 18:36:37 +0200 | [diff] [blame] | 4214 | int idx = get_input_connection(codec, adc_nid, nid); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4215 | if (idx < 0) |
| 4216 | continue; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4217 | if (codec->single_adc_amp) |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4218 | idx = 0; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4219 | |
| 4220 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { |
| 4221 | /* Make two independent kcontrols for left and right */ |
| 4222 | int err = cx_auto_add_volume_idx(codec, label, pfx, |
| 4223 | cidx, adc_nid, HDA_INPUT, idx, 1); |
| 4224 | if (err < 0) |
| 4225 | return err; |
| 4226 | return cx_auto_add_volume_idx(codec, rightch_label, pfx, |
| 4227 | cidx, adc_nid, HDA_INPUT, idx, 2); |
| 4228 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4229 | return cx_auto_add_volume_idx(codec, label, pfx, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4230 | cidx, adc_nid, HDA_INPUT, idx, 3); |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4231 | } |
| 4232 | return 0; |
| 4233 | } |
| 4234 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4235 | static int cx_auto_add_boost_volume(struct hda_codec *codec, int idx, |
| 4236 | const char *label, int cidx) |
| 4237 | { |
| 4238 | struct conexant_spec *spec = codec->spec; |
| 4239 | hda_nid_t mux, nid; |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4240 | int i, con; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4241 | |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4242 | nid = spec->imux_info[idx].pin; |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4243 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4244 | char rightch_label[44]; |
| 4245 | if (cx_auto_get_rightch_label(codec, label, rightch_label, nid)) { |
| 4246 | int err = cx_auto_add_volume_idx(codec, label, " Boost", |
| 4247 | cidx, nid, HDA_INPUT, 0, 1); |
| 4248 | if (err < 0) |
| 4249 | return err; |
| 4250 | return cx_auto_add_volume_idx(codec, rightch_label, " Boost", |
| 4251 | cidx, nid, HDA_INPUT, 0, 2); |
| 4252 | } |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4253 | return cx_auto_add_volume(codec, label, " Boost", cidx, |
| 4254 | nid, HDA_INPUT); |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4255 | } |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4256 | con = __select_input_connection(codec, spec->imux_info[idx].adc, nid, |
| 4257 | &mux, false, 0); |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4258 | if (con < 0) |
| 4259 | return 0; |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4260 | for (i = 0; i < idx; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4261 | if (spec->imux_info[i].boost == mux) |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4262 | return 0; /* already present */ |
| 4263 | } |
| 4264 | |
| 4265 | if (get_wcaps(codec, mux) & AC_WCAP_OUT_AMP) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4266 | spec->imux_info[idx].boost = mux; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4267 | return cx_auto_add_volume(codec, label, " Boost", 0, |
| 4268 | mux, HDA_OUTPUT); |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4269 | } |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4270 | return 0; |
| 4271 | } |
| 4272 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4273 | static int cx_auto_build_input_controls(struct hda_codec *codec) |
| 4274 | { |
| 4275 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4276 | struct hda_input_mux *imux = &spec->private_imux; |
| 4277 | const char *prev_label; |
| 4278 | int input_conn[HDA_MAX_NUM_INPUTS]; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4279 | int i, j, err, cidx; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4280 | int multi_connection; |
| 4281 | |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4282 | if (!imux->num_items) |
| 4283 | return 0; |
| 4284 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4285 | multi_connection = 0; |
| 4286 | for (i = 0; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4287 | cidx = get_input_connection(codec, spec->imux_info[i].adc, |
| 4288 | spec->imux_info[i].pin); |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4289 | if (cidx < 0) |
| 4290 | continue; |
| 4291 | input_conn[i] = spec->imux_info[i].adc; |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4292 | if (!codec->single_adc_amp) |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4293 | input_conn[i] |= cidx << 8; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4294 | if (i > 0 && input_conn[i] != input_conn[0]) |
| 4295 | multi_connection = 1; |
| 4296 | } |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4297 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4298 | prev_label = NULL; |
| 4299 | cidx = 0; |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4300 | for (i = 0; i < imux->num_items; i++) { |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4301 | hda_nid_t nid = spec->imux_info[i].pin; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4302 | const char *label; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4303 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4304 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, |
Takashi Iwai | 47ad1f4 | 2011-05-17 09:15:55 +0200 | [diff] [blame] | 4305 | spec->imux_info[i].index); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4306 | if (label == prev_label) |
| 4307 | cidx++; |
| 4308 | else |
| 4309 | cidx = 0; |
| 4310 | prev_label = label; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4311 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4312 | err = cx_auto_add_boost_volume(codec, i, label, cidx); |
| 4313 | if (err < 0) |
| 4314 | return err; |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4315 | |
Takashi Iwai | cf27f29 | 2011-05-16 11:33:02 +0200 | [diff] [blame] | 4316 | if (!multi_connection) { |
Takashi Iwai | f975930 | 2011-05-16 11:45:15 +0200 | [diff] [blame] | 4317 | if (i > 0) |
| 4318 | continue; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4319 | err = cx_auto_add_capture_volume(codec, nid, |
| 4320 | "Capture", "", cidx); |
| 4321 | } else { |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4322 | bool dup_found = false; |
| 4323 | for (j = 0; j < i; j++) { |
| 4324 | if (input_conn[j] == input_conn[i]) { |
| 4325 | dup_found = true; |
| 4326 | break; |
| 4327 | } |
| 4328 | } |
| 4329 | if (dup_found) |
| 4330 | continue; |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4331 | err = cx_auto_add_capture_volume(codec, nid, |
| 4332 | label, " Capture", cidx); |
David Henningsson | 983345e | 2011-02-15 19:57:09 +0100 | [diff] [blame] | 4333 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4334 | if (err < 0) |
| 4335 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4336 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4337 | |
| 4338 | if (spec->private_imux.num_items > 1 && !spec->auto_mic) { |
| 4339 | err = snd_hda_add_new_ctls(codec, cx_auto_capture_mixers); |
| 4340 | if (err < 0) |
| 4341 | return err; |
| 4342 | } |
| 4343 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4344 | return 0; |
| 4345 | } |
| 4346 | |
| 4347 | static int cx_auto_build_controls(struct hda_codec *codec) |
| 4348 | { |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4349 | struct conexant_spec *spec = codec->spec; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4350 | int err; |
| 4351 | |
| 4352 | err = cx_auto_build_output_controls(codec); |
| 4353 | if (err < 0) |
| 4354 | return err; |
| 4355 | err = cx_auto_build_input_controls(codec); |
| 4356 | if (err < 0) |
| 4357 | return err; |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4358 | err = conexant_build_controls(codec); |
| 4359 | if (err < 0) |
| 4360 | return err; |
| 4361 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 4362 | if (err < 0) |
| 4363 | return err; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4364 | if (spec->vmaster_mute.sw_kctl) { |
| 4365 | spec->vmaster_mute.hook = cx_auto_vmaster_hook; |
| 4366 | err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, |
| 4367 | spec->vmaster_mute_led); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 4368 | if (err < 0) |
| 4369 | return err; |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4370 | } |
Takashi Iwai | 31ef225 | 2011-12-01 17:41:36 +0100 | [diff] [blame] | 4371 | return 0; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4372 | } |
| 4373 | |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 4374 | static int cx_auto_search_adcs(struct hda_codec *codec) |
| 4375 | { |
| 4376 | struct conexant_spec *spec = codec->spec; |
| 4377 | hda_nid_t nid, end_nid; |
| 4378 | |
| 4379 | end_nid = codec->start_nid + codec->num_nodes; |
| 4380 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 4381 | unsigned int caps = get_wcaps(codec, nid); |
| 4382 | if (get_wcaps_type(caps) != AC_WID_AUD_IN) |
| 4383 | continue; |
| 4384 | if (caps & AC_WCAP_DIGITAL) |
| 4385 | continue; |
| 4386 | if (snd_BUG_ON(spec->num_adc_nids >= |
| 4387 | ARRAY_SIZE(spec->private_adc_nids))) |
| 4388 | break; |
| 4389 | spec->private_adc_nids[spec->num_adc_nids++] = nid; |
| 4390 | } |
| 4391 | spec->adc_nids = spec->private_adc_nids; |
| 4392 | return 0; |
| 4393 | } |
| 4394 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4395 | static const struct hda_codec_ops cx_auto_patch_ops = { |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4396 | .build_controls = cx_auto_build_controls, |
| 4397 | .build_pcms = conexant_build_pcms, |
| 4398 | .init = cx_auto_init, |
| 4399 | .free = conexant_free, |
| 4400 | .unsol_event = cx_auto_unsol_event, |
| 4401 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4402 | .suspend = conexant_suspend, |
| 4403 | #endif |
| 4404 | .reboot_notify = snd_hda_shutup_pins, |
| 4405 | }; |
| 4406 | |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4407 | /* |
| 4408 | * pin fix-up |
| 4409 | */ |
| 4410 | struct cxt_pincfg { |
| 4411 | hda_nid_t nid; |
| 4412 | u32 val; |
| 4413 | }; |
| 4414 | |
| 4415 | static void apply_pincfg(struct hda_codec *codec, const struct cxt_pincfg *cfg) |
| 4416 | { |
| 4417 | for (; cfg->nid; cfg++) |
| 4418 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); |
| 4419 | |
| 4420 | } |
| 4421 | |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4422 | enum { |
| 4423 | CXT_PINCFG_LENOVO_X200, |
Takashi Iwai | d398011 | 2012-04-19 17:17:59 +0200 | [diff] [blame] | 4424 | CXT_PINCFG_LENOVO_TP410, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4425 | CXT_FIXUP_STEREO_DMIC, |
| 4426 | }; |
| 4427 | |
| 4428 | static void apply_fixup(struct hda_codec *codec, |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4429 | const struct snd_pci_quirk *quirk, |
| 4430 | const struct cxt_pincfg **table) |
| 4431 | { |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4432 | struct conexant_spec *spec = codec->spec; |
| 4433 | |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4434 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
David Henningsson | 83b0c6b | 2012-04-10 13:05:29 +0200 | [diff] [blame] | 4435 | if (!quirk) |
| 4436 | return; |
| 4437 | if (table[quirk->value]) { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4438 | snd_printdd(KERN_INFO "hda_codec: applying pincfg for %s\n", |
| 4439 | quirk->name); |
| 4440 | apply_pincfg(codec, table[quirk->value]); |
| 4441 | } |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4442 | if (quirk->value == CXT_FIXUP_STEREO_DMIC) { |
| 4443 | snd_printdd(KERN_INFO "hda_codec: applying internal mic workaround for %s\n", |
| 4444 | quirk->name); |
| 4445 | spec->fixup_stereo_dmic = 1; |
| 4446 | } |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4447 | } |
| 4448 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4449 | /* ThinkPad X200 & co with cxt5051 */ |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4450 | static const struct cxt_pincfg cxt_pincfg_lenovo_x200[] = { |
| 4451 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */ |
| 4452 | { 0x17, 0x21a11000 }, /* dock-mic */ |
| 4453 | { 0x19, 0x2121103f }, /* dock-HP */ |
Takashi Iwai | 3e93f5e | 2012-02-28 21:49:55 +0100 | [diff] [blame] | 4454 | { 0x1c, 0x21440100 }, /* dock SPDIF out */ |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4455 | {} |
| 4456 | }; |
| 4457 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4458 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ |
| 4459 | static const struct cxt_pincfg cxt_pincfg_lenovo_tp410[] = { |
| 4460 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */ |
| 4461 | { 0x1a, 0x21a190f0 }, /* dock-mic */ |
| 4462 | { 0x1c, 0x212140ff }, /* dock-HP */ |
| 4463 | {} |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4464 | }; |
| 4465 | |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4466 | static const struct cxt_pincfg *cxt_pincfg_tbl[] = { |
| 4467 | [CXT_PINCFG_LENOVO_X200] = cxt_pincfg_lenovo_x200, |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4468 | [CXT_PINCFG_LENOVO_TP410] = cxt_pincfg_lenovo_tp410, |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4469 | [CXT_FIXUP_STEREO_DMIC] = NULL, |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4470 | }; |
| 4471 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4472 | static const struct snd_pci_quirk cxt5051_fixups[] = { |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4473 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), |
| 4474 | {} |
| 4475 | }; |
| 4476 | |
Takashi Iwai | d70f363 | 2012-04-19 15:18:08 +0200 | [diff] [blame] | 4477 | static const struct snd_pci_quirk cxt5066_fixups[] = { |
| 4478 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), |
| 4479 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), |
| 4480 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), |
| 4481 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), |
| 4482 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), |
David Henningsson | 18dcd30 | 2012-04-02 15:40:27 +0200 | [diff] [blame] | 4483 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4484 | {} |
| 4485 | }; |
| 4486 | |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4487 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches |
| 4488 | * can be created (bko#42825) |
| 4489 | */ |
| 4490 | static void add_cx5051_fake_mutes(struct hda_codec *codec) |
| 4491 | { |
| 4492 | static hda_nid_t out_nids[] = { |
| 4493 | 0x10, 0x11, 0 |
| 4494 | }; |
| 4495 | hda_nid_t *p; |
| 4496 | |
| 4497 | for (p = out_nids; *p; p++) |
| 4498 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, |
| 4499 | AC_AMPCAP_MIN_MUTE | |
| 4500 | query_amp_caps(codec, *p, HDA_OUTPUT)); |
| 4501 | } |
| 4502 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4503 | static int patch_conexant_auto(struct hda_codec *codec) |
| 4504 | { |
| 4505 | struct conexant_spec *spec; |
| 4506 | int err; |
| 4507 | |
Takashi Iwai | 1f8458a | 2011-05-13 17:22:05 +0200 | [diff] [blame] | 4508 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4509 | codec->chip_name); |
| 4510 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4511 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4512 | if (!spec) |
| 4513 | return -ENOMEM; |
| 4514 | codec->spec = spec; |
Takashi Iwai | e92d4b0 | 2011-08-24 16:22:21 +0200 | [diff] [blame] | 4515 | |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4516 | switch (codec->vendor_id) { |
| 4517 | case 0x14f15045: |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 4518 | codec->single_adc_amp = 1; |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4519 | break; |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4520 | case 0x14f15051: |
| 4521 | add_cx5051_fake_mutes(codec); |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 4522 | codec->pin_amp_workaround = 1; |
Takashi Iwai | d398011 | 2012-04-19 17:17:59 +0200 | [diff] [blame] | 4523 | apply_fixup(codec, cxt5051_fixups, cxt_pincfg_tbl); |
Takashi Iwai | 3868137 | 2012-02-27 15:00:58 +0100 | [diff] [blame] | 4524 | break; |
Michael Karcher | 51969d6 | 2012-04-06 15:34:19 +0200 | [diff] [blame] | 4525 | default: |
| 4526 | codec->pin_amp_workaround = 1; |
Takashi Iwai | d398011 | 2012-04-19 17:17:59 +0200 | [diff] [blame] | 4527 | apply_fixup(codec, cxt5066_fixups, cxt_pincfg_tbl); |
Takashi Iwai | 6b45214 | 2011-10-14 15:26:20 +0200 | [diff] [blame] | 4528 | } |
| 4529 | |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4530 | /* Show mute-led control only on HP laptops |
| 4531 | * This is a sort of white-list: on HP laptops, EAPD corresponds |
| 4532 | * only to the mute-LED without actualy amp function. Meanwhile, |
| 4533 | * others may use EAPD really as an amp switch, so it might be |
| 4534 | * not good to expose it blindly. |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4535 | */ |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 4536 | switch (codec->subsystem_id >> 16) { |
| 4537 | case 0x103c: |
| 4538 | spec->vmaster_mute_led = 1; |
| 4539 | break; |
| 4540 | } |
Takashi Iwai | 527c73b | 2012-03-12 12:38:51 +0100 | [diff] [blame] | 4541 | |
Takashi Iwai | 22ce5f7 | 2011-05-15 12:19:29 +0200 | [diff] [blame] | 4542 | err = cx_auto_search_adcs(codec); |
| 4543 | if (err < 0) |
| 4544 | return err; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4545 | err = cx_auto_parse_auto_config(codec); |
| 4546 | if (err < 0) { |
| 4547 | kfree(codec->spec); |
| 4548 | codec->spec = NULL; |
| 4549 | return err; |
| 4550 | } |
Takashi Iwai | 6764bce | 2011-05-13 16:52:25 +0200 | [diff] [blame] | 4551 | spec->capture_stream = &cx_auto_pcm_analog_capture; |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4552 | codec->patch_ops = cx_auto_patch_ops; |
| 4553 | if (spec->beep_amp) |
| 4554 | snd_hda_attach_beep_device(codec, spec->beep_amp); |
Takashi Iwai | 4f2864a | 2012-01-25 11:54:19 +0100 | [diff] [blame] | 4555 | |
| 4556 | /* Some laptops with Conexant chips show stalls in S3 resume, |
| 4557 | * which falls into the single-cmd mode. |
| 4558 | * Better to make reset, then. |
| 4559 | */ |
| 4560 | if (!codec->bus->sync_write) { |
| 4561 | snd_printd("hda_codec: " |
| 4562 | "Enable sync_write for stable communication\n"); |
| 4563 | codec->bus->sync_write = 1; |
| 4564 | codec->bus->allow_bus_reset = 1; |
| 4565 | } |
| 4566 | |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4567 | return 0; |
| 4568 | } |
| 4569 | |
| 4570 | /* |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 4571 | */ |
| 4572 | |
Takashi Iwai | 34cbe3a | 2011-05-02 11:38:21 +0200 | [diff] [blame] | 4573 | static const struct hda_codec_preset snd_hda_preset_conexant[] = { |
Tobin Davis | 82f3004 | 2007-02-13 12:45:44 +0100 | [diff] [blame] | 4574 | { .id = 0x14f15045, .name = "CX20549 (Venice)", |
| 4575 | .patch = patch_cxt5045 }, |
| 4576 | { .id = 0x14f15047, .name = "CX20551 (Waikiki)", |
| 4577 | .patch = patch_cxt5047 }, |
Takashi Iwai | 461e2c7 | 2008-01-25 11:35:17 +0100 | [diff] [blame] | 4578 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
| 4579 | .patch = patch_cxt5051 }, |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 4580 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", |
| 4581 | .patch = patch_cxt5066 }, |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 4582 | { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", |
| 4583 | .patch = patch_cxt5066 }, |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 4584 | { .id = 0x14f15068, .name = "CX20584", |
| 4585 | .patch = patch_cxt5066 }, |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 4586 | { .id = 0x14f15069, .name = "CX20585", |
| 4587 | .patch = patch_cxt5066 }, |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 4588 | { .id = 0x14f1506c, .name = "CX20588", |
| 4589 | .patch = patch_cxt5066 }, |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 4590 | { .id = 0x14f1506e, .name = "CX20590", |
| 4591 | .patch = patch_cxt5066 }, |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4592 | { .id = 0x14f15097, .name = "CX20631", |
| 4593 | .patch = patch_conexant_auto }, |
| 4594 | { .id = 0x14f15098, .name = "CX20632", |
| 4595 | .patch = patch_conexant_auto }, |
| 4596 | { .id = 0x14f150a1, .name = "CX20641", |
| 4597 | .patch = patch_conexant_auto }, |
| 4598 | { .id = 0x14f150a2, .name = "CX20642", |
| 4599 | .patch = patch_conexant_auto }, |
| 4600 | { .id = 0x14f150ab, .name = "CX20651", |
| 4601 | .patch = patch_conexant_auto }, |
| 4602 | { .id = 0x14f150ac, .name = "CX20652", |
| 4603 | .patch = patch_conexant_auto }, |
| 4604 | { .id = 0x14f150b8, .name = "CX20664", |
| 4605 | .patch = patch_conexant_auto }, |
| 4606 | { .id = 0x14f150b9, .name = "CX20665", |
| 4607 | .patch = patch_conexant_auto }, |
Tobin Davis | c9b443d | 2006-11-14 12:13:39 +0100 | [diff] [blame] | 4608 | {} /* terminator */ |
| 4609 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4610 | |
| 4611 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); |
| 4612 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
| 4613 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
Daniel Drake | 0fb67e9 | 2009-07-16 14:46:57 +0100 | [diff] [blame] | 4614 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); |
Einar Rünkaru | 95a618b | 2009-11-23 22:23:49 +0200 | [diff] [blame] | 4615 | MODULE_ALIAS("snd-hda-codec-id:14f15067"); |
Takashi Iwai | 850eab9 | 2010-08-09 13:44:27 +0200 | [diff] [blame] | 4616 | MODULE_ALIAS("snd-hda-codec-id:14f15068"); |
Jens Taprogge | 7b2bfdb | 2010-04-14 23:42:04 +0200 | [diff] [blame] | 4617 | MODULE_ALIAS("snd-hda-codec-id:14f15069"); |
David Henningsson | f0ca89b | 2011-06-21 20:51:34 +0200 | [diff] [blame] | 4618 | MODULE_ALIAS("snd-hda-codec-id:14f1506c"); |
David Henningsson | 6da8b51 | 2011-02-08 07:16:06 +0100 | [diff] [blame] | 4619 | MODULE_ALIAS("snd-hda-codec-id:14f1506e"); |
Takashi Iwai | f2e5731 | 2010-09-15 10:07:08 +0200 | [diff] [blame] | 4620 | MODULE_ALIAS("snd-hda-codec-id:14f15097"); |
| 4621 | MODULE_ALIAS("snd-hda-codec-id:14f15098"); |
| 4622 | MODULE_ALIAS("snd-hda-codec-id:14f150a1"); |
| 4623 | MODULE_ALIAS("snd-hda-codec-id:14f150a2"); |
| 4624 | MODULE_ALIAS("snd-hda-codec-id:14f150ab"); |
| 4625 | MODULE_ALIAS("snd-hda-codec-id:14f150ac"); |
| 4626 | MODULE_ALIAS("snd-hda-codec-id:14f150b8"); |
| 4627 | MODULE_ALIAS("snd-hda-codec-id:14f150b9"); |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4628 | |
| 4629 | MODULE_LICENSE("GPL"); |
| 4630 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
| 4631 | |
| 4632 | static struct hda_codec_preset_list conexant_list = { |
| 4633 | .preset = snd_hda_preset_conexant, |
| 4634 | .owner = THIS_MODULE, |
| 4635 | }; |
| 4636 | |
| 4637 | static int __init patch_conexant_init(void) |
| 4638 | { |
| 4639 | return snd_hda_add_codec_preset(&conexant_list); |
| 4640 | } |
| 4641 | |
| 4642 | static void __exit patch_conexant_exit(void) |
| 4643 | { |
| 4644 | snd_hda_delete_codec_preset(&conexant_list); |
| 4645 | } |
| 4646 | |
| 4647 | module_init(patch_conexant_init) |
| 4648 | module_exit(patch_conexant_exit) |