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