1c9b443d4STobin Davis /* 2c9b443d4STobin Davis * HD audio interface patch for Conexant HDA audio codec 3c9b443d4STobin Davis * 4c9b443d4STobin Davis * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> 5c9b443d4STobin Davis * Takashi Iwai <tiwai@suse.de> 6c9b443d4STobin Davis * Tobin Davis <tdavis@dsl-only.net> 7c9b443d4STobin Davis * 8c9b443d4STobin Davis * This driver is free software; you can redistribute it and/or modify 9c9b443d4STobin Davis * it under the terms of the GNU General Public License as published by 10c9b443d4STobin Davis * the Free Software Foundation; either version 2 of the License, or 11c9b443d4STobin Davis * (at your option) any later version. 12c9b443d4STobin Davis * 13c9b443d4STobin Davis * This driver is distributed in the hope that it will be useful, 14c9b443d4STobin Davis * but WITHOUT ANY WARRANTY; without even the implied warranty of 15c9b443d4STobin Davis * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16c9b443d4STobin Davis * GNU General Public License for more details. 17c9b443d4STobin Davis * 18c9b443d4STobin Davis * You should have received a copy of the GNU General Public License 19c9b443d4STobin Davis * along with this program; if not, write to the Free Software 20c9b443d4STobin Davis * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21c9b443d4STobin Davis */ 22c9b443d4STobin Davis 23c9b443d4STobin Davis #include <linux/init.h> 24c9b443d4STobin Davis #include <linux/delay.h> 25c9b443d4STobin Davis #include <linux/slab.h> 26c9b443d4STobin Davis #include <linux/pci.h> 27da155d5bSPaul Gortmaker #include <linux/module.h> 28c9b443d4STobin Davis #include <sound/core.h> 29bc7a166dSUlrich Dangel #include <sound/jack.h> 30bc7a166dSUlrich Dangel 31c9b443d4STobin Davis #include "hda_codec.h" 32c9b443d4STobin Davis #include "hda_local.h" 3323d30f28STakashi Iwai #include "hda_auto_parser.h" 34c0f8faf0SEinar Rünkaru #include "hda_beep.h" 351835a0f9STakashi Iwai #include "hda_jack.h" 36aed523f1STakashi Iwai #include "hda_generic.h" 37c9b443d4STobin Davis 38bf92d1d5STakashi Iwai #define ENABLE_CXT_STATIC_QUIRKS 39c9b443d4STobin Davis 40c9b443d4STobin Davis #define CXT_PIN_DIR_IN 0x00 41c9b443d4STobin Davis #define CXT_PIN_DIR_OUT 0x01 42c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT 0x02 43c9b443d4STobin Davis #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 44c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 45c9b443d4STobin Davis 46c9b443d4STobin Davis #define CONEXANT_HP_EVENT 0x37 47c9b443d4STobin Davis #define CONEXANT_MIC_EVENT 0x38 4803697e2aSTakashi Iwai #define CONEXANT_LINE_EVENT 0x39 49c9b443d4STobin Davis 50bc7a166dSUlrich Dangel /* Conexant 5051 specific */ 51c9b443d4STobin Davis 52ecda0cffSTakashi Iwai #define CXT5051_SPDIF_OUT 0x12 53bc7a166dSUlrich Dangel #define CXT5051_PORTB_EVENT 0x38 54bc7a166dSUlrich Dangel #define CXT5051_PORTC_EVENT 0x39 55bc7a166dSUlrich Dangel 56faddaa5dSTakashi Iwai #define AUTO_MIC_PORTB (1 << 1) 57faddaa5dSTakashi Iwai #define AUTO_MIC_PORTC (1 << 2) 58bc7a166dSUlrich Dangel 59c9b443d4STobin Davis struct conexant_spec { 6023d30f28STakashi Iwai struct hda_gen_spec gen; 61c9b443d4STobin Davis 62bf92d1d5STakashi Iwai unsigned int beep_amp; 63bf92d1d5STakashi Iwai 64bf92d1d5STakashi Iwai /* extra EAPD pins */ 65bf92d1d5STakashi Iwai unsigned int num_eapds; 66bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 67ff359b14STakashi Iwai bool dynamic_eapd; 68bf92d1d5STakashi Iwai 69e4c3bce2SDavid Henningsson unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 70e4c3bce2SDavid Henningsson 71bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 7234cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 73c9b443d4STobin Davis int num_mixers; 74dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 75c9b443d4STobin Davis 76c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 77c9b443d4STobin Davis * don't forget NULL 78c9b443d4STobin Davis * termination! 79c9b443d4STobin Davis */ 80c9b443d4STobin Davis unsigned int num_init_verbs; 81c9b443d4STobin Davis 82c9b443d4STobin Davis /* playback */ 83c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 84c9b443d4STobin Davis * max_channels, dacs must be set 85c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 86c9b443d4STobin Davis */ 87c9b443d4STobin Davis unsigned int cur_eapd; 8882f30040STobin Davis unsigned int hp_present; 8903697e2aSTakashi Iwai unsigned int line_present; 90faddaa5dSTakashi Iwai unsigned int auto_mic; 91c9b443d4STobin Davis 92c9b443d4STobin Davis /* capture */ 93c9b443d4STobin Davis unsigned int num_adc_nids; 9434cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 95c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 96c9b443d4STobin Davis 97461e2c78STakashi Iwai unsigned int cur_adc_idx; 98461e2c78STakashi Iwai hda_nid_t cur_adc; 99461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 100461e2c78STakashi Iwai unsigned int cur_adc_format; 101461e2c78STakashi Iwai 1026764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1036764bcefSTakashi Iwai 104c9b443d4STobin Davis /* capture source */ 105c9b443d4STobin Davis const struct hda_input_mux *input_mux; 10634cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 107c9b443d4STobin Davis unsigned int cur_mux[3]; 108c9b443d4STobin Davis 109c9b443d4STobin Davis /* channel model */ 110c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 111c9b443d4STobin Davis int num_channel_mode; 112c9b443d4STobin Davis 113c9b443d4STobin Davis /* PCM information */ 114c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 115c9b443d4STobin Davis 116c9b443d4STobin Davis unsigned int spdif_route; 117c9b443d4STobin Davis 1180fb67e98SDaniel Drake unsigned int port_d_mode; 119f2e5731dSTakashi Iwai unsigned int dell_automute:1; 120cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 121cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1227b2bfdbcSJens Taprogge unsigned int thinkpad:1; 123048e78a5SDavid Henningsson unsigned int hp_laptop:1; 124a1d6906eSDavid Henningsson unsigned int asus:1; 1256764bcefSTakashi Iwai 12675f8991dSDaniel Drake unsigned int ext_mic_present; 12775f8991dSDaniel Drake unsigned int recording; 12875f8991dSDaniel Drake void (*capture_prepare)(struct hda_codec *codec); 12975f8991dSDaniel Drake void (*capture_cleanup)(struct hda_codec *codec); 130c4cfe66cSDaniel Drake 131c4cfe66cSDaniel Drake /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 132c4cfe66cSDaniel Drake * through the microphone jack. 133c4cfe66cSDaniel Drake * When the user enables this through a mixer switch, both internal and 134c4cfe66cSDaniel Drake * external microphones are disabled. Gain is fixed at 0dB. In this mode, 135c4cfe66cSDaniel Drake * we also allow the bias to be configured through a separate mixer 136c4cfe66cSDaniel Drake * control. */ 137c4cfe66cSDaniel Drake unsigned int dc_enable; 138c4cfe66cSDaniel Drake unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ 139c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 140bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 141c9b443d4STobin Davis }; 142c9b443d4STobin Davis 143bf92d1d5STakashi Iwai 144bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 1457504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 1467504b6cdSTakashi Iwai int idx, int dir) 1477504b6cdSTakashi Iwai { 1487504b6cdSTakashi Iwai spec->gen.beep_nid = nid; 1497504b6cdSTakashi Iwai spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 1507504b6cdSTakashi Iwai } 151bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 152bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 153bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 154bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 155bf92d1d5STakashi Iwai { } /* end */ 156bf92d1d5STakashi Iwai }; 157bf92d1d5STakashi Iwai 158bf92d1d5STakashi Iwai /* create beep controls if needed */ 159bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 160bf92d1d5STakashi Iwai { 161bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 162bf92d1d5STakashi Iwai int err; 163bf92d1d5STakashi Iwai 164bf92d1d5STakashi Iwai if (spec->beep_amp) { 165bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 166bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 167bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 168bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 169bf92d1d5STakashi Iwai if (!kctl) 170bf92d1d5STakashi Iwai return -ENOMEM; 171bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 172bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 173bf92d1d5STakashi Iwai if (err < 0) 174bf92d1d5STakashi Iwai return err; 175bf92d1d5STakashi Iwai } 176bf92d1d5STakashi Iwai } 177bf92d1d5STakashi Iwai return 0; 178bf92d1d5STakashi Iwai } 179bf92d1d5STakashi Iwai #else 180bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 181bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 182bf92d1d5STakashi Iwai #endif 183bf92d1d5STakashi Iwai 184bf92d1d5STakashi Iwai 185bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 186c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 187c9b443d4STobin Davis struct hda_codec *codec, 188c9b443d4STobin Davis struct snd_pcm_substream *substream) 189c9b443d4STobin Davis { 190c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1919a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1929a08160bSTakashi Iwai hinfo); 193c9b443d4STobin Davis } 194c9b443d4STobin Davis 195c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 196c9b443d4STobin Davis struct hda_codec *codec, 197c9b443d4STobin Davis unsigned int stream_tag, 198c9b443d4STobin Davis unsigned int format, 199c9b443d4STobin Davis struct snd_pcm_substream *substream) 200c9b443d4STobin Davis { 201c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 202c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 203c9b443d4STobin Davis stream_tag, 204c9b443d4STobin Davis format, substream); 205c9b443d4STobin Davis } 206c9b443d4STobin Davis 207c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 208c9b443d4STobin Davis struct hda_codec *codec, 209c9b443d4STobin Davis struct snd_pcm_substream *substream) 210c9b443d4STobin Davis { 211c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 212c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 213c9b443d4STobin Davis } 214c9b443d4STobin Davis 215c9b443d4STobin Davis /* 216c9b443d4STobin Davis * Digital out 217c9b443d4STobin Davis */ 218c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 219c9b443d4STobin Davis struct hda_codec *codec, 220c9b443d4STobin Davis struct snd_pcm_substream *substream) 221c9b443d4STobin Davis { 222c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 223c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 224c9b443d4STobin Davis } 225c9b443d4STobin Davis 226c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 227c9b443d4STobin Davis struct hda_codec *codec, 228c9b443d4STobin Davis struct snd_pcm_substream *substream) 229c9b443d4STobin Davis { 230c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 231c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 232c9b443d4STobin Davis } 233c9b443d4STobin Davis 2346b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2356b97eb45STakashi Iwai struct hda_codec *codec, 2366b97eb45STakashi Iwai unsigned int stream_tag, 2376b97eb45STakashi Iwai unsigned int format, 2386b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2396b97eb45STakashi Iwai { 2406b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2416b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2426b97eb45STakashi Iwai stream_tag, 2436b97eb45STakashi Iwai format, substream); 2446b97eb45STakashi Iwai } 2456b97eb45STakashi Iwai 246c9b443d4STobin Davis /* 247c9b443d4STobin Davis * Analog capture 248c9b443d4STobin Davis */ 249c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 250c9b443d4STobin Davis struct hda_codec *codec, 251c9b443d4STobin Davis unsigned int stream_tag, 252c9b443d4STobin Davis unsigned int format, 253c9b443d4STobin Davis struct snd_pcm_substream *substream) 254c9b443d4STobin Davis { 255c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 25675f8991dSDaniel Drake if (spec->capture_prepare) 25775f8991dSDaniel Drake spec->capture_prepare(codec); 258c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 259c9b443d4STobin Davis stream_tag, 0, format); 260c9b443d4STobin Davis return 0; 261c9b443d4STobin Davis } 262c9b443d4STobin Davis 263c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 264c9b443d4STobin Davis struct hda_codec *codec, 265c9b443d4STobin Davis struct snd_pcm_substream *substream) 266c9b443d4STobin Davis { 267c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 268888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 26975f8991dSDaniel Drake if (spec->capture_cleanup) 27075f8991dSDaniel Drake spec->capture_cleanup(codec); 271c9b443d4STobin Davis return 0; 272c9b443d4STobin Davis } 273c9b443d4STobin Davis 274c9b443d4STobin Davis 275c9b443d4STobin Davis 27634cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 277c9b443d4STobin Davis .substreams = 1, 278c9b443d4STobin Davis .channels_min = 2, 279c9b443d4STobin Davis .channels_max = 2, 280c9b443d4STobin Davis .nid = 0, /* fill later */ 281c9b443d4STobin Davis .ops = { 282c9b443d4STobin Davis .open = conexant_playback_pcm_open, 283c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 284c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 285c9b443d4STobin Davis }, 286c9b443d4STobin Davis }; 287c9b443d4STobin Davis 28834cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 289c9b443d4STobin Davis .substreams = 1, 290c9b443d4STobin Davis .channels_min = 2, 291c9b443d4STobin Davis .channels_max = 2, 292c9b443d4STobin Davis .nid = 0, /* fill later */ 293c9b443d4STobin Davis .ops = { 294c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 295c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 296c9b443d4STobin Davis }, 297c9b443d4STobin Davis }; 298c9b443d4STobin Davis 299c9b443d4STobin Davis 30034cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 301c9b443d4STobin Davis .substreams = 1, 302c9b443d4STobin Davis .channels_min = 2, 303c9b443d4STobin Davis .channels_max = 2, 304c9b443d4STobin Davis .nid = 0, /* fill later */ 305c9b443d4STobin Davis .ops = { 306c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 3076b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 3086b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 309c9b443d4STobin Davis }, 310c9b443d4STobin Davis }; 311c9b443d4STobin Davis 31234cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 313c9b443d4STobin Davis .substreams = 1, 314c9b443d4STobin Davis .channels_min = 2, 315c9b443d4STobin Davis .channels_max = 2, 316c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 317c9b443d4STobin Davis }; 318c9b443d4STobin Davis 319461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 320461e2c78STakashi Iwai struct hda_codec *codec, 321461e2c78STakashi Iwai unsigned int stream_tag, 322461e2c78STakashi Iwai unsigned int format, 323461e2c78STakashi Iwai struct snd_pcm_substream *substream) 324461e2c78STakashi Iwai { 325461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 326461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 327461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 328461e2c78STakashi Iwai spec->cur_adc_format = format; 329461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 330461e2c78STakashi Iwai return 0; 331461e2c78STakashi Iwai } 332461e2c78STakashi Iwai 333461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 334461e2c78STakashi Iwai struct hda_codec *codec, 335461e2c78STakashi Iwai struct snd_pcm_substream *substream) 336461e2c78STakashi Iwai { 337461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 338888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 339461e2c78STakashi Iwai spec->cur_adc = 0; 340461e2c78STakashi Iwai return 0; 341461e2c78STakashi Iwai } 342461e2c78STakashi Iwai 34334cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 344461e2c78STakashi Iwai .substreams = 1, 345461e2c78STakashi Iwai .channels_min = 2, 346461e2c78STakashi Iwai .channels_max = 2, 347461e2c78STakashi Iwai .nid = 0, /* fill later */ 348461e2c78STakashi Iwai .ops = { 349461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 350461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 351461e2c78STakashi Iwai }, 352461e2c78STakashi Iwai }; 353461e2c78STakashi Iwai 354c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 355c9b443d4STobin Davis { 356c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 357c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 358c9b443d4STobin Davis 359c9b443d4STobin Davis codec->num_pcms = 1; 360c9b443d4STobin Davis codec->pcm_info = info; 361c9b443d4STobin Davis 362c9b443d4STobin Davis info->name = "CONEXANT Analog"; 363c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 364c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 365c9b443d4STobin Davis spec->multiout.max_channels; 366c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 367c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3686764bcefSTakashi Iwai if (spec->capture_stream) 3696764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3706764bcefSTakashi Iwai else { 371461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 372461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 373461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3746764bcefSTakashi Iwai else { 375461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 376461e2c78STakashi Iwai conexant_pcm_analog_capture; 3776764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3786764bcefSTakashi Iwai spec->num_adc_nids; 3796764bcefSTakashi Iwai } 3806764bcefSTakashi Iwai } 381c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 382c9b443d4STobin Davis 383c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 384c9b443d4STobin Davis info++; 385c9b443d4STobin Davis codec->num_pcms++; 386c9b443d4STobin Davis info->name = "Conexant Digital"; 3877ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 388c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 389c9b443d4STobin Davis conexant_pcm_digital_playback; 390c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 391c9b443d4STobin Davis spec->multiout.dig_out_nid; 392c9b443d4STobin Davis if (spec->dig_in_nid) { 393c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 394c9b443d4STobin Davis conexant_pcm_digital_capture; 395c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 396c9b443d4STobin Davis spec->dig_in_nid; 397c9b443d4STobin Davis } 398c9b443d4STobin Davis } 399c9b443d4STobin Davis 400c9b443d4STobin Davis return 0; 401c9b443d4STobin Davis } 402c9b443d4STobin Davis 403c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 404c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 405c9b443d4STobin Davis { 406c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 407c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 408c9b443d4STobin Davis 409c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 410c9b443d4STobin Davis } 411c9b443d4STobin Davis 412c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 413c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 414c9b443d4STobin Davis { 415c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 416c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 417c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 418c9b443d4STobin Davis 419c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 420c9b443d4STobin Davis return 0; 421c9b443d4STobin Davis } 422c9b443d4STobin Davis 423c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 424c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 425c9b443d4STobin Davis { 426c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 427c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 428c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 429c9b443d4STobin Davis 430c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 431c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 432c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 433c9b443d4STobin Davis } 434c9b443d4STobin Davis 4354d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4364d7fbdbcSTakashi Iwai unsigned int power_state) 4374d7fbdbcSTakashi Iwai { 4384d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4394d7fbdbcSTakashi Iwai msleep(100); 4404d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4414d7fbdbcSTakashi Iwai power_state); 4424d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4434d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4444d7fbdbcSTakashi Iwai msleep(10); 4459419ab6bSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state); 4464d7fbdbcSTakashi Iwai } 4474d7fbdbcSTakashi Iwai 448c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 449c9b443d4STobin Davis { 450c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 451c9b443d4STobin Davis int i; 452c9b443d4STobin Davis 453c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 454c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 455c9b443d4STobin Davis return 0; 456c9b443d4STobin Davis } 457c9b443d4STobin Davis 458c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 459c9b443d4STobin Davis { 460ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 461c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 462ee48df57STakashi Iwai kfree(spec); 463c9b443d4STobin Davis } 464c9b443d4STobin Davis 46534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 466b880c74aSTakashi Iwai { 467b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 468b880c74aSTakashi Iwai .name = "Capture Source", 469b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 470b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 471b880c74aSTakashi Iwai .put = conexant_mux_enum_put 472b880c74aSTakashi Iwai }, 473b880c74aSTakashi Iwai {} 474b880c74aSTakashi Iwai }; 475b880c74aSTakashi Iwai 4769322ca54STakashi Iwai static const char * const slave_pfxs[] = { 477f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 478dd5746a8STakashi Iwai NULL 479dd5746a8STakashi Iwai }; 480dd5746a8STakashi Iwai 481c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 482c9b443d4STobin Davis { 483c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 484c9b443d4STobin Davis unsigned int i; 485c9b443d4STobin Davis int err; 486c9b443d4STobin Davis 487c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 488c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 489c9b443d4STobin Davis if (err < 0) 490c9b443d4STobin Davis return err; 491c9b443d4STobin Davis } 492c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 493c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 49474b654c9SStephen Warren spec->multiout.dig_out_nid, 495c9b443d4STobin Davis spec->multiout.dig_out_nid); 496c9b443d4STobin Davis if (err < 0) 497c9b443d4STobin Davis return err; 4989a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4999a08160bSTakashi Iwai &spec->multiout); 5009a08160bSTakashi Iwai if (err < 0) 5019a08160bSTakashi Iwai return err; 5029a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 503c9b443d4STobin Davis } 504c9b443d4STobin Davis if (spec->dig_in_nid) { 505c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 506c9b443d4STobin Davis if (err < 0) 507c9b443d4STobin Davis return err; 508c9b443d4STobin Davis } 509dd5746a8STakashi Iwai 510dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 511dd5746a8STakashi Iwai if (spec->vmaster_nid && 512dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 513dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 514dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 515dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 516dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5179322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5189322ca54STakashi Iwai "Playback Volume"); 519dd5746a8STakashi Iwai if (err < 0) 520dd5746a8STakashi Iwai return err; 521dd5746a8STakashi Iwai } 522dd5746a8STakashi Iwai if (spec->vmaster_nid && 523dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 524aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5259322ca54STakashi Iwai NULL, slave_pfxs, 526aed523f1STakashi Iwai "Playback Switch"); 527dd5746a8STakashi Iwai if (err < 0) 528dd5746a8STakashi Iwai return err; 529dd5746a8STakashi Iwai } 530dd5746a8STakashi Iwai 531b880c74aSTakashi Iwai if (spec->input_mux) { 532b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 533b880c74aSTakashi Iwai if (err < 0) 534b880c74aSTakashi Iwai return err; 535b880c74aSTakashi Iwai } 536b880c74aSTakashi Iwai 537aed523f1STakashi Iwai err = add_beep_ctls(codec); 5383507e2a8STakashi Iwai if (err < 0) 5393507e2a8STakashi Iwai return err; 5403507e2a8STakashi Iwai 541c9b443d4STobin Davis return 0; 542c9b443d4STobin Davis } 543c9b443d4STobin Davis 54434cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 545c9b443d4STobin Davis .build_controls = conexant_build_controls, 546c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 547c9b443d4STobin Davis .init = conexant_init, 548c9b443d4STobin Davis .free = conexant_free, 5494d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 550c9b443d4STobin Davis }; 551c9b443d4STobin Davis 5526764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 553c9b443d4STobin Davis /* 554c9b443d4STobin Davis * EAPD control 555c9b443d4STobin Davis * the private value = nid | (invert << 8) 556c9b443d4STobin Davis */ 557c9b443d4STobin Davis 558a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 559c9b443d4STobin Davis 56082f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 561c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 562c9b443d4STobin Davis { 563c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 564c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 565c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 566c9b443d4STobin Davis if (invert) 567c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 568c9b443d4STobin Davis else 569c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 570c9b443d4STobin Davis return 0; 57182f30040STobin Davis 572c9b443d4STobin Davis } 573c9b443d4STobin Davis 57482f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 575c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 576c9b443d4STobin Davis { 577c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 578c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 579c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 580c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 581c9b443d4STobin Davis unsigned int eapd; 58282f30040STobin Davis 58368ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 584c9b443d4STobin Davis if (invert) 585c9b443d4STobin Davis eapd = !eapd; 58682beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 587c9b443d4STobin Davis return 0; 58882f30040STobin Davis 589c9b443d4STobin Davis spec->cur_eapd = eapd; 59082beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 591c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 592c9b443d4STobin Davis eapd ? 0x02 : 0x00); 593c9b443d4STobin Davis return 1; 594c9b443d4STobin Davis } 595c9b443d4STobin Davis 59686d72bdfSTakashi Iwai /* controls for test mode */ 59786d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 59886d72bdfSTakashi Iwai 59982f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 60082f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 60182f30040STobin Davis .info = cxt_eapd_info, \ 60282f30040STobin Davis .get = cxt_eapd_get, \ 60382f30040STobin Davis .put = cxt_eapd_put, \ 60482f30040STobin Davis .private_value = nid | (mask<<16) } 60582f30040STobin Davis 60682f30040STobin Davis 60782f30040STobin Davis 608c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 609c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 610c9b443d4STobin Davis { 611c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 612c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 613c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 614c9b443d4STobin Davis spec->num_channel_mode); 615c9b443d4STobin Davis } 616c9b443d4STobin Davis 617c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 618c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 619c9b443d4STobin Davis { 620c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 621c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 622c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 623c9b443d4STobin Davis spec->num_channel_mode, 624c9b443d4STobin Davis spec->multiout.max_channels); 625c9b443d4STobin Davis } 626c9b443d4STobin Davis 627c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 628c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 629c9b443d4STobin Davis { 630c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 631c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 632c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 633c9b443d4STobin Davis spec->num_channel_mode, 634c9b443d4STobin Davis &spec->multiout.max_channels); 635c9b443d4STobin Davis return err; 636c9b443d4STobin Davis } 637c9b443d4STobin Davis 638c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 639c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 640c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 641c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 642c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 643c9b443d4STobin Davis .private_value = nid | (dir<<16) } 644c9b443d4STobin Davis 64586d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 64686d72bdfSTakashi Iwai 647c9b443d4STobin Davis /* Conexant 5045 specific */ 648c9b443d4STobin Davis 64934cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 65034cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 65134cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 652cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 653c9b443d4STobin Davis 65434cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6555cd57529STobin Davis { 2, NULL }, 6565cd57529STobin Davis }; 657c9b443d4STobin Davis 65834cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 659c9b443d4STobin Davis .num_items = 2, 660c9b443d4STobin Davis .items = { 6613edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6623edbbb9eSMichael Karcher { "Mic", 0x2 }, 663c9b443d4STobin Davis } 664c9b443d4STobin Davis }; 665c9b443d4STobin Davis 66634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 667e6e03daeSMichael Karcher .num_items = 4, 6685218c892SJiang Zhe .items = { 6693edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6703edbbb9eSMichael Karcher { "Mic", 0x2 }, 6713edbbb9eSMichael Karcher { "Line", 0x3 }, 67222e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6735218c892SJiang Zhe } 6745218c892SJiang Zhe }; 6755218c892SJiang Zhe 67634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_hp530 = { 6772de3c232SJiang zhe .num_items = 2, 6782de3c232SJiang zhe .items = { 6793edbbb9eSMichael Karcher { "Mic", 0x1 }, 6803edbbb9eSMichael Karcher { "Internal Mic", 0x2 }, 6812de3c232SJiang zhe } 6822de3c232SJiang zhe }; 6832de3c232SJiang zhe 684c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 685c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 686c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 687c9b443d4STobin Davis { 688c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 689c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 69082f30040STobin Davis unsigned int bits; 691c9b443d4STobin Davis 69282f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 693c9b443d4STobin Davis return 0; 694c9b443d4STobin Davis 69582f30040STobin Davis /* toggle internal speakers mute depending of presence of 69682f30040STobin Davis * the headphone jack 69782f30040STobin Davis */ 69847fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 69947fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 70047fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 7017f29673bSTobin Davis 70247fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 70347fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 70447fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 705c9b443d4STobin Davis return 1; 706c9b443d4STobin Davis } 707c9b443d4STobin Davis 708c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 70934cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 710cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 711cca3b371STakashi Iwai .values = { 712cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 713cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 714cca3b371STakashi Iwai 0 715cca3b371STakashi Iwai }, 716cca3b371STakashi Iwai }; 717c9b443d4STobin Davis 7187f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 7197f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7207f29673bSTobin Davis { 72134cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7227f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7237f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7247f29673bSTobin Davis {} 7257f29673bSTobin Davis }; 72634cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7277f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7287f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7297f29673bSTobin Davis {} 7307f29673bSTobin Davis }; 7317f29673bSTobin Davis unsigned int present; 7327f29673bSTobin Davis 733d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7347f29673bSTobin Davis if (present) 7357f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7367f29673bSTobin Davis else 7377f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7387f29673bSTobin Davis } 7397f29673bSTobin Davis 740c9b443d4STobin Davis 741c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 742c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 743c9b443d4STobin Davis { 74482f30040STobin Davis struct conexant_spec *spec = codec->spec; 745dd87da1cSTobin Davis unsigned int bits; 746c9b443d4STobin Davis 747d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 748dd87da1cSTobin Davis 74947fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 75047fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 75147fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 752c9b443d4STobin Davis } 753c9b443d4STobin Davis 754c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 755c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 756c9b443d4STobin Davis unsigned int res) 757c9b443d4STobin Davis { 758c9b443d4STobin Davis res >>= 26; 759c9b443d4STobin Davis switch (res) { 760c9b443d4STobin Davis case CONEXANT_HP_EVENT: 761c9b443d4STobin Davis cxt5045_hp_automute(codec); 762c9b443d4STobin Davis break; 7637f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7647f29673bSTobin Davis cxt5045_hp_automic(codec); 7657f29673bSTobin Davis break; 7667f29673bSTobin Davis 767c9b443d4STobin Davis } 768c9b443d4STobin Davis } 769c9b443d4STobin Davis 77034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 771cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 772cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 773c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 774c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 77528c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 77628c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7778607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7788607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 779cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 780c9b443d4STobin Davis { 781c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 782c9b443d4STobin Davis .name = "Master Playback Switch", 78382f30040STobin Davis .info = cxt_eapd_info, 78482f30040STobin Davis .get = cxt_eapd_get, 785c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 78682f30040STobin Davis .private_value = 0x10, 787c9b443d4STobin Davis }, 788c9b443d4STobin Davis 789c9b443d4STobin Davis {} 790c9b443d4STobin Davis }; 791c9b443d4STobin Davis 79234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7933edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7943edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 79522e14130SLukasz Marcinowski 7965218c892SJiang Zhe {} 7975218c892SJiang Zhe }; 7985218c892SJiang Zhe 79934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 800cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 801cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 8022de3c232SJiang zhe HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 8032de3c232SJiang zhe HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 80428c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 80528c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 8068607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 8078607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 8082de3c232SJiang zhe HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 8092de3c232SJiang zhe { 8102de3c232SJiang zhe .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8112de3c232SJiang zhe .name = "Master Playback Switch", 8122de3c232SJiang zhe .info = cxt_eapd_info, 8132de3c232SJiang zhe .get = cxt_eapd_get, 8142de3c232SJiang zhe .put = cxt5045_hp_master_sw_put, 8152de3c232SJiang zhe .private_value = 0x10, 8162de3c232SJiang zhe }, 8172de3c232SJiang zhe 8182de3c232SJiang zhe {} 8192de3c232SJiang zhe }; 8202de3c232SJiang zhe 82134cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 822c9b443d4STobin Davis /* Line in, Mic */ 8234090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8247f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 825c9b443d4STobin Davis /* HP, Amp */ 826c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 827c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 82882f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 829c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 830c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 831c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 832c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 833c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 834c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 83528c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8367f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 83782f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 838c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 839c9b443d4STobin Davis /* SPDIF route: PCM */ 840cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 841c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 842c9b443d4STobin Davis /* EAPD */ 84382f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 844c9b443d4STobin Davis { } /* end */ 845c9b443d4STobin Davis }; 846c9b443d4STobin Davis 84734cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 84828c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8495218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8505218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8515218c892SJiang Zhe /* Line In,HP, Amp */ 8525218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8535218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8545218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8555218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8565218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8575218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8585218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8595218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8605218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 86128c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8625218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8635218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8645218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8655218c892SJiang Zhe /* SPDIF route: PCM */ 866cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8675218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8685218c892SJiang Zhe /* EAPD */ 8695218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8705218c892SJiang Zhe { } /* end */ 8715218c892SJiang Zhe }; 8727f29673bSTobin Davis 87334cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8747f29673bSTobin Davis /* pin sensing on HP jack */ 8757f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 876d3091fadSTakashi Iwai { } /* end */ 8777f29673bSTobin Davis }; 8787f29673bSTobin Davis 87934cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8807f29673bSTobin Davis /* pin sensing on HP jack */ 8817f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 882d3091fadSTakashi Iwai { } /* end */ 8837f29673bSTobin Davis }; 8847f29673bSTobin Davis 885c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 886c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 887c9b443d4STobin Davis * configuration. 888c9b443d4STobin Davis */ 88934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 890c9b443d4STobin Davis .num_items = 5, 891c9b443d4STobin Davis .items = { 892c9b443d4STobin Davis { "MIXER", 0x0 }, 893c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 894c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 895c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 896c9b443d4STobin Davis { "CD pin", 0x4 }, 897c9b443d4STobin Davis }, 898c9b443d4STobin Davis }; 899c9b443d4STobin Davis 90034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 901c9b443d4STobin Davis 902c9b443d4STobin Davis /* Output controls */ 903c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 904c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 905250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 906250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 907250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 908250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 909c9b443d4STobin Davis 910c9b443d4STobin Davis /* Modes for retasking pin widgets */ 911c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 912c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 913c9b443d4STobin Davis 91482f30040STobin Davis /* EAPD Switch Control */ 91582f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 91682f30040STobin Davis 917c9b443d4STobin Davis /* Loopback mixer controls */ 918c9b443d4STobin Davis 919250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 920250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 921250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 922250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 923250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 924250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 925250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 926250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 927250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 928250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 929c9b443d4STobin Davis { 930c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 931c9b443d4STobin Davis .name = "Input Source", 932c9b443d4STobin Davis .info = conexant_mux_enum_info, 933c9b443d4STobin Davis .get = conexant_mux_enum_get, 934c9b443d4STobin Davis .put = conexant_mux_enum_put, 935c9b443d4STobin Davis }, 936fb3409e7STobin Davis /* Audio input controls */ 937cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 938cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 939c9b443d4STobin Davis { } /* end */ 940c9b443d4STobin Davis }; 941c9b443d4STobin Davis 94234cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9437f29673bSTobin Davis /* Set connections */ 9447f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9457f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9467f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 947c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 948c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9497f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 950c9b443d4STobin Davis 951c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 952c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 953c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 954c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 955c9b443d4STobin Davis * control. 956c9b443d4STobin Davis */ 957cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 958cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 959c9b443d4STobin Davis 960c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 961c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 962c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 963c9b443d4STobin Davis * input/output buffers as needed. 964c9b443d4STobin Davis */ 965c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 966c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 967c9b443d4STobin Davis 968c9b443d4STobin Davis /* Mute capture amp left and right */ 969c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 970c9b443d4STobin Davis 971c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 972c9b443d4STobin Davis * pin) 973c9b443d4STobin Davis */ 974250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 975250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 976c9b443d4STobin Davis 977c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 978250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 979c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 980c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 981c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 982c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 983c9b443d4STobin Davis 984c9b443d4STobin Davis { } 985c9b443d4STobin Davis }; 986c9b443d4STobin Davis #endif 987c9b443d4STobin Davis 988c9b443d4STobin Davis 989c9b443d4STobin Davis /* initialize jack-sensing, too */ 990c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 991c9b443d4STobin Davis { 992c9b443d4STobin Davis conexant_init(codec); 993c9b443d4STobin Davis cxt5045_hp_automute(codec); 994c9b443d4STobin Davis return 0; 995c9b443d4STobin Davis } 996c9b443d4STobin Davis 997c9b443d4STobin Davis 998c9b443d4STobin Davis enum { 99915908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 100015908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 100115908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 10025218c892SJiang Zhe CXT5045_BENQ, 10032de3c232SJiang zhe CXT5045_LAPTOP_HP530, 1004c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1005c9b443d4STobin Davis CXT5045_TEST, 1006c9b443d4STobin Davis #endif 10071f8458a2STakashi Iwai CXT5045_AUTO, 1008f5fcc13cSTakashi Iwai CXT5045_MODELS 1009c9b443d4STobin Davis }; 1010c9b443d4STobin Davis 1011ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 101215908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 101315908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 101415908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 10155218c892SJiang Zhe [CXT5045_BENQ] = "benq", 10162de3c232SJiang zhe [CXT5045_LAPTOP_HP530] = "laptop-hp530", 1017c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1018f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 1019c9b443d4STobin Davis #endif 10201f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 1021f5fcc13cSTakashi Iwai }; 1022c9b443d4STobin Davis 102334cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 10242de3c232SJiang zhe SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 10256a9dccd6STakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 10265218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 102715908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 102815908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 10299e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 10309e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 103115908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 103215908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 103315908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1034dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 1035dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 103615908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1037c9b443d4STobin Davis {} 1038c9b443d4STobin Davis }; 1039c9b443d4STobin Davis 1040c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 1041c9b443d4STobin Davis { 1042c9b443d4STobin Davis struct conexant_spec *spec; 1043c9b443d4STobin Davis int board_config; 1044c9b443d4STobin Davis 10451f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10461f8458a2STakashi Iwai cxt5045_models, 10471f8458a2STakashi Iwai cxt5045_cfg_tbl); 10481f8458a2STakashi Iwai if (board_config < 0) 1049c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10501f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10511f8458a2STakashi Iwai return patch_conexant_auto(codec); 10521f8458a2STakashi Iwai 1053c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1054c9b443d4STobin Davis if (!spec) 1055c9b443d4STobin Davis return -ENOMEM; 1056c9b443d4STobin Davis codec->spec = spec; 10574f32456eSMichael Karcher codec->single_adc_amp = 1; 1058c9b443d4STobin Davis 1059c9b443d4STobin Davis spec->multiout.max_channels = 2; 1060c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1061c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1062c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1063c9b443d4STobin Davis spec->num_adc_nids = 1; 1064c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1065c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1066c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1067c9b443d4STobin Davis spec->num_mixers = 1; 1068c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1069c9b443d4STobin Davis spec->num_init_verbs = 1; 1070c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1071c9b443d4STobin Davis spec->spdif_route = 0; 10723507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10733507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10745cd57529STobin Davis 10753507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1076c9b443d4STobin Davis 1077c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1078c9b443d4STobin Davis 1079c9b443d4STobin Davis switch (board_config) { 108015908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10817f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1082c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1083c9b443d4STobin Davis spec->num_init_verbs = 2; 10847f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10857f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10867f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10877f29673bSTobin Davis break; 108815908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 108986376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10907f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10917f29673bSTobin Davis spec->num_init_verbs = 2; 10927f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1093c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1094c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1095c9b443d4STobin Davis break; 109615908c36SMarc Boucher default: 109715908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 109815908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 109915908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 110015908c36SMarc Boucher spec->num_init_verbs = 3; 110115908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 110215908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 110315908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 110415908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 110515908c36SMarc Boucher break; 11065218c892SJiang Zhe case CXT5045_BENQ: 11075218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11085218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 11095218c892SJiang Zhe spec->num_init_verbs = 1; 11105218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 11115218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 11125218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 11135218c892SJiang Zhe spec->num_mixers = 2; 11145218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 11155218c892SJiang Zhe break; 11162de3c232SJiang zhe case CXT5045_LAPTOP_HP530: 11172de3c232SJiang zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11182de3c232SJiang zhe spec->input_mux = &cxt5045_capture_source_hp530; 11192de3c232SJiang zhe spec->num_init_verbs = 2; 11202de3c232SJiang zhe spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 11212de3c232SJiang zhe spec->mixers[0] = cxt5045_mixers_hp530; 11222de3c232SJiang zhe codec->patch_ops.init = cxt5045_init; 11232de3c232SJiang zhe break; 1124c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1125c9b443d4STobin Davis case CXT5045_TEST: 1126c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1127c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1128c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 112915908c36SMarc Boucher break; 113015908c36SMarc Boucher 1131c9b443d4STobin Davis #endif 1132c9b443d4STobin Davis } 113348ecb7e8STakashi Iwai 1134031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1135031005f7STakashi Iwai case 0x103c: 11368f0f5ff6SDaniel T Chen case 0x1631: 11370b587fc4SDaniel T Chen case 0x1734: 11380ebf9e36SDaniel T Chen case 0x17aa: 11390ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 11400ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 11410ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 114248ecb7e8STakashi Iwai */ 114348ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 114448ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 114548ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 114648ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 114748ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1148031005f7STakashi Iwai break; 1149031005f7STakashi Iwai } 115048ecb7e8STakashi Iwai 11513507e2a8STakashi Iwai if (spec->beep_amp) 1152a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 11533507e2a8STakashi Iwai 1154c9b443d4STobin Davis return 0; 1155c9b443d4STobin Davis } 1156c9b443d4STobin Davis 1157c9b443d4STobin Davis 1158c9b443d4STobin Davis /* Conexant 5047 specific */ 115982f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1160c9b443d4STobin Davis 116134cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 116234cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 116334cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1164c9b443d4STobin Davis 116534cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11665cd57529STobin Davis { 2, NULL }, 11675cd57529STobin Davis }; 1168c9b443d4STobin Davis 116934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 117082f30040STobin Davis .num_items = 2, 117182f30040STobin Davis .items = { 117282f30040STobin Davis { "ExtMic", 0x2 }, 117382f30040STobin Davis { "Line-In", 0x1 }, 1174c9b443d4STobin Davis } 1175c9b443d4STobin Davis }; 1176c9b443d4STobin Davis 1177c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1178c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1179c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1180c9b443d4STobin Davis { 1181c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1182c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 118382f30040STobin Davis unsigned int bits; 1184c9b443d4STobin Davis 118582f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1186c9b443d4STobin Davis return 0; 1187c9b443d4STobin Davis 118882f30040STobin Davis /* toggle internal speakers mute depending of presence of 118982f30040STobin Davis * the headphone jack 119082f30040STobin Davis */ 119147fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11923b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11933b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11943b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11953b7523fcSTakashi Iwai */ 11965d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 119747fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 119847fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 119947fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 120047fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1201c9b443d4STobin Davis return 1; 1202c9b443d4STobin Davis } 1203c9b443d4STobin Davis 1204c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1205c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1206c9b443d4STobin Davis { 120782f30040STobin Davis struct conexant_spec *spec = codec->spec; 1208dd87da1cSTobin Davis unsigned int bits; 1209c9b443d4STobin Davis 1210d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1211dd87da1cSTobin Davis 121247fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 12133b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12145d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 121547fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1216c9b443d4STobin Davis } 1217c9b443d4STobin Davis 1218c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1219c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1220c9b443d4STobin Davis { 122134cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 12229f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12239f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1224c9b443d4STobin Davis {} 1225c9b443d4STobin Davis }; 122634cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 12279f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12289f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1229c9b443d4STobin Davis {} 1230c9b443d4STobin Davis }; 1231c9b443d4STobin Davis unsigned int present; 1232c9b443d4STobin Davis 1233d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1234c9b443d4STobin Davis if (present) 1235c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1236c9b443d4STobin Davis else 1237c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1238c9b443d4STobin Davis } 1239c9b443d4STobin Davis 1240c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1241c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1242c9b443d4STobin Davis unsigned int res) 1243c9b443d4STobin Davis { 12449f113e0eSMarc Boucher switch (res >> 26) { 1245c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1246c9b443d4STobin Davis cxt5047_hp_automute(codec); 1247c9b443d4STobin Davis break; 1248c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1249c9b443d4STobin Davis cxt5047_hp_automic(codec); 1250c9b443d4STobin Davis break; 1251c9b443d4STobin Davis } 1252c9b443d4STobin Davis } 1253c9b443d4STobin Davis 125434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1255df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1256df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12575f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1258c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1259c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1260c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1261c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 126282f30040STobin Davis { 126382f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 126482f30040STobin Davis .name = "Master Playback Switch", 126582f30040STobin Davis .info = cxt_eapd_info, 126682f30040STobin Davis .get = cxt_eapd_get, 1267c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1268c9b443d4STobin Davis .private_value = 0x13, 1269c9b443d4STobin Davis }, 1270c9b443d4STobin Davis 1271c9b443d4STobin Davis {} 1272c9b443d4STobin Davis }; 1273c9b443d4STobin Davis 127434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12753b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12765d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1277df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1278df481e41STakashi Iwai {} 1279df481e41STakashi Iwai }; 1280df481e41STakashi Iwai 128134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1282c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1283c9b443d4STobin Davis { } /* end */ 1284c9b443d4STobin Davis }; 1285c9b443d4STobin Davis 128634cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1287c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1288c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1289c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1290c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12917f29673bSTobin Davis /* HP, Speaker */ 1292b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12935b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12945b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12957f29673bSTobin Davis /* Record selector: Mic */ 12967f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12977f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12987f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12997f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1300c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1301c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1302c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1303c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1304c9b443d4STobin Davis /* SPDIF route: PCM */ 1305c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 130682f30040STobin Davis /* Enable unsolicited events */ 130782f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 130882f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1309c9b443d4STobin Davis { } /* end */ 1310c9b443d4STobin Davis }; 1311c9b443d4STobin Davis 1312c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 131334cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 13143b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1315c9b443d4STobin Davis {} 1316c9b443d4STobin Davis }; 1317c9b443d4STobin Davis 1318c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1319c9b443d4STobin Davis * configuration. 1320c9b443d4STobin Davis */ 1321c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 132234cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 132382f30040STobin Davis .num_items = 4, 1324c9b443d4STobin Davis .items = { 132582f30040STobin Davis { "LINE1 pin", 0x0 }, 132682f30040STobin Davis { "MIC1 pin", 0x1 }, 132782f30040STobin Davis { "MIC2 pin", 0x2 }, 132882f30040STobin Davis { "CD pin", 0x3 }, 1329c9b443d4STobin Davis }, 1330c9b443d4STobin Davis }; 1331c9b443d4STobin Davis 133234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1333c9b443d4STobin Davis 1334c9b443d4STobin Davis /* Output only controls */ 133582f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 133682f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 133782f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 133882f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1339c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1340c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1341c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1342c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 134382f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 134482f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 134582f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 134682f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1347c9b443d4STobin Davis 1348c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1349c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1350c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1351c9b443d4STobin Davis 135282f30040STobin Davis /* EAPD Switch Control */ 135382f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 135482f30040STobin Davis 1355c9b443d4STobin Davis /* Loopback mixer controls */ 135682f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 135782f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 135882f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 135982f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 136082f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 136182f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 136282f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 136382f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1364c9b443d4STobin Davis 136582f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 136682f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 136782f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 136882f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 136982f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 137082f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 137182f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 137282f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1373c9b443d4STobin Davis { 1374c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1375c9b443d4STobin Davis .name = "Input Source", 1376c9b443d4STobin Davis .info = conexant_mux_enum_info, 1377c9b443d4STobin Davis .get = conexant_mux_enum_get, 1378c9b443d4STobin Davis .put = conexant_mux_enum_put, 1379c9b443d4STobin Davis }, 1380854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13819f113e0eSMarc Boucher 1382c9b443d4STobin Davis { } /* end */ 1383c9b443d4STobin Davis }; 1384c9b443d4STobin Davis 138534cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1386c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1387c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1388c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1389c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1390c9b443d4STobin Davis 1391c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1392c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1393c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1394c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1395c9b443d4STobin Davis * control. 1396c9b443d4STobin Davis */ 1397c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1398c9b443d4STobin Davis 1399c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1400c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1401c9b443d4STobin Davis */ 1402c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1403c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1404c9b443d4STobin Davis 1405c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1406c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1407c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1408c9b443d4STobin Davis 1409c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1410c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1411c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1412c9b443d4STobin Davis * input/output buffers as needed. 1413c9b443d4STobin Davis */ 1414c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1415c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1416c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1417c9b443d4STobin Davis 1418c9b443d4STobin Davis /* Mute capture amp left and right */ 1419c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1420c9b443d4STobin Davis 1421c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1422c9b443d4STobin Davis * pin) 1423c9b443d4STobin Davis */ 1424c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1425c9b443d4STobin Davis 1426c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1427c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1428c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1429c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1430c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1431c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1432c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1433c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1434c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1435c9b443d4STobin Davis 1436c9b443d4STobin Davis { } 1437c9b443d4STobin Davis }; 1438c9b443d4STobin Davis #endif 1439c9b443d4STobin Davis 1440c9b443d4STobin Davis 1441c9b443d4STobin Davis /* initialize jack-sensing, too */ 1442c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1443c9b443d4STobin Davis { 1444c9b443d4STobin Davis conexant_init(codec); 1445c9b443d4STobin Davis cxt5047_hp_automute(codec); 1446c9b443d4STobin Davis return 0; 1447c9b443d4STobin Davis } 1448c9b443d4STobin Davis 1449c9b443d4STobin Davis 1450c9b443d4STobin Davis enum { 1451f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1452f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1453f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1454c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1455c9b443d4STobin Davis CXT5047_TEST, 1456c9b443d4STobin Davis #endif 1457fa5dadcbSTakashi Iwai CXT5047_AUTO, 1458f5fcc13cSTakashi Iwai CXT5047_MODELS 1459c9b443d4STobin Davis }; 1460c9b443d4STobin Davis 1461ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1462f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1463f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1464f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1465c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1466f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1467c9b443d4STobin Davis #endif 1468fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1469f5fcc13cSTakashi Iwai }; 1470c9b443d4STobin Davis 147134cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1472ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1473dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1474dea0a509STakashi Iwai CXT5047_LAPTOP), 1475f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1476c9b443d4STobin Davis {} 1477c9b443d4STobin Davis }; 1478c9b443d4STobin Davis 1479c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1480c9b443d4STobin Davis { 1481c9b443d4STobin Davis struct conexant_spec *spec; 1482c9b443d4STobin Davis int board_config; 1483c9b443d4STobin Davis 1484fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1485fa5dadcbSTakashi Iwai cxt5047_models, 1486fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1487fa5dadcbSTakashi Iwai if (board_config < 0) 1488c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1489fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1490fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1491fa5dadcbSTakashi Iwai 1492c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1493c9b443d4STobin Davis if (!spec) 1494c9b443d4STobin Davis return -ENOMEM; 1495c9b443d4STobin Davis codec->spec = spec; 14969421f954STakashi Iwai codec->pin_amp_workaround = 1; 1497c9b443d4STobin Davis 1498c9b443d4STobin Davis spec->multiout.max_channels = 2; 1499c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1500c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1501c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1502c9b443d4STobin Davis spec->num_adc_nids = 1; 1503c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1504c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1505c9b443d4STobin Davis spec->num_mixers = 1; 1506df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1507c9b443d4STobin Davis spec->num_init_verbs = 1; 1508c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1509c9b443d4STobin Davis spec->spdif_route = 0; 15105cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 15115cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1512c9b443d4STobin Davis 1513c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1514c9b443d4STobin Davis 1515c9b443d4STobin Davis switch (board_config) { 1516c9b443d4STobin Davis case CXT5047_LAPTOP: 1517df481e41STakashi Iwai spec->num_mixers = 2; 1518df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1519df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1520c9b443d4STobin Davis break; 1521c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1522df481e41STakashi Iwai spec->num_mixers = 2; 1523df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1524fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1525c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1526c9b443d4STobin Davis break; 1527c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 152882f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1529df481e41STakashi Iwai spec->num_mixers = 2; 1530df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1531c9b443d4STobin Davis spec->num_init_verbs = 2; 1532c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1533fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1534c9b443d4STobin Davis break; 1535c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1536c9b443d4STobin Davis case CXT5047_TEST: 1537c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1538c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1539c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1540fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1541c9b443d4STobin Davis #endif 1542c9b443d4STobin Davis } 1543dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1544025f206cSDaniel T Chen 1545025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1546025f206cSDaniel T Chen case 0x103c: 1547025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1548025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1549025f206cSDaniel T Chen * with 0 dB offset 0x17) 1550025f206cSDaniel T Chen */ 1551025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1552025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1553025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1554025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1555025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1556025f206cSDaniel T Chen break; 1557025f206cSDaniel T Chen } 1558025f206cSDaniel T Chen 1559c9b443d4STobin Davis return 0; 1560c9b443d4STobin Davis } 1561c9b443d4STobin Davis 1562461e2c78STakashi Iwai /* Conexant 5051 specific */ 156334cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 156434cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1565461e2c78STakashi Iwai 156634cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1567461e2c78STakashi Iwai { 2, NULL }, 1568461e2c78STakashi Iwai }; 1569461e2c78STakashi Iwai 1570461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1571461e2c78STakashi Iwai { 1572461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1573461e2c78STakashi Iwai unsigned int pinctl; 157423d2df5bSTakashi Iwai /* headphone pin */ 157523d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1576cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 157723d2df5bSTakashi Iwai /* speaker pin */ 1578461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1579cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1580a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1581f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1582cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1583461e2c78STakashi Iwai } 1584461e2c78STakashi Iwai 1585461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1586461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1587461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1588461e2c78STakashi Iwai { 1589461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1590461e2c78STakashi Iwai 1591461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1592461e2c78STakashi Iwai return 0; 1593461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1594461e2c78STakashi Iwai return 1; 1595461e2c78STakashi Iwai } 1596461e2c78STakashi Iwai 1597461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1598461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1599461e2c78STakashi Iwai { 160079d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1601461e2c78STakashi Iwai unsigned int present; 1602461e2c78STakashi Iwai 1603faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 160479d7d533STakashi Iwai return; 1605d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1606461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1607461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1608461e2c78STakashi Iwai present ? 0x01 : 0x00); 1609461e2c78STakashi Iwai } 1610461e2c78STakashi Iwai 1611461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1612461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1613461e2c78STakashi Iwai { 1614461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1615461e2c78STakashi Iwai unsigned int present; 1616461e2c78STakashi Iwai hda_nid_t new_adc; 1617461e2c78STakashi Iwai 1618faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 161979d7d533STakashi Iwai return; 1620d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1621461e2c78STakashi Iwai if (present) 1622461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1623461e2c78STakashi Iwai else 1624461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1625461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1626461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1627461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1628f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1629461e2c78STakashi Iwai spec->cur_adc = new_adc; 1630461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1631461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1632461e2c78STakashi Iwai spec->cur_adc_format); 1633461e2c78STakashi Iwai } 1634461e2c78STakashi Iwai } 1635461e2c78STakashi Iwai 1636461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1637461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1638461e2c78STakashi Iwai { 1639461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1640461e2c78STakashi Iwai 1641d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1642461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1643461e2c78STakashi Iwai } 1644461e2c78STakashi Iwai 1645461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1646461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1647461e2c78STakashi Iwai unsigned int res) 1648461e2c78STakashi Iwai { 1649461e2c78STakashi Iwai switch (res >> 26) { 1650461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1651461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1652461e2c78STakashi Iwai break; 1653461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1654461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1655461e2c78STakashi Iwai break; 1656461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1657461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1658461e2c78STakashi Iwai break; 1659461e2c78STakashi Iwai } 1660461e2c78STakashi Iwai } 1661461e2c78STakashi Iwai 166234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1663461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1664461e2c78STakashi Iwai { 1665461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1666461e2c78STakashi Iwai .name = "Master Playback Switch", 1667461e2c78STakashi Iwai .info = cxt_eapd_info, 1668461e2c78STakashi Iwai .get = cxt_eapd_get, 1669461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1670461e2c78STakashi Iwai .private_value = 0x1a, 1671461e2c78STakashi Iwai }, 16722c7a3fb3STakashi Iwai {} 16732c7a3fb3STakashi Iwai }; 1674461e2c78STakashi Iwai 167534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16762c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16772c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16788607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16798607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1680c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1681c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1682461e2c78STakashi Iwai {} 1683461e2c78STakashi Iwai }; 1684461e2c78STakashi Iwai 168534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1686461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1687461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16888607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16898607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1690461e2c78STakashi Iwai {} 1691461e2c78STakashi Iwai }; 1692461e2c78STakashi Iwai 169334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16944e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16954e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 169679d7d533STakashi Iwai {} 169779d7d533STakashi Iwai }; 169879d7d533STakashi Iwai 169934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 17005f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 17015f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1702cd9d95a5SKen Prox {} 1703cd9d95a5SKen Prox }; 1704cd9d95a5SKen Prox 170534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1706faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1707faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 17088607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 17098607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1710faddaa5dSTakashi Iwai {} 1711faddaa5dSTakashi Iwai }; 1712faddaa5dSTakashi Iwai 171334cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1714461e2c78STakashi Iwai /* Line in, Mic */ 1715461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1716461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1717461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1718461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1719461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1720461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1721461e2c78STakashi Iwai /* SPK */ 1722461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1723461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1724461e2c78STakashi Iwai /* HP, Amp */ 1725461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1726461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1727461e2c78STakashi Iwai /* DAC1 */ 1728461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172928c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1730461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1731461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1732461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1733461e2c78STakashi Iwai /* SPDIF route: PCM */ 17341965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1735461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1736461e2c78STakashi Iwai /* EAPD */ 1737461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1738461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1739461e2c78STakashi Iwai { } /* end */ 1740461e2c78STakashi Iwai }; 1741461e2c78STakashi Iwai 174234cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 174379d7d533STakashi Iwai /* Line in, Mic */ 174479d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 174579d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 174679d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174779d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174879d7d533STakashi Iwai /* SPK */ 174979d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 175079d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 175179d7d533STakashi Iwai /* HP, Amp */ 175279d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 175379d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 175479d7d533STakashi Iwai /* DAC1 */ 175579d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 175628c4edb7SDavid Henningsson /* Record selector: Internal mic */ 175779d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 175879d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 175979d7d533STakashi Iwai /* SPDIF route: PCM */ 176079d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 176179d7d533STakashi Iwai /* EAPD */ 176279d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 176379d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 176479d7d533STakashi Iwai { } /* end */ 176579d7d533STakashi Iwai }; 176679d7d533STakashi Iwai 176734cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1768cd9d95a5SKen Prox /* Line in, Mic */ 176930ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1770cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1771cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1772cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1773cd9d95a5SKen Prox /* SPK */ 1774cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1775cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1776cd9d95a5SKen Prox /* HP, Amp */ 1777cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1778cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1779cd9d95a5SKen Prox /* DAC1 */ 1780cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 178128c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1782cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1783cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1784cd9d95a5SKen Prox /* SPDIF route: PCM */ 1785cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1786cd9d95a5SKen Prox /* EAPD */ 1787cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1788cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1789cd9d95a5SKen Prox { } /* end */ 1790cd9d95a5SKen Prox }; 1791cd9d95a5SKen Prox 17926953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17936953e552STakashi Iwai unsigned int event) 17946953e552STakashi Iwai { 17956953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17966953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17976953e552STakashi Iwai AC_USRSP_EN | event); 17986953e552STakashi Iwai } 17996953e552STakashi Iwai 180034cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1801f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1802f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1803f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1804f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1805f7154de2SHerton Ronaldo Krzesinski }; 1806f7154de2SHerton Ronaldo Krzesinski 1807461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1808461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1809461e2c78STakashi Iwai { 18106953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 18116953e552STakashi Iwai 1812461e2c78STakashi Iwai conexant_init(codec); 18136953e552STakashi Iwai 18146953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 18156953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 18166953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 18176953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 18186953e552STakashi Iwai 1819461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1820461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1821461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1822461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1823461e2c78STakashi Iwai } 1824461e2c78STakashi Iwai return 0; 1825461e2c78STakashi Iwai } 1826461e2c78STakashi Iwai 1827461e2c78STakashi Iwai 1828461e2c78STakashi Iwai enum { 1829461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1830461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 183179d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1832cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1833faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1834f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 18356764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1836461e2c78STakashi Iwai CXT5051_MODELS 1837461e2c78STakashi Iwai }; 1838461e2c78STakashi Iwai 1839ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1840461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1841461e2c78STakashi Iwai [CXT5051_HP] = "hp", 184279d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 18435f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1844faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1845f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 18466764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1847461e2c78STakashi Iwai }; 1848461e2c78STakashi Iwai 184934cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 185079d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 18511812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 18525f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1853faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1854461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1855461e2c78STakashi Iwai CXT5051_LAPTOP), 1856461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1857f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1858461e2c78STakashi Iwai {} 1859461e2c78STakashi Iwai }; 1860461e2c78STakashi Iwai 1861461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1862461e2c78STakashi Iwai { 1863461e2c78STakashi Iwai struct conexant_spec *spec; 1864461e2c78STakashi Iwai int board_config; 1865461e2c78STakashi Iwai 18666764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18676764bcefSTakashi Iwai cxt5051_models, 18686764bcefSTakashi Iwai cxt5051_cfg_tbl); 18696764bcefSTakashi Iwai if (board_config < 0) 1870c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18711f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18726764bcefSTakashi Iwai return patch_conexant_auto(codec); 18736764bcefSTakashi Iwai 1874461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1875461e2c78STakashi Iwai if (!spec) 1876461e2c78STakashi Iwai return -ENOMEM; 1877461e2c78STakashi Iwai codec->spec = spec; 18789421f954STakashi Iwai codec->pin_amp_workaround = 1; 1879461e2c78STakashi Iwai 1880461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1881461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1882461e2c78STakashi Iwai 1883461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1884461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1885461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1886461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1887461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1888461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18892c7a3fb3STakashi Iwai spec->num_mixers = 2; 18902c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18912c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1892461e2c78STakashi Iwai spec->num_init_verbs = 1; 1893461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1894461e2c78STakashi Iwai spec->spdif_route = 0; 1895461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1896461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1897461e2c78STakashi Iwai spec->cur_adc = 0; 1898461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1899461e2c78STakashi Iwai 19003507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 19013507e2a8STakashi Iwai 190279d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 190379d7d533STakashi Iwai 1904faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1905461e2c78STakashi Iwai switch (board_config) { 1906461e2c78STakashi Iwai case CXT5051_HP: 1907461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1908461e2c78STakashi Iwai break; 190979d7d533STakashi Iwai case CXT5051_HP_DV6736: 191079d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 191179d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1912faddaa5dSTakashi Iwai spec->auto_mic = 0; 191379d7d533STakashi Iwai break; 1914cd9d95a5SKen Prox case CXT5051_F700: 1915cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1916cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1917faddaa5dSTakashi Iwai spec->auto_mic = 0; 1918faddaa5dSTakashi Iwai break; 1919faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1920faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1921faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1922cd9d95a5SKen Prox break; 1923f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1924f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1925f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1926f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1927f7154de2SHerton Ronaldo Krzesinski break; 1928461e2c78STakashi Iwai } 1929461e2c78STakashi Iwai 19303507e2a8STakashi Iwai if (spec->beep_amp) 1931a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 19323507e2a8STakashi Iwai 1933461e2c78STakashi Iwai return 0; 1934461e2c78STakashi Iwai } 1935461e2c78STakashi Iwai 19360fb67e98SDaniel Drake /* Conexant 5066 specific */ 19370fb67e98SDaniel Drake 193834cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 193934cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 194034cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 194134cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 19420fb67e98SDaniel Drake 1943dbaccc0cSDaniel Drake /* OLPC's microphone port is DC coupled for use with external sensors, 1944dbaccc0cSDaniel Drake * therefore we use a 50% mic bias in order to center the input signal with 1945dbaccc0cSDaniel Drake * the DC input range of the codec. */ 1946dbaccc0cSDaniel Drake #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 1947dbaccc0cSDaniel Drake 194834cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 19490fb67e98SDaniel Drake { 2, NULL }, 19500fb67e98SDaniel Drake }; 19510fb67e98SDaniel Drake 1952a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1953a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1954a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1955a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1956a3de8ab8STakashi Iwai 19570fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 19580fb67e98SDaniel Drake { 19590fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19600fb67e98SDaniel Drake unsigned int pinctl; 19610fb67e98SDaniel Drake 19623a253445SJohn Baboval snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 19633a253445SJohn Baboval spec->hp_present, spec->cur_eapd); 19640fb67e98SDaniel Drake 19650fb67e98SDaniel Drake /* Port A (HP) */ 1966a3de8ab8STakashi Iwai pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; 1967cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x19, pinctl); 19680fb67e98SDaniel Drake 19690fb67e98SDaniel Drake /* Port D (HP/LO) */ 1970a3de8ab8STakashi Iwai pinctl = spec->cur_eapd ? spec->port_d_mode : 0; 1971a3de8ab8STakashi Iwai if (spec->dell_automute || spec->thinkpad) { 1972a3de8ab8STakashi Iwai /* Mute if Port A is connected */ 1973a3de8ab8STakashi Iwai if (hp_port_a_present(spec)) 19743a253445SJohn Baboval pinctl = 0; 19753a253445SJohn Baboval } else { 1976a3de8ab8STakashi Iwai /* Thinkpad/Dell doesn't give pin-D status */ 1977a3de8ab8STakashi Iwai if (!hp_port_d_present(spec)) 1978a3de8ab8STakashi Iwai pinctl = 0; 19793a253445SJohn Baboval } 1980cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1c, pinctl); 19810fb67e98SDaniel Drake 19820fb67e98SDaniel Drake /* CLASS_D AMP */ 19830fb67e98SDaniel Drake pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1984cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1f, pinctl); 19850fb67e98SDaniel Drake } 19860fb67e98SDaniel Drake 19870fb67e98SDaniel Drake /* turn on/off EAPD (+ mute HP) as a master switch */ 19880fb67e98SDaniel Drake static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, 19890fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 19900fb67e98SDaniel Drake { 19910fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 19920fb67e98SDaniel Drake 19930fb67e98SDaniel Drake if (!cxt_eapd_put(kcontrol, ucontrol)) 19940fb67e98SDaniel Drake return 0; 19950fb67e98SDaniel Drake 19960fb67e98SDaniel Drake cxt5066_update_speaker(codec); 19970fb67e98SDaniel Drake return 1; 19980fb67e98SDaniel Drake } 19990fb67e98SDaniel Drake 2000c4cfe66cSDaniel Drake static const struct hda_input_mux cxt5066_olpc_dc_bias = { 2001c4cfe66cSDaniel Drake .num_items = 3, 2002c4cfe66cSDaniel Drake .items = { 2003c4cfe66cSDaniel Drake { "Off", PIN_IN }, 2004c4cfe66cSDaniel Drake { "50%", PIN_VREF50 }, 2005c4cfe66cSDaniel Drake { "80%", PIN_VREF80 }, 2006c4cfe66cSDaniel Drake }, 2007c4cfe66cSDaniel Drake }; 2008c4cfe66cSDaniel Drake 2009c4cfe66cSDaniel Drake static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) 2010c4cfe66cSDaniel Drake { 2011c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2012c4cfe66cSDaniel Drake /* Even though port F is the DC input, the bias is controlled on port B. 2013c4cfe66cSDaniel Drake * we also leave that port as an active input (but unselected) in DC mode 2014c4cfe66cSDaniel Drake * just in case that is necessary to make the bias setting take effect. */ 2015cdd03cedSTakashi Iwai return snd_hda_set_pin_ctl_cache(codec, 0x1a, 2016c4cfe66cSDaniel Drake cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); 2017c4cfe66cSDaniel Drake } 2018c4cfe66cSDaniel Drake 201975f8991dSDaniel Drake /* OLPC defers mic widget control until when capture is started because the 202075f8991dSDaniel Drake * microphone LED comes on as soon as these settings are put in place. if we 202175f8991dSDaniel Drake * did this before recording, it would give the false indication that recording 202275f8991dSDaniel Drake * is happening when it is not. */ 202375f8991dSDaniel Drake static void cxt5066_olpc_select_mic(struct hda_codec *codec) 20240fb67e98SDaniel Drake { 2025dbaccc0cSDaniel Drake struct conexant_spec *spec = codec->spec; 202675f8991dSDaniel Drake if (!spec->recording) 202775f8991dSDaniel Drake return; 20280fb67e98SDaniel Drake 2029c4cfe66cSDaniel Drake if (spec->dc_enable) { 2030c4cfe66cSDaniel Drake /* in DC mode we ignore presence detection and just use the jack 2031c4cfe66cSDaniel Drake * through our special DC port */ 2032c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2033c4cfe66cSDaniel Drake /* disble internal mic, port C */ 2034c4cfe66cSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2035c4cfe66cSDaniel Drake 2036c4cfe66cSDaniel Drake /* enable DC capture, port F */ 2037c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2038c4cfe66cSDaniel Drake {}, 2039c4cfe66cSDaniel Drake }; 2040c4cfe66cSDaniel Drake 2041c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2042c4cfe66cSDaniel Drake /* port B input disabled (and bias set) through the following call */ 2043c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 2044c4cfe66cSDaniel Drake return; 2045c4cfe66cSDaniel Drake } 2046c4cfe66cSDaniel Drake 2047c4cfe66cSDaniel Drake /* disable DC (port F) */ 2048cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1e, 0); 2049c4cfe66cSDaniel Drake 205075f8991dSDaniel Drake /* external mic, port B */ 2051cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, 205275f8991dSDaniel Drake spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); 20530fb67e98SDaniel Drake 205475f8991dSDaniel Drake /* internal mic, port C */ 2055cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, 205675f8991dSDaniel Drake spec->ext_mic_present ? 0 : PIN_VREF80); 205775f8991dSDaniel Drake } 20580fb67e98SDaniel Drake 205975f8991dSDaniel Drake /* toggle input of built-in and mic jack appropriately */ 206075f8991dSDaniel Drake static void cxt5066_olpc_automic(struct hda_codec *codec) 206175f8991dSDaniel Drake { 206275f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 20630fb67e98SDaniel Drake unsigned int present; 20640fb67e98SDaniel Drake 2065c4cfe66cSDaniel Drake if (spec->dc_enable) /* don't do presence detection in DC mode */ 2066c4cfe66cSDaniel Drake return; 2067c4cfe66cSDaniel Drake 206875f8991dSDaniel Drake present = snd_hda_codec_read(codec, 0x1a, 0, 206975f8991dSDaniel Drake AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 207075f8991dSDaniel Drake if (present) 20710fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone detected\n"); 207275f8991dSDaniel Drake else 20730fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone absent\n"); 207475f8991dSDaniel Drake 207575f8991dSDaniel Drake snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 207675f8991dSDaniel Drake present ? 0 : 1); 207775f8991dSDaniel Drake spec->ext_mic_present = !!present; 207875f8991dSDaniel Drake 207975f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 20800fb67e98SDaniel Drake } 20810fb67e98SDaniel Drake 208295a618bdSEinar Rünkaru /* toggle input of built-in digital mic and mic jack appropriately */ 208395a618bdSEinar Rünkaru static void cxt5066_vostro_automic(struct hda_codec *codec) 208495a618bdSEinar Rünkaru { 208595a618bdSEinar Rünkaru unsigned int present; 208695a618bdSEinar Rünkaru 208795a618bdSEinar Rünkaru struct hda_verb ext_mic_present[] = { 208895a618bdSEinar Rünkaru /* enable external mic, port B */ 208975f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 209095a618bdSEinar Rünkaru 209195a618bdSEinar Rünkaru /* switch to external mic input */ 209295a618bdSEinar Rünkaru {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 209395a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 209495a618bdSEinar Rünkaru 209595a618bdSEinar Rünkaru /* disable internal digital mic */ 209695a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 209795a618bdSEinar Rünkaru {} 209895a618bdSEinar Rünkaru }; 209934cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 210095a618bdSEinar Rünkaru /* enable internal mic, port C */ 210195a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 210295a618bdSEinar Rünkaru 210395a618bdSEinar Rünkaru /* switch to internal mic input */ 210495a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 210595a618bdSEinar Rünkaru 210695a618bdSEinar Rünkaru /* disable external mic, port B */ 210795a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 210895a618bdSEinar Rünkaru {} 210995a618bdSEinar Rünkaru }; 211095a618bdSEinar Rünkaru 211195a618bdSEinar Rünkaru present = snd_hda_jack_detect(codec, 0x1a); 211295a618bdSEinar Rünkaru if (present) { 211395a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone detected\n"); 211495a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 211595a618bdSEinar Rünkaru } else { 211695a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone absent\n"); 211795a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_absent); 211895a618bdSEinar Rünkaru } 211995a618bdSEinar Rünkaru } 212095a618bdSEinar Rünkaru 2121cfd3d8dcSGreg Alexander /* toggle input of built-in digital mic and mic jack appropriately */ 2122cfd3d8dcSGreg Alexander static void cxt5066_ideapad_automic(struct hda_codec *codec) 2123cfd3d8dcSGreg Alexander { 2124cfd3d8dcSGreg Alexander unsigned int present; 2125cfd3d8dcSGreg Alexander 2126cfd3d8dcSGreg Alexander struct hda_verb ext_mic_present[] = { 2127cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 2128cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2129cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2130cfd3d8dcSGreg Alexander {} 2131cfd3d8dcSGreg Alexander }; 213234cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 2133cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 2134cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2135cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2136cfd3d8dcSGreg Alexander {} 2137cfd3d8dcSGreg Alexander }; 2138cfd3d8dcSGreg Alexander 2139cfd3d8dcSGreg Alexander present = snd_hda_jack_detect(codec, 0x1b); 2140cfd3d8dcSGreg Alexander if (present) { 2141cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone detected\n"); 2142cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2143cfd3d8dcSGreg Alexander } else { 2144cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone absent\n"); 2145cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_absent); 2146cfd3d8dcSGreg Alexander } 2147cfd3d8dcSGreg Alexander } 2148cfd3d8dcSGreg Alexander 2149a1d6906eSDavid Henningsson 2150a1d6906eSDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2151a1d6906eSDavid Henningsson static void cxt5066_asus_automic(struct hda_codec *codec) 2152a1d6906eSDavid Henningsson { 2153a1d6906eSDavid Henningsson unsigned int present; 2154a1d6906eSDavid Henningsson 2155a1d6906eSDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2156a1d6906eSDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2157a1d6906eSDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2158a1d6906eSDavid Henningsson present ? 1 : 0); 2159a1d6906eSDavid Henningsson } 2160a1d6906eSDavid Henningsson 2161a1d6906eSDavid Henningsson 2162048e78a5SDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2163048e78a5SDavid Henningsson static void cxt5066_hp_laptop_automic(struct hda_codec *codec) 2164048e78a5SDavid Henningsson { 2165048e78a5SDavid Henningsson unsigned int present; 2166048e78a5SDavid Henningsson 2167048e78a5SDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2168048e78a5SDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2169048e78a5SDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2170048e78a5SDavid Henningsson present ? 1 : 3); 2171048e78a5SDavid Henningsson } 2172048e78a5SDavid Henningsson 2173048e78a5SDavid Henningsson 21747b2bfdbcSJens Taprogge /* toggle input of built-in digital mic and mic jack appropriately 21757b2bfdbcSJens Taprogge order is: external mic -> dock mic -> interal mic */ 21767b2bfdbcSJens Taprogge static void cxt5066_thinkpad_automic(struct hda_codec *codec) 21777b2bfdbcSJens Taprogge { 21787b2bfdbcSJens Taprogge unsigned int ext_present, dock_present; 21797b2bfdbcSJens Taprogge 218034cbe3a6STakashi Iwai static const struct hda_verb ext_mic_present[] = { 21817b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21827b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 21837b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21847b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21857b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21867b2bfdbcSJens Taprogge {} 21877b2bfdbcSJens Taprogge }; 218834cbe3a6STakashi Iwai static const struct hda_verb dock_mic_present[] = { 21897b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21907b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 21917b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21927b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21937b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21947b2bfdbcSJens Taprogge {} 21957b2bfdbcSJens Taprogge }; 219634cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 21977b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 21987b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 21997b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 22007b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 22017b2bfdbcSJens Taprogge {} 22027b2bfdbcSJens Taprogge }; 22037b2bfdbcSJens Taprogge 22047b2bfdbcSJens Taprogge ext_present = snd_hda_jack_detect(codec, 0x1b); 22057b2bfdbcSJens Taprogge dock_present = snd_hda_jack_detect(codec, 0x1a); 22067b2bfdbcSJens Taprogge if (ext_present) { 22077b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone detected\n"); 22087b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 22097b2bfdbcSJens Taprogge } else if (dock_present) { 22107b2bfdbcSJens Taprogge snd_printdd("CXT5066: dock microphone detected\n"); 22117b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 22127b2bfdbcSJens Taprogge } else { 22137b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone absent\n"); 22147b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_absent); 22157b2bfdbcSJens Taprogge } 22167b2bfdbcSJens Taprogge } 22177b2bfdbcSJens Taprogge 22180fb67e98SDaniel Drake /* mute internal speaker if HP is plugged */ 22190fb67e98SDaniel Drake static void cxt5066_hp_automute(struct hda_codec *codec) 22200fb67e98SDaniel Drake { 22210fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 22220fb67e98SDaniel Drake unsigned int portA, portD; 22230fb67e98SDaniel Drake 22240fb67e98SDaniel Drake /* Port A */ 2225d56757abSTakashi Iwai portA = snd_hda_jack_detect(codec, 0x19); 22260fb67e98SDaniel Drake 22270fb67e98SDaniel Drake /* Port D */ 2228d56757abSTakashi Iwai portD = snd_hda_jack_detect(codec, 0x1c); 22290fb67e98SDaniel Drake 2230a3de8ab8STakashi Iwai spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2231a3de8ab8STakashi Iwai spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 22320fb67e98SDaniel Drake snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 22330fb67e98SDaniel Drake portA, portD, spec->hp_present); 22340fb67e98SDaniel Drake cxt5066_update_speaker(codec); 22350fb67e98SDaniel Drake } 22360fb67e98SDaniel Drake 223702b6b5b6SDavid Henningsson /* Dispatch the right mic autoswitch function */ 223802b6b5b6SDavid Henningsson static void cxt5066_automic(struct hda_codec *codec) 223902b6b5b6SDavid Henningsson { 224002b6b5b6SDavid Henningsson struct conexant_spec *spec = codec->spec; 224102b6b5b6SDavid Henningsson 224202b6b5b6SDavid Henningsson if (spec->dell_vostro) 224302b6b5b6SDavid Henningsson cxt5066_vostro_automic(codec); 224402b6b5b6SDavid Henningsson else if (spec->ideapad) 224502b6b5b6SDavid Henningsson cxt5066_ideapad_automic(codec); 224602b6b5b6SDavid Henningsson else if (spec->thinkpad) 224702b6b5b6SDavid Henningsson cxt5066_thinkpad_automic(codec); 224802b6b5b6SDavid Henningsson else if (spec->hp_laptop) 224902b6b5b6SDavid Henningsson cxt5066_hp_laptop_automic(codec); 2250a1d6906eSDavid Henningsson else if (spec->asus) 2251a1d6906eSDavid Henningsson cxt5066_asus_automic(codec); 225202b6b5b6SDavid Henningsson } 225302b6b5b6SDavid Henningsson 22540fb67e98SDaniel Drake /* unsolicited event for jack sensing */ 225575f8991dSDaniel Drake static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 22560fb67e98SDaniel Drake { 2257c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 22580fb67e98SDaniel Drake snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 22590fb67e98SDaniel Drake switch (res >> 26) { 22600fb67e98SDaniel Drake case CONEXANT_HP_EVENT: 22610fb67e98SDaniel Drake cxt5066_hp_automute(codec); 22620fb67e98SDaniel Drake break; 22630fb67e98SDaniel Drake case CONEXANT_MIC_EVENT: 2264c4cfe66cSDaniel Drake /* ignore mic events in DC mode; we're always using the jack */ 2265c4cfe66cSDaniel Drake if (!spec->dc_enable) 226675f8991dSDaniel Drake cxt5066_olpc_automic(codec); 22670fb67e98SDaniel Drake break; 22680fb67e98SDaniel Drake } 22690fb67e98SDaniel Drake } 22700fb67e98SDaniel Drake 227195a618bdSEinar Rünkaru /* unsolicited event for jack sensing */ 227202b6b5b6SDavid Henningsson static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 227395a618bdSEinar Rünkaru { 227402b6b5b6SDavid Henningsson snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 227595a618bdSEinar Rünkaru switch (res >> 26) { 227695a618bdSEinar Rünkaru case CONEXANT_HP_EVENT: 227795a618bdSEinar Rünkaru cxt5066_hp_automute(codec); 227895a618bdSEinar Rünkaru break; 227995a618bdSEinar Rünkaru case CONEXANT_MIC_EVENT: 228002b6b5b6SDavid Henningsson cxt5066_automic(codec); 228195a618bdSEinar Rünkaru break; 228295a618bdSEinar Rünkaru } 228395a618bdSEinar Rünkaru } 228495a618bdSEinar Rünkaru 22857b2bfdbcSJens Taprogge 22860fb67e98SDaniel Drake static const struct hda_input_mux cxt5066_analog_mic_boost = { 22870fb67e98SDaniel Drake .num_items = 5, 22880fb67e98SDaniel Drake .items = { 22890fb67e98SDaniel Drake { "0dB", 0 }, 22900fb67e98SDaniel Drake { "10dB", 1 }, 22910fb67e98SDaniel Drake { "20dB", 2 }, 22920fb67e98SDaniel Drake { "30dB", 3 }, 22930fb67e98SDaniel Drake { "40dB", 4 }, 22940fb67e98SDaniel Drake }, 22950fb67e98SDaniel Drake }; 22960fb67e98SDaniel Drake 2297cfd3d8dcSGreg Alexander static void cxt5066_set_mic_boost(struct hda_codec *codec) 2298c4cfe66cSDaniel Drake { 2299c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2300cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x17, 0, 2301c4cfe66cSDaniel Drake AC_VERB_SET_AMP_GAIN_MUTE, 2302c4cfe66cSDaniel Drake AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2303c4cfe66cSDaniel Drake cxt5066_analog_mic_boost.items[spec->mic_boost].index); 23047b2bfdbcSJens Taprogge if (spec->ideapad || spec->thinkpad) { 2305cfd3d8dcSGreg Alexander /* adjust the internal mic as well...it is not through 0x17 */ 2306cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x23, 0, 2307cfd3d8dcSGreg Alexander AC_VERB_SET_AMP_GAIN_MUTE, 2308cfd3d8dcSGreg Alexander AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | 2309cfd3d8dcSGreg Alexander cxt5066_analog_mic_boost. 2310cfd3d8dcSGreg Alexander items[spec->mic_boost].index); 2311cfd3d8dcSGreg Alexander } 2312c4cfe66cSDaniel Drake } 2313c4cfe66cSDaniel Drake 23140fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 23150fb67e98SDaniel Drake struct snd_ctl_elem_info *uinfo) 23160fb67e98SDaniel Drake { 23170fb67e98SDaniel Drake return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); 23180fb67e98SDaniel Drake } 23190fb67e98SDaniel Drake 23200fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, 23210fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23220fb67e98SDaniel Drake { 23230fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2324c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2325c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->mic_boost; 23260fb67e98SDaniel Drake return 0; 23270fb67e98SDaniel Drake } 23280fb67e98SDaniel Drake 23290fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, 23300fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23310fb67e98SDaniel Drake { 23320fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2333c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 23340fb67e98SDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 23350fb67e98SDaniel Drake unsigned int idx; 23360fb67e98SDaniel Drake idx = ucontrol->value.enumerated.item[0]; 23370fb67e98SDaniel Drake if (idx >= imux->num_items) 23380fb67e98SDaniel Drake idx = imux->num_items - 1; 23390fb67e98SDaniel Drake 2340c4cfe66cSDaniel Drake spec->mic_boost = idx; 2341c4cfe66cSDaniel Drake if (!spec->dc_enable) 2342c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2343c4cfe66cSDaniel Drake return 1; 2344c4cfe66cSDaniel Drake } 23450fb67e98SDaniel Drake 2346c4cfe66cSDaniel Drake static void cxt5066_enable_dc(struct hda_codec *codec) 2347c4cfe66cSDaniel Drake { 2348c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2349c4cfe66cSDaniel Drake /* disable gain */ 2350c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2351c4cfe66cSDaniel Drake 2352c4cfe66cSDaniel Drake /* switch to DC input */ 2353c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_CONNECT_SEL, 3}, 2354c4cfe66cSDaniel Drake {} 2355c4cfe66cSDaniel Drake }; 2356c4cfe66cSDaniel Drake 2357c4cfe66cSDaniel Drake /* configure as input source */ 2358c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2359c4cfe66cSDaniel Drake cxt5066_olpc_select_mic(codec); /* also sets configured bias */ 2360c4cfe66cSDaniel Drake } 2361c4cfe66cSDaniel Drake 2362c4cfe66cSDaniel Drake static void cxt5066_disable_dc(struct hda_codec *codec) 2363c4cfe66cSDaniel Drake { 2364c4cfe66cSDaniel Drake /* reconfigure input source */ 2365c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2366c4cfe66cSDaniel Drake /* automic also selects the right mic if we're recording */ 2367c4cfe66cSDaniel Drake cxt5066_olpc_automic(codec); 2368c4cfe66cSDaniel Drake } 2369c4cfe66cSDaniel Drake 2370c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, 2371c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2372c4cfe66cSDaniel Drake { 2373c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2374c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2375c4cfe66cSDaniel Drake ucontrol->value.integer.value[0] = spec->dc_enable; 2376c4cfe66cSDaniel Drake return 0; 2377c4cfe66cSDaniel Drake } 2378c4cfe66cSDaniel Drake 2379c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, 2380c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2381c4cfe66cSDaniel Drake { 2382c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2383c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2384c4cfe66cSDaniel Drake int dc_enable = !!ucontrol->value.integer.value[0]; 2385c4cfe66cSDaniel Drake 2386c4cfe66cSDaniel Drake if (dc_enable == spec->dc_enable) 2387c4cfe66cSDaniel Drake return 0; 2388c4cfe66cSDaniel Drake 2389c4cfe66cSDaniel Drake spec->dc_enable = dc_enable; 2390c4cfe66cSDaniel Drake if (dc_enable) 2391c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2392c4cfe66cSDaniel Drake else 2393c4cfe66cSDaniel Drake cxt5066_disable_dc(codec); 2394c4cfe66cSDaniel Drake 2395c4cfe66cSDaniel Drake return 1; 2396c4cfe66cSDaniel Drake } 2397c4cfe66cSDaniel Drake 2398c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 2399c4cfe66cSDaniel Drake struct snd_ctl_elem_info *uinfo) 2400c4cfe66cSDaniel Drake { 2401c4cfe66cSDaniel Drake return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); 2402c4cfe66cSDaniel Drake } 2403c4cfe66cSDaniel Drake 2404c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 2405c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2406c4cfe66cSDaniel Drake { 2407c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2408c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2409c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 2410c4cfe66cSDaniel Drake return 0; 2411c4cfe66cSDaniel Drake } 2412c4cfe66cSDaniel Drake 2413c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 2414c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2415c4cfe66cSDaniel Drake { 2416c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2417c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2418c4cfe66cSDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2419c4cfe66cSDaniel Drake unsigned int idx; 2420c4cfe66cSDaniel Drake 2421c4cfe66cSDaniel Drake idx = ucontrol->value.enumerated.item[0]; 2422c4cfe66cSDaniel Drake if (idx >= imux->num_items) 2423c4cfe66cSDaniel Drake idx = imux->num_items - 1; 2424c4cfe66cSDaniel Drake 2425c4cfe66cSDaniel Drake spec->dc_input_bias = idx; 2426c4cfe66cSDaniel Drake if (spec->dc_enable) 2427c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 24280fb67e98SDaniel Drake return 1; 24290fb67e98SDaniel Drake } 24300fb67e98SDaniel Drake 243175f8991dSDaniel Drake static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) 243275f8991dSDaniel Drake { 243375f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 243475f8991dSDaniel Drake /* mark as recording and configure the microphone widget so that the 243575f8991dSDaniel Drake * recording LED comes on. */ 243675f8991dSDaniel Drake spec->recording = 1; 243775f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 243875f8991dSDaniel Drake } 243975f8991dSDaniel Drake 244075f8991dSDaniel Drake static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) 244175f8991dSDaniel Drake { 244275f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 244375f8991dSDaniel Drake const struct hda_verb disable_mics[] = { 244475f8991dSDaniel Drake /* disable external mic, port B */ 244575f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 244675f8991dSDaniel Drake 244775f8991dSDaniel Drake /* disble internal mic, port C */ 244875f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2449c4cfe66cSDaniel Drake 2450c4cfe66cSDaniel Drake /* disable DC capture, port F */ 2451c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 245275f8991dSDaniel Drake {}, 245375f8991dSDaniel Drake }; 245475f8991dSDaniel Drake 245575f8991dSDaniel Drake snd_hda_sequence_write(codec, disable_mics); 245675f8991dSDaniel Drake spec->recording = 0; 245775f8991dSDaniel Drake } 245875f8991dSDaniel Drake 2459f6a2491cSAndy Robinson static void conexant_check_dig_outs(struct hda_codec *codec, 246034cbe3a6STakashi Iwai const hda_nid_t *dig_pins, 2461f6a2491cSAndy Robinson int num_pins) 2462f6a2491cSAndy Robinson { 2463f6a2491cSAndy Robinson struct conexant_spec *spec = codec->spec; 2464f6a2491cSAndy Robinson hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; 2465f6a2491cSAndy Robinson int i; 2466f6a2491cSAndy Robinson 2467f6a2491cSAndy Robinson for (i = 0; i < num_pins; i++, dig_pins++) { 2468f6a2491cSAndy Robinson unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); 2469f6a2491cSAndy Robinson if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) 2470f6a2491cSAndy Robinson continue; 2471f6a2491cSAndy Robinson if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) 2472f6a2491cSAndy Robinson continue; 2473f6a2491cSAndy Robinson } 2474f6a2491cSAndy Robinson } 2475f6a2491cSAndy Robinson 247634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5066_capture_source = { 24770fb67e98SDaniel Drake .num_items = 4, 24780fb67e98SDaniel Drake .items = { 24790fb67e98SDaniel Drake { "Mic B", 0 }, 24800fb67e98SDaniel Drake { "Mic C", 1 }, 24810fb67e98SDaniel Drake { "Mic E", 2 }, 24820fb67e98SDaniel Drake { "Mic F", 3 }, 24830fb67e98SDaniel Drake }, 24840fb67e98SDaniel Drake }; 24850fb67e98SDaniel Drake 248634cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { 24870fb67e98SDaniel Drake .ops = &snd_hda_bind_vol, 24880fb67e98SDaniel Drake .values = { 24890fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24900fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24910fb67e98SDaniel Drake 0 24920fb67e98SDaniel Drake }, 24930fb67e98SDaniel Drake }; 24940fb67e98SDaniel Drake 249534cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { 24960fb67e98SDaniel Drake .ops = &snd_hda_bind_sw, 24970fb67e98SDaniel Drake .values = { 24980fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24990fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 25000fb67e98SDaniel Drake 0 25010fb67e98SDaniel Drake }, 25020fb67e98SDaniel Drake }; 25030fb67e98SDaniel Drake 250434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master[] = { 25050fb67e98SDaniel Drake HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 25060fb67e98SDaniel Drake {} 25070fb67e98SDaniel Drake }; 25080fb67e98SDaniel Drake 250934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { 25100fb67e98SDaniel Drake { 25110fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25120fb67e98SDaniel Drake .name = "Master Playback Volume", 25130fb67e98SDaniel Drake .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 25140fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_READ | 25150fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, 25165e26dfd0SJaroslav Kysela .subdevice = HDA_SUBDEV_AMP_FLAG, 25170fb67e98SDaniel Drake .info = snd_hda_mixer_amp_volume_info, 25180fb67e98SDaniel Drake .get = snd_hda_mixer_amp_volume_get, 25190fb67e98SDaniel Drake .put = snd_hda_mixer_amp_volume_put, 25200fb67e98SDaniel Drake .tlv = { .c = snd_hda_mixer_amp_tlv }, 25210fb67e98SDaniel Drake /* offset by 28 volume steps to limit minimum gain to -46dB */ 25220fb67e98SDaniel Drake .private_value = 25230fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), 25240fb67e98SDaniel Drake }, 25250fb67e98SDaniel Drake {} 25260fb67e98SDaniel Drake }; 25270fb67e98SDaniel Drake 252834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { 2529c4cfe66cSDaniel Drake { 2530c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2531c4cfe66cSDaniel Drake .name = "DC Mode Enable Switch", 2532c4cfe66cSDaniel Drake .info = snd_ctl_boolean_mono_info, 2533c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_get, 2534c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_put, 2535c4cfe66cSDaniel Drake }, 2536c4cfe66cSDaniel Drake { 2537c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2538c4cfe66cSDaniel Drake .name = "DC Input Bias Enum", 2539c4cfe66cSDaniel Drake .info = cxt5066_olpc_dc_bias_enum_info, 2540c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_bias_enum_get, 2541c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_bias_enum_put, 2542c4cfe66cSDaniel Drake }, 2543c4cfe66cSDaniel Drake {} 2544c4cfe66cSDaniel Drake }; 2545c4cfe66cSDaniel Drake 254634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixers[] = { 25470fb67e98SDaniel Drake { 25480fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25490fb67e98SDaniel Drake .name = "Master Playback Switch", 25500fb67e98SDaniel Drake .info = cxt_eapd_info, 25510fb67e98SDaniel Drake .get = cxt_eapd_get, 25520fb67e98SDaniel Drake .put = cxt5066_hp_master_sw_put, 25530fb67e98SDaniel Drake .private_value = 0x1d, 25540fb67e98SDaniel Drake }, 25550fb67e98SDaniel Drake 25560fb67e98SDaniel Drake { 25570fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2558c4cfe66cSDaniel Drake .name = "Analog Mic Boost Capture Enum", 25590fb67e98SDaniel Drake .info = cxt5066_mic_boost_mux_enum_info, 25600fb67e98SDaniel Drake .get = cxt5066_mic_boost_mux_enum_get, 25610fb67e98SDaniel Drake .put = cxt5066_mic_boost_mux_enum_put, 25620fb67e98SDaniel Drake }, 25630fb67e98SDaniel Drake 25640fb67e98SDaniel Drake HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), 25650fb67e98SDaniel Drake HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), 25660fb67e98SDaniel Drake {} 25670fb67e98SDaniel Drake }; 25680fb67e98SDaniel Drake 256934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { 2570254bba6aSEinar Rünkaru { 2571254bba6aSEinar Rünkaru .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 257228c4edb7SDavid Henningsson .name = "Internal Mic Boost Capture Enum", 2573254bba6aSEinar Rünkaru .info = cxt5066_mic_boost_mux_enum_info, 2574254bba6aSEinar Rünkaru .get = cxt5066_mic_boost_mux_enum_get, 2575254bba6aSEinar Rünkaru .put = cxt5066_mic_boost_mux_enum_put, 2576254bba6aSEinar Rünkaru .private_value = 0x23 | 0x100, 2577254bba6aSEinar Rünkaru }, 2578254bba6aSEinar Rünkaru {} 2579254bba6aSEinar Rünkaru }; 2580254bba6aSEinar Rünkaru 258134cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs[] = { 25820fb67e98SDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 25830fb67e98SDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 25840fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 25850fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 25860fb67e98SDaniel Drake 25870fb67e98SDaniel Drake /* Speakers */ 25880fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 25890fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25900fb67e98SDaniel Drake 25910fb67e98SDaniel Drake /* HP, Amp */ 25920fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25930fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25940fb67e98SDaniel Drake 25950fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25960fb67e98SDaniel Drake {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25970fb67e98SDaniel Drake 25980fb67e98SDaniel Drake /* DAC1 */ 25990fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 26000fb67e98SDaniel Drake 26010fb67e98SDaniel Drake /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 26020fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26030fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26040fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 26050fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26060fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 26070fb67e98SDaniel Drake 26080fb67e98SDaniel Drake /* no digital microphone support yet */ 26090fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26100fb67e98SDaniel Drake 26110fb67e98SDaniel Drake /* Audio input selector */ 26120fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26130fb67e98SDaniel Drake 26140fb67e98SDaniel Drake /* SPDIF route: PCM */ 26150fb67e98SDaniel Drake {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 26160fb67e98SDaniel Drake {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 26170fb67e98SDaniel Drake 26180fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26190fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26200fb67e98SDaniel Drake 26210fb67e98SDaniel Drake /* EAPD */ 26220fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26230fb67e98SDaniel Drake 26240fb67e98SDaniel Drake /* not handling these yet */ 26250fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26260fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26270fb67e98SDaniel Drake {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26280fb67e98SDaniel Drake {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26290fb67e98SDaniel Drake {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26300fb67e98SDaniel Drake {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26310fb67e98SDaniel Drake {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26320fb67e98SDaniel Drake {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26330fb67e98SDaniel Drake { } /* end */ 26340fb67e98SDaniel Drake }; 26350fb67e98SDaniel Drake 263634cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_olpc[] = { 26370fb67e98SDaniel Drake /* Port A: headphones */ 26380fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 26390fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26400fb67e98SDaniel Drake 26410fb67e98SDaniel Drake /* Port B: external microphone */ 264275f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26430fb67e98SDaniel Drake 26440fb67e98SDaniel Drake /* Port C: internal microphone */ 264575f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26460fb67e98SDaniel Drake 26470fb67e98SDaniel Drake /* Port D: unused */ 26480fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26490fb67e98SDaniel Drake 26500fb67e98SDaniel Drake /* Port E: unused, but has primary EAPD */ 26510fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26520fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26530fb67e98SDaniel Drake 2654c4cfe66cSDaniel Drake /* Port F: external DC input through microphone port */ 26550fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26560fb67e98SDaniel Drake 26570fb67e98SDaniel Drake /* Port G: internal speakers */ 26580fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26590fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26600fb67e98SDaniel Drake 26610fb67e98SDaniel Drake /* DAC1 */ 26620fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 26630fb67e98SDaniel Drake 26640fb67e98SDaniel Drake /* DAC2: unused */ 26650fb67e98SDaniel Drake {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 26660fb67e98SDaniel Drake 26670fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26680fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26690fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26700fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26710fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26720fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26730fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26740fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26750fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26760fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26770fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26780fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26790fb67e98SDaniel Drake 26800fb67e98SDaniel Drake /* Disable digital microphone port */ 26810fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26820fb67e98SDaniel Drake 26830fb67e98SDaniel Drake /* Audio input selectors */ 26840fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26850fb67e98SDaniel Drake {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 26860fb67e98SDaniel Drake 26870fb67e98SDaniel Drake /* Disable SPDIF */ 26880fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26890fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26900fb67e98SDaniel Drake 26910fb67e98SDaniel Drake /* enable unsolicited events for Port A and B */ 26920fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 26930fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 26940fb67e98SDaniel Drake { } /* end */ 26950fb67e98SDaniel Drake }; 26960fb67e98SDaniel Drake 269734cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_vostro[] = { 269895a618bdSEinar Rünkaru /* Port A: headphones */ 269995a618bdSEinar Rünkaru {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270095a618bdSEinar Rünkaru {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 270195a618bdSEinar Rünkaru 270295a618bdSEinar Rünkaru /* Port B: external microphone */ 270395a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270495a618bdSEinar Rünkaru 270595a618bdSEinar Rünkaru /* Port C: unused */ 270695a618bdSEinar Rünkaru {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270795a618bdSEinar Rünkaru 270895a618bdSEinar Rünkaru /* Port D: unused */ 270995a618bdSEinar Rünkaru {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271095a618bdSEinar Rünkaru 271195a618bdSEinar Rünkaru /* Port E: unused, but has primary EAPD */ 271295a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271395a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 271495a618bdSEinar Rünkaru 271595a618bdSEinar Rünkaru /* Port F: unused */ 271695a618bdSEinar Rünkaru {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271795a618bdSEinar Rünkaru 271895a618bdSEinar Rünkaru /* Port G: internal speakers */ 271995a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 272095a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 272195a618bdSEinar Rünkaru 272295a618bdSEinar Rünkaru /* DAC1 */ 272395a618bdSEinar Rünkaru {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 272495a618bdSEinar Rünkaru 272595a618bdSEinar Rünkaru /* DAC2: unused */ 272695a618bdSEinar Rünkaru {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 272795a618bdSEinar Rünkaru 272895a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 272995a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273095a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273195a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273295a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273395a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273495a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273595a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273695a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273795a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273895a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273995a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 274095a618bdSEinar Rünkaru 274195a618bdSEinar Rünkaru /* Digital microphone port */ 274295a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 274395a618bdSEinar Rünkaru 274495a618bdSEinar Rünkaru /* Audio input selectors */ 274595a618bdSEinar Rünkaru {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 274695a618bdSEinar Rünkaru {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 274795a618bdSEinar Rünkaru 274895a618bdSEinar Rünkaru /* Disable SPDIF */ 274995a618bdSEinar Rünkaru {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 275095a618bdSEinar Rünkaru {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 275195a618bdSEinar Rünkaru 275295a618bdSEinar Rünkaru /* enable unsolicited events for Port A and B */ 275395a618bdSEinar Rünkaru {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 275495a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 275595a618bdSEinar Rünkaru { } /* end */ 275695a618bdSEinar Rünkaru }; 275795a618bdSEinar Rünkaru 275834cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_ideapad[] = { 2759cfd3d8dcSGreg Alexander {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 2760cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 2761cfd3d8dcSGreg Alexander {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 2762cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 2763cfd3d8dcSGreg Alexander 2764cfd3d8dcSGreg Alexander /* Speakers */ 2765cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2766cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2767cfd3d8dcSGreg Alexander 2768cfd3d8dcSGreg Alexander /* HP, Amp */ 2769cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2770cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2771cfd3d8dcSGreg Alexander 2772cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2773cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2774cfd3d8dcSGreg Alexander 2775cfd3d8dcSGreg Alexander /* DAC1 */ 2776cfd3d8dcSGreg Alexander {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2777cfd3d8dcSGreg Alexander 2778cfd3d8dcSGreg Alexander /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 2779cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 2780cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2781cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 2782cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2783cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2784cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 2785cfd3d8dcSGreg Alexander 2786cfd3d8dcSGreg Alexander /* Audio input selector */ 2787cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 2788cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 2789cfd3d8dcSGreg Alexander 2790cfd3d8dcSGreg Alexander /* SPDIF route: PCM */ 2791cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 2792cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 2793cfd3d8dcSGreg Alexander 2794cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2795cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2796cfd3d8dcSGreg Alexander 2797cfd3d8dcSGreg Alexander /* internal microphone */ 279828c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 2799cfd3d8dcSGreg Alexander 2800cfd3d8dcSGreg Alexander /* EAPD */ 2801cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2802cfd3d8dcSGreg Alexander 2803cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2804cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2805cfd3d8dcSGreg Alexander { } /* end */ 2806cfd3d8dcSGreg Alexander }; 2807cfd3d8dcSGreg Alexander 280834cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { 28097b2bfdbcSJens Taprogge {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 28107b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 28117b2bfdbcSJens Taprogge 28127b2bfdbcSJens Taprogge /* Port G: internal speakers */ 28137b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28147b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28157b2bfdbcSJens Taprogge 28167b2bfdbcSJens Taprogge /* Port A: HP, Amp */ 28177b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28187b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28197b2bfdbcSJens Taprogge 28207b2bfdbcSJens Taprogge /* Port B: Mic Dock */ 28217b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28227b2bfdbcSJens Taprogge 28237b2bfdbcSJens Taprogge /* Port C: Mic */ 28247b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28257b2bfdbcSJens Taprogge 28267b2bfdbcSJens Taprogge /* Port D: HP Dock, Amp */ 28277b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28287b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28297b2bfdbcSJens Taprogge 28307b2bfdbcSJens Taprogge /* DAC1 */ 28317b2bfdbcSJens Taprogge {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 28327b2bfdbcSJens Taprogge 28337b2bfdbcSJens Taprogge /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 28347b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 28357b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 28367b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 28377b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 28387b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 28397b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 28407b2bfdbcSJens Taprogge 28417b2bfdbcSJens Taprogge /* Audio input selector */ 28427b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 28437b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 28447b2bfdbcSJens Taprogge 28457b2bfdbcSJens Taprogge /* SPDIF route: PCM */ 28467b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 28477b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 28487b2bfdbcSJens Taprogge 28497b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28507b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28517b2bfdbcSJens Taprogge 28527b2bfdbcSJens Taprogge /* internal microphone */ 285328c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 28547b2bfdbcSJens Taprogge 28557b2bfdbcSJens Taprogge /* EAPD */ 28567b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 28577b2bfdbcSJens Taprogge 28587b2bfdbcSJens Taprogge /* enable unsolicited events for Port A, B, C and D */ 28597b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28607b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28617b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28627b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28637b2bfdbcSJens Taprogge { } /* end */ 28647b2bfdbcSJens Taprogge }; 28657b2bfdbcSJens Taprogge 286634cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { 28670fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28680fb67e98SDaniel Drake { } /* end */ 28690fb67e98SDaniel Drake }; 28700fb67e98SDaniel Drake 2871048e78a5SDavid Henningsson 287234cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { 2873048e78a5SDavid Henningsson {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, 2874048e78a5SDavid Henningsson {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2875048e78a5SDavid Henningsson {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2876048e78a5SDavid Henningsson { } /* end */ 2877048e78a5SDavid Henningsson }; 2878048e78a5SDavid Henningsson 28790fb67e98SDaniel Drake /* initialize jack-sensing, too */ 28800fb67e98SDaniel Drake static int cxt5066_init(struct hda_codec *codec) 28810fb67e98SDaniel Drake { 28820fb67e98SDaniel Drake snd_printdd("CXT5066: init\n"); 28830fb67e98SDaniel Drake conexant_init(codec); 28840fb67e98SDaniel Drake if (codec->patch_ops.unsol_event) { 28850fb67e98SDaniel Drake cxt5066_hp_automute(codec); 288602b6b5b6SDavid Henningsson cxt5066_automic(codec); 28870fb67e98SDaniel Drake } 2888c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 28890fb67e98SDaniel Drake return 0; 28900fb67e98SDaniel Drake } 28910fb67e98SDaniel Drake 289275f8991dSDaniel Drake static int cxt5066_olpc_init(struct hda_codec *codec) 289375f8991dSDaniel Drake { 2894c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 289575f8991dSDaniel Drake snd_printdd("CXT5066: init\n"); 289675f8991dSDaniel Drake conexant_init(codec); 289775f8991dSDaniel Drake cxt5066_hp_automute(codec); 2898c4cfe66cSDaniel Drake if (!spec->dc_enable) { 2899c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 290075f8991dSDaniel Drake cxt5066_olpc_automic(codec); 2901c4cfe66cSDaniel Drake } else { 2902c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2903c4cfe66cSDaniel Drake } 290475f8991dSDaniel Drake return 0; 290575f8991dSDaniel Drake } 290675f8991dSDaniel Drake 29070fb67e98SDaniel Drake enum { 29080fb67e98SDaniel Drake CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 29090fb67e98SDaniel Drake CXT5066_DELL_LAPTOP, /* Dell Laptop */ 29100fb67e98SDaniel Drake CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ 29111feba3b7SDavid Henningsson CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2912cfd3d8dcSGreg Alexander CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 29137b2bfdbcSJens Taprogge CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2914a1d6906eSDavid Henningsson CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ 2915048e78a5SDavid Henningsson CXT5066_HP_LAPTOP, /* HP Laptop */ 2916fea4a4f9STakashi Iwai CXT5066_AUTO, /* BIOS auto-parser */ 29170fb67e98SDaniel Drake CXT5066_MODELS 29180fb67e98SDaniel Drake }; 29190fb67e98SDaniel Drake 2920ea734963STakashi Iwai static const char * const cxt5066_models[CXT5066_MODELS] = { 29210fb67e98SDaniel Drake [CXT5066_LAPTOP] = "laptop", 29220fb67e98SDaniel Drake [CXT5066_DELL_LAPTOP] = "dell-laptop", 29230fb67e98SDaniel Drake [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", 29241feba3b7SDavid Henningsson [CXT5066_DELL_VOSTRO] = "dell-vostro", 2925cfd3d8dcSGreg Alexander [CXT5066_IDEAPAD] = "ideapad", 29267b2bfdbcSJens Taprogge [CXT5066_THINKPAD] = "thinkpad", 2927a1d6906eSDavid Henningsson [CXT5066_ASUS] = "asus", 2928048e78a5SDavid Henningsson [CXT5066_HP_LAPTOP] = "hp-laptop", 2929fea4a4f9STakashi Iwai [CXT5066_AUTO] = "auto", 29300fb67e98SDaniel Drake }; 29310fb67e98SDaniel Drake 293234cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { 293300cd0bb7STakashi Iwai SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 29341feba3b7SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 29358a96b1e0SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), 2936ca6cd851SDaniel T Chen SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2937231f50bcSAnisse Astier SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2938ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2939048e78a5SDavid Henningsson SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2940f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2941a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2942f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 29432ca9cac9SAnisse Astier SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 2944c5366681SDaniel T Chen SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 29455637edb2SDavid Henningsson SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 29465637edb2SDavid Henningsson CXT5066_LAPTOP), 29475637edb2SDavid Henningsson SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 29484d155641STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2949ef61d4e6SManoj Iyer SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 295019593875SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 2951d2859fd4SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), 2952a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), 29530fb67e98SDaniel Drake {} 29540fb67e98SDaniel Drake }; 29550fb67e98SDaniel Drake 29560fb67e98SDaniel Drake static int patch_cxt5066(struct hda_codec *codec) 29570fb67e98SDaniel Drake { 29580fb67e98SDaniel Drake struct conexant_spec *spec; 29590fb67e98SDaniel Drake int board_config; 29600fb67e98SDaniel Drake 2961fea4a4f9STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, 2962fea4a4f9STakashi Iwai cxt5066_models, cxt5066_cfg_tbl); 2963fea4a4f9STakashi Iwai if (board_config < 0) 2964c82693dbSTakashi Iwai board_config = CXT5066_AUTO; /* model=auto as default */ 2965fea4a4f9STakashi Iwai if (board_config == CXT5066_AUTO) 2966fea4a4f9STakashi Iwai return patch_conexant_auto(codec); 2967fea4a4f9STakashi Iwai 29680fb67e98SDaniel Drake spec = kzalloc(sizeof(*spec), GFP_KERNEL); 29690fb67e98SDaniel Drake if (!spec) 29700fb67e98SDaniel Drake return -ENOMEM; 29710fb67e98SDaniel Drake codec->spec = spec; 29720fb67e98SDaniel Drake 29730fb67e98SDaniel Drake codec->patch_ops = conexant_patch_ops; 297475f8991dSDaniel Drake codec->patch_ops.init = conexant_init; 29750fb67e98SDaniel Drake 29760fb67e98SDaniel Drake spec->dell_automute = 0; 29770fb67e98SDaniel Drake spec->multiout.max_channels = 2; 29780fb67e98SDaniel Drake spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); 29790fb67e98SDaniel Drake spec->multiout.dac_nids = cxt5066_dac_nids; 2980f6a2491cSAndy Robinson conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, 2981f6a2491cSAndy Robinson ARRAY_SIZE(cxt5066_digout_pin_nids)); 29820fb67e98SDaniel Drake spec->num_adc_nids = 1; 29830fb67e98SDaniel Drake spec->adc_nids = cxt5066_adc_nids; 29840fb67e98SDaniel Drake spec->capsrc_nids = cxt5066_capsrc_nids; 29850fb67e98SDaniel Drake spec->input_mux = &cxt5066_capture_source; 29860fb67e98SDaniel Drake 29870fb67e98SDaniel Drake spec->port_d_mode = PIN_HP; 29880fb67e98SDaniel Drake 29890fb67e98SDaniel Drake spec->num_init_verbs = 1; 29900fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs; 29910fb67e98SDaniel Drake spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); 29920fb67e98SDaniel Drake spec->channel_mode = cxt5066_modes; 29930fb67e98SDaniel Drake spec->cur_adc = 0; 29940fb67e98SDaniel Drake spec->cur_adc_idx = 0; 29950fb67e98SDaniel Drake 29963507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 29973507e2a8STakashi Iwai 29980fb67e98SDaniel Drake switch (board_config) { 29990fb67e98SDaniel Drake default: 30000fb67e98SDaniel Drake case CXT5066_LAPTOP: 30010fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30020fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30030fb67e98SDaniel Drake break; 30040fb67e98SDaniel Drake case CXT5066_DELL_LAPTOP: 30050fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30060fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30070fb67e98SDaniel Drake 30080fb67e98SDaniel Drake spec->port_d_mode = PIN_OUT; 30090fb67e98SDaniel Drake spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; 30100fb67e98SDaniel Drake spec->num_init_verbs++; 30110fb67e98SDaniel Drake spec->dell_automute = 1; 30120fb67e98SDaniel Drake break; 3013a1d6906eSDavid Henningsson case CXT5066_ASUS: 3014048e78a5SDavid Henningsson case CXT5066_HP_LAPTOP: 3015048e78a5SDavid Henningsson codec->patch_ops.init = cxt5066_init; 301602b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3017048e78a5SDavid Henningsson spec->init_verbs[spec->num_init_verbs] = 3018048e78a5SDavid Henningsson cxt5066_init_verbs_hp_laptop; 3019048e78a5SDavid Henningsson spec->num_init_verbs++; 3020a1d6906eSDavid Henningsson spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; 3021a1d6906eSDavid Henningsson spec->asus = board_config == CXT5066_ASUS; 3022048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3023048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3024048e78a5SDavid Henningsson /* no S/PDIF out */ 3025f6a2491cSAndy Robinson if (board_config == CXT5066_HP_LAPTOP) 3026048e78a5SDavid Henningsson spec->multiout.dig_out_nid = 0; 3027048e78a5SDavid Henningsson /* input source automatically selected */ 3028048e78a5SDavid Henningsson spec->input_mux = NULL; 3029048e78a5SDavid Henningsson spec->port_d_mode = 0; 3030048e78a5SDavid Henningsson spec->mic_boost = 3; /* default 30dB gain */ 3031048e78a5SDavid Henningsson break; 3032048e78a5SDavid Henningsson 30330fb67e98SDaniel Drake case CXT5066_OLPC_XO_1_5: 303475f8991dSDaniel Drake codec->patch_ops.init = cxt5066_olpc_init; 303575f8991dSDaniel Drake codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; 30360fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs_olpc; 30370fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 3038c4cfe66cSDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; 30390fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30400fb67e98SDaniel Drake spec->port_d_mode = 0; 3041c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 30420fb67e98SDaniel Drake 30430fb67e98SDaniel Drake /* no S/PDIF out */ 30440fb67e98SDaniel Drake spec->multiout.dig_out_nid = 0; 30450fb67e98SDaniel Drake 30460fb67e98SDaniel Drake /* input source automatically selected */ 30470fb67e98SDaniel Drake spec->input_mux = NULL; 304875f8991dSDaniel Drake 304975f8991dSDaniel Drake /* our capture hooks which allow us to turn on the microphone LED 305075f8991dSDaniel Drake * at the right time */ 305175f8991dSDaniel Drake spec->capture_prepare = cxt5066_olpc_capture_prepare; 305275f8991dSDaniel Drake spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 30530fb67e98SDaniel Drake break; 30541feba3b7SDavid Henningsson case CXT5066_DELL_VOSTRO: 305575f8991dSDaniel Drake codec->patch_ops.init = cxt5066_init; 305602b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 305795a618bdSEinar Rünkaru spec->init_verbs[0] = cxt5066_init_verbs_vostro; 305895a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 305995a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3060254bba6aSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 306195a618bdSEinar Rünkaru spec->port_d_mode = 0; 3062254bba6aSEinar Rünkaru spec->dell_vostro = 1; 3063c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 306495a618bdSEinar Rünkaru 306595a618bdSEinar Rünkaru /* no S/PDIF out */ 306695a618bdSEinar Rünkaru spec->multiout.dig_out_nid = 0; 306795a618bdSEinar Rünkaru 306895a618bdSEinar Rünkaru /* input source automatically selected */ 306995a618bdSEinar Rünkaru spec->input_mux = NULL; 307095a618bdSEinar Rünkaru break; 3071cfd3d8dcSGreg Alexander case CXT5066_IDEAPAD: 3072cfd3d8dcSGreg Alexander codec->patch_ops.init = cxt5066_init; 307302b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3074cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3075cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3076cfd3d8dcSGreg Alexander spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 3077cfd3d8dcSGreg Alexander spec->port_d_mode = 0; 3078cfd3d8dcSGreg Alexander spec->ideapad = 1; 3079cfd3d8dcSGreg Alexander spec->mic_boost = 2; /* default 20dB gain */ 3080cfd3d8dcSGreg Alexander 3081cfd3d8dcSGreg Alexander /* no S/PDIF out */ 3082cfd3d8dcSGreg Alexander spec->multiout.dig_out_nid = 0; 3083cfd3d8dcSGreg Alexander 3084cfd3d8dcSGreg Alexander /* input source automatically selected */ 3085cfd3d8dcSGreg Alexander spec->input_mux = NULL; 3086cfd3d8dcSGreg Alexander break; 30877b2bfdbcSJens Taprogge case CXT5066_THINKPAD: 30887b2bfdbcSJens Taprogge codec->patch_ops.init = cxt5066_init; 308902b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 30907b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30917b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30927b2bfdbcSJens Taprogge spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 30937b2bfdbcSJens Taprogge spec->thinkpad = 1; 30947b2bfdbcSJens Taprogge spec->port_d_mode = PIN_OUT; 30957b2bfdbcSJens Taprogge spec->mic_boost = 2; /* default 20dB gain */ 30967b2bfdbcSJens Taprogge 30977b2bfdbcSJens Taprogge /* no S/PDIF out */ 30987b2bfdbcSJens Taprogge spec->multiout.dig_out_nid = 0; 30997b2bfdbcSJens Taprogge 31007b2bfdbcSJens Taprogge /* input source automatically selected */ 31017b2bfdbcSJens Taprogge spec->input_mux = NULL; 31027b2bfdbcSJens Taprogge break; 31030fb67e98SDaniel Drake } 31040fb67e98SDaniel Drake 31053507e2a8STakashi Iwai if (spec->beep_amp) 3106a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 31073507e2a8STakashi Iwai 31080fb67e98SDaniel Drake return 0; 31090fb67e98SDaniel Drake } 3110461e2c78STakashi Iwai 3111bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 3112bf92d1d5STakashi Iwai 3113bf92d1d5STakashi Iwai 3114461e2c78STakashi Iwai /* 3115f2e5731dSTakashi Iwai * Automatic parser for CX20641 & co 3116f2e5731dSTakashi Iwai */ 3117f2e5731dSTakashi Iwai 3118f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 3119f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec) 3120f2e5731dSTakashi Iwai { 3121f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 3122f2e5731dSTakashi Iwai hda_nid_t nid, end_nid; 3123f2e5731dSTakashi Iwai 3124f2e5731dSTakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 3125f2e5731dSTakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) 3126f2e5731dSTakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 3127f2e5731dSTakashi Iwai set_beep_amp(spec, nid, 0, HDA_OUTPUT); 3128f2e5731dSTakashi Iwai break; 3129f2e5731dSTakashi Iwai } 3130f2e5731dSTakashi Iwai } 3131f2e5731dSTakashi Iwai #else 3132f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec) 3133f2e5731dSTakashi Iwai #endif 3134f2e5731dSTakashi Iwai 3135254f2968STakashi Iwai /* parse EAPDs */ 313619110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 313719110595STakashi Iwai { 313819110595STakashi Iwai struct conexant_spec *spec = codec->spec; 313919110595STakashi Iwai hda_nid_t nid, end_nid; 314019110595STakashi Iwai 314119110595STakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 314219110595STakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) { 314319110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 314419110595STakashi Iwai continue; 314519110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 314619110595STakashi Iwai continue; 314719110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 314819110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 314919110595STakashi Iwai break; 315019110595STakashi Iwai } 3151254f2968STakashi Iwai 3152254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 3153254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 3154254f2968STakashi Iwai * pins, and we can control EAPD per pin. 3155254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 3156254f2968STakashi Iwai * thus it might control over all pins. 3157254f2968STakashi Iwai */ 3158aed523f1STakashi Iwai if (spec->num_eapds > 2) 3159ff359b14STakashi Iwai spec->dynamic_eapd = 1; 3160f2e5731dSTakashi Iwai } 3161f2e5731dSTakashi Iwai 3162da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 3163da339866STakashi Iwai hda_nid_t *pins, bool on) 3164f2e5731dSTakashi Iwai { 3165f2e5731dSTakashi Iwai int i; 3166f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 3167f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 3168f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 3169da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 3170da339866STakashi Iwai on ? 0x02 : 0); 3171f2e5731dSTakashi Iwai } 3172f2e5731dSTakashi Iwai } 3173f2e5731dSTakashi Iwai 3174527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 3175527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 3176527c73baSTakashi Iwai { 3177527c73baSTakashi Iwai struct hda_codec *codec = private_data; 3178527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 3179527c73baSTakashi Iwai 3180527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 3181527c73baSTakashi Iwai } 3182527c73baSTakashi Iwai 3183f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec) 3184f2e5731dSTakashi Iwai { 3185f2e5731dSTakashi Iwai int err; 3186f2e5731dSTakashi Iwai 3187aed523f1STakashi Iwai err = snd_hda_gen_build_controls(codec); 3188f2e5731dSTakashi Iwai if (err < 0) 3189f2e5731dSTakashi Iwai return err; 3190f2e5731dSTakashi Iwai 3191aed523f1STakashi Iwai err = add_beep_ctls(codec); 3192aed523f1STakashi Iwai if (err < 0) 3193aed523f1STakashi Iwai return err; 319422ce5f74STakashi Iwai 319522ce5f74STakashi Iwai return 0; 319622ce5f74STakashi Iwai } 319722ce5f74STakashi Iwai 3198ff359b14STakashi Iwai static int cx_auto_init(struct hda_codec *codec) 3199ff359b14STakashi Iwai { 3200ff359b14STakashi Iwai struct conexant_spec *spec = codec->spec; 3201ff359b14STakashi Iwai snd_hda_gen_init(codec); 3202ff359b14STakashi Iwai if (!spec->dynamic_eapd) 3203ff359b14STakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); 3204e4c3bce2SDavid Henningsson 3205e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); 3206e4c3bce2SDavid Henningsson 3207ff359b14STakashi Iwai return 0; 3208ff359b14STakashi Iwai } 3209ff359b14STakashi Iwai 321008cf680cSDavid Henningsson static void cx_auto_free(struct hda_codec *codec) 321108cf680cSDavid Henningsson { 321208cf680cSDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); 321308cf680cSDavid Henningsson snd_hda_gen_free(codec); 321408cf680cSDavid Henningsson } 321508cf680cSDavid Henningsson 321634cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 3217f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 3218aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 3219ff359b14STakashi Iwai .init = cx_auto_init, 322008cf680cSDavid Henningsson .free = cx_auto_free, 322129adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 3222164a7adaSTakashi Iwai #ifdef CONFIG_PM 3223164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 3224164a7adaSTakashi Iwai #endif 3225f2e5731dSTakashi Iwai }; 3226f2e5731dSTakashi Iwai 3227e92d4b08STakashi Iwai /* 3228e92d4b08STakashi Iwai * pin fix-up 3229e92d4b08STakashi Iwai */ 323018dcd304SDavid Henningsson enum { 323118dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 3232d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 3233239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 3234239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 323518dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 3236239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 3237e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC_PIN, 3238e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC, 32394a437044STakashi Iwai CXT_FIXUP_GPIO1, 324008cf680cSDavid Henningsson CXT_FIXUP_THINKPAD_ACPI, 324118dcd304SDavid Henningsson }; 324218dcd304SDavid Henningsson 3243*b317b032STakashi Iwai /* for hda_fixup_thinkpad_acpi() */ 3244*b317b032STakashi Iwai #include "thinkpad_helper.c" 324508cf680cSDavid Henningsson 324623d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 324723d30f28STakashi Iwai const struct hda_fixup *fix, int action) 3248e92d4b08STakashi Iwai { 324918dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 3250aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 3251e92d4b08STakashi Iwai } 3252e92d4b08STakashi Iwai 3253239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 3254239fb862SHuacai Chen const struct hda_fixup *fix, int action) 3255239fb862SHuacai Chen { 3256239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 3257239fb862SHuacai Chen return; 3258239fb862SHuacai Chen 3259239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 3260239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 3261239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3262239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3263239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 3264239fb862SHuacai Chen } 3265239fb862SHuacai Chen 3266e4c3bce2SDavid Henningsson static void cxt_update_headset_mode(struct hda_codec *codec) 3267e4c3bce2SDavid Henningsson { 3268e4c3bce2SDavid Henningsson /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ 3269e4c3bce2SDavid Henningsson int i; 3270e4c3bce2SDavid Henningsson bool mic_mode = false; 3271e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 3272e4c3bce2SDavid Henningsson struct auto_pin_cfg *cfg = &spec->gen.autocfg; 3273e4c3bce2SDavid Henningsson 3274e4c3bce2SDavid Henningsson hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; 3275e4c3bce2SDavid Henningsson 3276e4c3bce2SDavid Henningsson for (i = 0; i < cfg->num_inputs; i++) 3277e4c3bce2SDavid Henningsson if (cfg->inputs[i].pin == mux_pin) { 3278e4c3bce2SDavid Henningsson mic_mode = !!cfg->inputs[i].is_headphone_mic; 3279e4c3bce2SDavid Henningsson break; 3280e4c3bce2SDavid Henningsson } 3281e4c3bce2SDavid Henningsson 3282e4c3bce2SDavid Henningsson if (mic_mode) { 3283e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ 3284e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = false; 3285e4c3bce2SDavid Henningsson } else { 3286e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ 3287e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); 3288e4c3bce2SDavid Henningsson } 3289e4c3bce2SDavid Henningsson 3290e4c3bce2SDavid Henningsson snd_hda_gen_update_outputs(codec); 3291e4c3bce2SDavid Henningsson } 3292e4c3bce2SDavid Henningsson 3293e4c3bce2SDavid Henningsson static void cxt_update_headset_mode_hook(struct hda_codec *codec, 3294e4c3bce2SDavid Henningsson struct snd_ctl_elem_value *ucontrol) 3295e4c3bce2SDavid Henningsson { 3296e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 3297e4c3bce2SDavid Henningsson } 3298e4c3bce2SDavid Henningsson 3299e4c3bce2SDavid Henningsson static void cxt_fixup_headphone_mic(struct hda_codec *codec, 3300e4c3bce2SDavid Henningsson const struct hda_fixup *fix, int action) 3301e4c3bce2SDavid Henningsson { 3302e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 3303e4c3bce2SDavid Henningsson 3304e4c3bce2SDavid Henningsson switch (action) { 3305e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PRE_PROBE: 3306e4c3bce2SDavid Henningsson spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; 3307e4c3bce2SDavid Henningsson break; 3308e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PROBE: 3309e4c3bce2SDavid Henningsson spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; 3310e4c3bce2SDavid Henningsson spec->gen.automute_hook = cxt_update_headset_mode; 3311e4c3bce2SDavid Henningsson break; 3312e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_INIT: 3313e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 3314e4c3bce2SDavid Henningsson break; 3315e4c3bce2SDavid Henningsson } 3316e4c3bce2SDavid Henningsson } 3317e4c3bce2SDavid Henningsson 3318e4c3bce2SDavid Henningsson 3319d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 332023d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3321e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3322e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3323e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 33243e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3325e92d4b08STakashi Iwai {} 3326e92d4b08STakashi Iwai }; 3327e92d4b08STakashi Iwai 3328d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 332923d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3330d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3331d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3332d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3333d70f3632STakashi Iwai {} 3334e92d4b08STakashi Iwai }; 3335e92d4b08STakashi Iwai 3336239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3337239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3338239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3339239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3340239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3341239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3342239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3343239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3344239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3345239fb862SHuacai Chen {} 3346239fb862SHuacai Chen }; 3347239fb862SHuacai Chen 334823d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 334923d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 335023d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 335123d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 335223d30f28STakashi Iwai }, 335323d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 335423d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 335523d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 335608cf680cSDavid Henningsson .chained = true, 335708cf680cSDavid Henningsson .chain_id = CXT_FIXUP_THINKPAD_ACPI, 335823d30f28STakashi Iwai }, 3359239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3360239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3361239fb862SHuacai Chen .chained = true, 3362239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3363239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3364239fb862SHuacai Chen }, 3365239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3366239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3367239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3368239fb862SHuacai Chen }, 336923d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 337023d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 337123d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 337223d30f28STakashi Iwai }, 3373239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3374239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3375239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3376239fb862SHuacai Chen }, 3377e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC_PIN] = { 3378e4c3bce2SDavid Henningsson .type = HDA_FIXUP_PINS, 3379e4c3bce2SDavid Henningsson .chained = true, 3380e4c3bce2SDavid Henningsson .chain_id = CXT_FIXUP_HEADPHONE_MIC, 3381e4c3bce2SDavid Henningsson .v.pins = (const struct hda_pintbl[]) { 3382e4c3bce2SDavid Henningsson { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ 3383e4c3bce2SDavid Henningsson { } 3384e4c3bce2SDavid Henningsson } 3385e4c3bce2SDavid Henningsson }, 3386e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC] = { 3387e4c3bce2SDavid Henningsson .type = HDA_FIXUP_FUNC, 3388e4c3bce2SDavid Henningsson .v.func = cxt_fixup_headphone_mic, 3389e4c3bce2SDavid Henningsson }, 33904a437044STakashi Iwai [CXT_FIXUP_GPIO1] = { 33914a437044STakashi Iwai .type = HDA_FIXUP_VERBS, 33924a437044STakashi Iwai .v.verbs = (const struct hda_verb[]) { 33934a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, 33944a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, 33954a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, 33964a437044STakashi Iwai { } 33974a437044STakashi Iwai }, 33984a437044STakashi Iwai }, 339908cf680cSDavid Henningsson [CXT_FIXUP_THINKPAD_ACPI] = { 340008cf680cSDavid Henningsson .type = HDA_FIXUP_FUNC, 3401*b317b032STakashi Iwai .v.func = hda_fixup_thinkpad_acpi, 340208cf680cSDavid Henningsson }, 3403e92d4b08STakashi Iwai }; 3404e92d4b08STakashi Iwai 3405d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3406e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3407e92d4b08STakashi Iwai {} 3408e92d4b08STakashi Iwai }; 3409e92d4b08STakashi Iwai 3410d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 341163a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 34124a437044STakashi Iwai SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), 3413e4c3bce2SDavid Henningsson SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), 3414d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3415d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3416d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3417d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3418d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 3419a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 342088d57606SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), 342118dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3422e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3423b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 34242fd3f170SHui Wang SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), 3425239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3426239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3427f2e5731dSTakashi Iwai {} 3428f2e5731dSTakashi Iwai }; 3429f2e5731dSTakashi Iwai 34303868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 34313868137eSTakashi Iwai * can be created (bko#42825) 34323868137eSTakashi Iwai */ 34333868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 34343868137eSTakashi Iwai { 34353868137eSTakashi Iwai static hda_nid_t out_nids[] = { 34363868137eSTakashi Iwai 0x10, 0x11, 0 34373868137eSTakashi Iwai }; 34383868137eSTakashi Iwai hda_nid_t *p; 34393868137eSTakashi Iwai 34403868137eSTakashi Iwai for (p = out_nids; *p; p++) 34413868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 34423868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 34433868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 34443868137eSTakashi Iwai } 34453868137eSTakashi Iwai 3446f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3447f2e5731dSTakashi Iwai { 3448f2e5731dSTakashi Iwai struct conexant_spec *spec; 3449f2e5731dSTakashi Iwai int err; 3450f2e5731dSTakashi Iwai 34511f8458a2STakashi Iwai printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 34521f8458a2STakashi Iwai codec->chip_name); 34531f8458a2STakashi Iwai 3454f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3455f2e5731dSTakashi Iwai if (!spec) 3456f2e5731dSTakashi Iwai return -ENOMEM; 3457aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3458f2e5731dSTakashi Iwai codec->spec = spec; 3459e92d4b08STakashi Iwai 3460aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3461aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3462ff359b14STakashi Iwai spec->gen.own_eapd_ctl = 1; 3463ff359b14STakashi Iwai if (spec->dynamic_eapd) 3464aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3465e92d4b08STakashi Iwai 34666b452142STakashi Iwai switch (codec->vendor_id) { 34676b452142STakashi Iwai case 0x14f15045: 34684f32456eSMichael Karcher codec->single_adc_amp = 1; 34696b452142STakashi Iwai break; 3470164a7adaSTakashi Iwai case 0x14f15047: 3471164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 3472164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 3473164a7adaSTakashi Iwai break; 34743868137eSTakashi Iwai case 0x14f15051: 34753868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 347651969d62SMichael Karcher codec->pin_amp_workaround = 1; 347723d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); 34783868137eSTakashi Iwai break; 347951969d62SMichael Karcher default: 348051969d62SMichael Karcher codec->pin_amp_workaround = 1; 348123d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); 348223d30f28STakashi Iwai break; 34836b452142STakashi Iwai } 34846b452142STakashi Iwai 3485f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3486f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3487f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3488f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3489f29735cbSTakashi Iwai * not good to expose it blindly. 3490527c73baSTakashi Iwai */ 3491f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3492f29735cbSTakashi Iwai case 0x103c: 3493aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3494f29735cbSTakashi Iwai break; 3495f29735cbSTakashi Iwai } 3496527c73baSTakashi Iwai 3497aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3498aed523f1STakashi Iwai 3499e4c3bce2SDavid Henningsson err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 3500e4c3bce2SDavid Henningsson spec->parse_flags); 350122ce5f74STakashi Iwai if (err < 0) 3502aed523f1STakashi Iwai goto error; 3503aed523f1STakashi Iwai 3504aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3505aed523f1STakashi Iwai if (err < 0) 3506aed523f1STakashi Iwai goto error; 3507aed523f1STakashi Iwai 3508f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 35094f2864a4STakashi Iwai 35104f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 35114f2864a4STakashi Iwai * which falls into the single-cmd mode. 35124f2864a4STakashi Iwai * Better to make reset, then. 35134f2864a4STakashi Iwai */ 35144f2864a4STakashi Iwai if (!codec->bus->sync_write) { 35154f2864a4STakashi Iwai snd_printd("hda_codec: " 35164f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 35174f2864a4STakashi Iwai codec->bus->sync_write = 1; 35184f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 35194f2864a4STakashi Iwai } 35204f2864a4STakashi Iwai 3521e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 3522e4c3bce2SDavid Henningsson 3523f2e5731dSTakashi Iwai return 0; 3524aed523f1STakashi Iwai 3525aed523f1STakashi Iwai error: 352608cf680cSDavid Henningsson cx_auto_free(codec); 3527aed523f1STakashi Iwai return err; 3528f2e5731dSTakashi Iwai } 3529f2e5731dSTakashi Iwai 3530bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3531bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3532bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3533bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3534bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3535bf92d1d5STakashi Iwai #endif 3536bf92d1d5STakashi Iwai 3537f2e5731dSTakashi Iwai /* 3538461e2c78STakashi Iwai */ 3539461e2c78STakashi Iwai 354034cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 354182f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 354282f30040STobin Davis .patch = patch_cxt5045 }, 354382f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 354482f30040STobin Davis .patch = patch_cxt5047 }, 3545461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3546461e2c78STakashi Iwai .patch = patch_cxt5051 }, 35470fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 35480fb67e98SDaniel Drake .patch = patch_cxt5066 }, 354995a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 355095a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3551850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3552850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 35537b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 35547b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3555f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3556f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 35576da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 35586da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3559f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3560f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3561f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3562f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3563f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3564f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3565f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3566f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3567f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3568f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3569f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3570f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3571f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3572f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3573f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3574f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 35752d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 35762d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35772d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 35782d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35792d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 35802d825fd8STakashi Iwai .patch = patch_conexant_auto }, 358142c364acSTakashi Iwai { .id = 0x14f15113, .name = "CX20755", 358242c364acSTakashi Iwai .patch = patch_conexant_auto }, 358342c364acSTakashi Iwai { .id = 0x14f15114, .name = "CX20756", 358442c364acSTakashi Iwai .patch = patch_conexant_auto }, 358542c364acSTakashi Iwai { .id = 0x14f15115, .name = "CX20757", 358642c364acSTakashi Iwai .patch = patch_conexant_auto }, 35878f42d769STakashi Iwai { .id = 0x14f151d7, .name = "CX20952", 35888f42d769STakashi Iwai .patch = patch_conexant_auto }, 3589c9b443d4STobin Davis {} /* terminator */ 3590c9b443d4STobin Davis }; 35911289e9e8STakashi Iwai 35921289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 35931289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 35941289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 35950fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 359695a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3597850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 35987b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3599f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 36006da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3601f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3602f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3603f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3604f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3605f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3606f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3607f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3608f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 36092d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 36102d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 36112d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 361242c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113"); 361342c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114"); 361442c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115"); 36158f42d769STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f151d7"); 36161289e9e8STakashi Iwai 36171289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 36181289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 36191289e9e8STakashi Iwai 36201289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 36211289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 36221289e9e8STakashi Iwai .owner = THIS_MODULE, 36231289e9e8STakashi Iwai }; 36241289e9e8STakashi Iwai 36251289e9e8STakashi Iwai static int __init patch_conexant_init(void) 36261289e9e8STakashi Iwai { 36271289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 36281289e9e8STakashi Iwai } 36291289e9e8STakashi Iwai 36301289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 36311289e9e8STakashi Iwai { 36321289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 36331289e9e8STakashi Iwai } 36341289e9e8STakashi Iwai 36351289e9e8STakashi Iwai module_init(patch_conexant_init) 36361289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3637