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