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