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 38*bf92d1d5STakashi Iwai #define ENABLE_CXT_STATIC_QUIRKS 39*bf92d1d5STakashi Iwai 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 { 60aed523f1STakashi Iwai struct hda_gen_spec gen; 61aed523f1STakashi Iwai 62*bf92d1d5STakashi Iwai unsigned int beep_amp; 63*bf92d1d5STakashi Iwai 64*bf92d1d5STakashi Iwai /* extra EAPD pins */ 65*bf92d1d5STakashi Iwai unsigned int num_eapds; 66*bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 67*bf92d1d5STakashi Iwai 68*bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 6934cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 70c9b443d4STobin Davis int num_mixers; 71dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 72c9b443d4STobin Davis 73c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 74c9b443d4STobin Davis * don't forget NULL 75c9b443d4STobin Davis * termination! 76c9b443d4STobin Davis */ 77c9b443d4STobin Davis unsigned int num_init_verbs; 78c9b443d4STobin Davis 79c9b443d4STobin Davis /* playback */ 80c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 81c9b443d4STobin Davis * max_channels, dacs must be set 82c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 83c9b443d4STobin Davis */ 84c9b443d4STobin Davis unsigned int cur_eapd; 8582f30040STobin Davis unsigned int hp_present; 8603697e2aSTakashi Iwai unsigned int line_present; 87faddaa5dSTakashi Iwai unsigned int auto_mic; 88c9b443d4STobin Davis 89c9b443d4STobin Davis /* capture */ 90c9b443d4STobin Davis unsigned int num_adc_nids; 9134cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 92c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 93c9b443d4STobin Davis 94461e2c78STakashi Iwai unsigned int cur_adc_idx; 95461e2c78STakashi Iwai hda_nid_t cur_adc; 96461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 97461e2c78STakashi Iwai unsigned int cur_adc_format; 98461e2c78STakashi Iwai 996764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1006764bcefSTakashi Iwai 101c9b443d4STobin Davis /* capture source */ 102c9b443d4STobin Davis const struct hda_input_mux *input_mux; 10334cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 104c9b443d4STobin Davis unsigned int cur_mux[3]; 105c9b443d4STobin Davis 106c9b443d4STobin Davis /* channel model */ 107c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 108c9b443d4STobin Davis int num_channel_mode; 109c9b443d4STobin Davis 110c9b443d4STobin Davis /* PCM information */ 111c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 112c9b443d4STobin Davis 113c9b443d4STobin Davis unsigned int spdif_route; 114c9b443d4STobin Davis 1150fb67e98SDaniel Drake unsigned int port_d_mode; 116f2e5731dSTakashi Iwai unsigned int dell_automute:1; 117cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 118cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1197b2bfdbcSJens Taprogge unsigned int thinkpad:1; 120048e78a5SDavid Henningsson unsigned int hp_laptop:1; 121a1d6906eSDavid Henningsson unsigned int asus:1; 1226764bcefSTakashi Iwai 12375f8991dSDaniel Drake unsigned int ext_mic_present; 12475f8991dSDaniel Drake unsigned int recording; 12575f8991dSDaniel Drake void (*capture_prepare)(struct hda_codec *codec); 12675f8991dSDaniel Drake void (*capture_cleanup)(struct hda_codec *codec); 127c4cfe66cSDaniel Drake 128c4cfe66cSDaniel Drake /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 129c4cfe66cSDaniel Drake * through the microphone jack. 130c4cfe66cSDaniel Drake * When the user enables this through a mixer switch, both internal and 131c4cfe66cSDaniel Drake * external microphones are disabled. Gain is fixed at 0dB. In this mode, 132c4cfe66cSDaniel Drake * we also allow the bias to be configured through a separate mixer 133c4cfe66cSDaniel Drake * control. */ 134c4cfe66cSDaniel Drake unsigned int dc_enable; 135c4cfe66cSDaniel Drake unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ 136c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 137*bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 138c9b443d4STobin Davis }; 139c9b443d4STobin Davis 140*bf92d1d5STakashi Iwai 141*bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 142*bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) \ 143*bf92d1d5STakashi Iwai ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) 144*bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 145*bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 146*bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 147*bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 148*bf92d1d5STakashi Iwai { } /* end */ 149*bf92d1d5STakashi Iwai }; 150*bf92d1d5STakashi Iwai 151*bf92d1d5STakashi Iwai /* create beep controls if needed */ 152*bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 153*bf92d1d5STakashi Iwai { 154*bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 155*bf92d1d5STakashi Iwai int err; 156*bf92d1d5STakashi Iwai 157*bf92d1d5STakashi Iwai if (spec->beep_amp) { 158*bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 159*bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 160*bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 161*bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 162*bf92d1d5STakashi Iwai if (!kctl) 163*bf92d1d5STakashi Iwai return -ENOMEM; 164*bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 165*bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 166*bf92d1d5STakashi Iwai if (err < 0) 167*bf92d1d5STakashi Iwai return err; 168*bf92d1d5STakashi Iwai } 169*bf92d1d5STakashi Iwai } 170*bf92d1d5STakashi Iwai return 0; 171*bf92d1d5STakashi Iwai } 172*bf92d1d5STakashi Iwai #else 173*bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 174*bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 175*bf92d1d5STakashi Iwai #endif 176*bf92d1d5STakashi Iwai 177*bf92d1d5STakashi Iwai 178*bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 179c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 180c9b443d4STobin Davis struct hda_codec *codec, 181c9b443d4STobin Davis struct snd_pcm_substream *substream) 182c9b443d4STobin Davis { 183c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1849a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1859a08160bSTakashi Iwai hinfo); 186c9b443d4STobin Davis } 187c9b443d4STobin Davis 188c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 189c9b443d4STobin Davis struct hda_codec *codec, 190c9b443d4STobin Davis unsigned int stream_tag, 191c9b443d4STobin Davis unsigned int format, 192c9b443d4STobin Davis struct snd_pcm_substream *substream) 193c9b443d4STobin Davis { 194c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 195c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 196c9b443d4STobin Davis stream_tag, 197c9b443d4STobin Davis format, substream); 198c9b443d4STobin Davis } 199c9b443d4STobin Davis 200c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 201c9b443d4STobin Davis struct hda_codec *codec, 202c9b443d4STobin Davis struct snd_pcm_substream *substream) 203c9b443d4STobin Davis { 204c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 205c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 206c9b443d4STobin Davis } 207c9b443d4STobin Davis 208c9b443d4STobin Davis /* 209c9b443d4STobin Davis * Digital out 210c9b443d4STobin Davis */ 211c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 212c9b443d4STobin Davis struct hda_codec *codec, 213c9b443d4STobin Davis struct snd_pcm_substream *substream) 214c9b443d4STobin Davis { 215c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 216c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 217c9b443d4STobin Davis } 218c9b443d4STobin Davis 219c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 220c9b443d4STobin Davis struct hda_codec *codec, 221c9b443d4STobin Davis struct snd_pcm_substream *substream) 222c9b443d4STobin Davis { 223c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 224c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 225c9b443d4STobin Davis } 226c9b443d4STobin Davis 2276b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2286b97eb45STakashi Iwai struct hda_codec *codec, 2296b97eb45STakashi Iwai unsigned int stream_tag, 2306b97eb45STakashi Iwai unsigned int format, 2316b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2326b97eb45STakashi Iwai { 2336b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2346b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2356b97eb45STakashi Iwai stream_tag, 2366b97eb45STakashi Iwai format, substream); 2376b97eb45STakashi Iwai } 2386b97eb45STakashi Iwai 239c9b443d4STobin Davis /* 240c9b443d4STobin Davis * Analog capture 241c9b443d4STobin Davis */ 242c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 243c9b443d4STobin Davis struct hda_codec *codec, 244c9b443d4STobin Davis unsigned int stream_tag, 245c9b443d4STobin Davis unsigned int format, 246c9b443d4STobin Davis struct snd_pcm_substream *substream) 247c9b443d4STobin Davis { 248c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 24975f8991dSDaniel Drake if (spec->capture_prepare) 25075f8991dSDaniel Drake spec->capture_prepare(codec); 251c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 252c9b443d4STobin Davis stream_tag, 0, format); 253c9b443d4STobin Davis return 0; 254c9b443d4STobin Davis } 255c9b443d4STobin Davis 256c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 257c9b443d4STobin Davis struct hda_codec *codec, 258c9b443d4STobin Davis struct snd_pcm_substream *substream) 259c9b443d4STobin Davis { 260c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 261888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 26275f8991dSDaniel Drake if (spec->capture_cleanup) 26375f8991dSDaniel Drake spec->capture_cleanup(codec); 264c9b443d4STobin Davis return 0; 265c9b443d4STobin Davis } 266c9b443d4STobin Davis 267c9b443d4STobin Davis 268c9b443d4STobin Davis 26934cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 270c9b443d4STobin Davis .substreams = 1, 271c9b443d4STobin Davis .channels_min = 2, 272c9b443d4STobin Davis .channels_max = 2, 273c9b443d4STobin Davis .nid = 0, /* fill later */ 274c9b443d4STobin Davis .ops = { 275c9b443d4STobin Davis .open = conexant_playback_pcm_open, 276c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 277c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 278c9b443d4STobin Davis }, 279c9b443d4STobin Davis }; 280c9b443d4STobin Davis 28134cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 282c9b443d4STobin Davis .substreams = 1, 283c9b443d4STobin Davis .channels_min = 2, 284c9b443d4STobin Davis .channels_max = 2, 285c9b443d4STobin Davis .nid = 0, /* fill later */ 286c9b443d4STobin Davis .ops = { 287c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 288c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 289c9b443d4STobin Davis }, 290c9b443d4STobin Davis }; 291c9b443d4STobin Davis 292c9b443d4STobin Davis 29334cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 294c9b443d4STobin Davis .substreams = 1, 295c9b443d4STobin Davis .channels_min = 2, 296c9b443d4STobin Davis .channels_max = 2, 297c9b443d4STobin Davis .nid = 0, /* fill later */ 298c9b443d4STobin Davis .ops = { 299c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 3006b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 3016b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 302c9b443d4STobin Davis }, 303c9b443d4STobin Davis }; 304c9b443d4STobin Davis 30534cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 306c9b443d4STobin Davis .substreams = 1, 307c9b443d4STobin Davis .channels_min = 2, 308c9b443d4STobin Davis .channels_max = 2, 309c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 310c9b443d4STobin Davis }; 311c9b443d4STobin Davis 312461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 313461e2c78STakashi Iwai struct hda_codec *codec, 314461e2c78STakashi Iwai unsigned int stream_tag, 315461e2c78STakashi Iwai unsigned int format, 316461e2c78STakashi Iwai struct snd_pcm_substream *substream) 317461e2c78STakashi Iwai { 318461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 319461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 320461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 321461e2c78STakashi Iwai spec->cur_adc_format = format; 322461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 323461e2c78STakashi Iwai return 0; 324461e2c78STakashi Iwai } 325461e2c78STakashi Iwai 326461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 327461e2c78STakashi Iwai struct hda_codec *codec, 328461e2c78STakashi Iwai struct snd_pcm_substream *substream) 329461e2c78STakashi Iwai { 330461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 331888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 332461e2c78STakashi Iwai spec->cur_adc = 0; 333461e2c78STakashi Iwai return 0; 334461e2c78STakashi Iwai } 335461e2c78STakashi Iwai 33634cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 337461e2c78STakashi Iwai .substreams = 1, 338461e2c78STakashi Iwai .channels_min = 2, 339461e2c78STakashi Iwai .channels_max = 2, 340461e2c78STakashi Iwai .nid = 0, /* fill later */ 341461e2c78STakashi Iwai .ops = { 342461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 343461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 344461e2c78STakashi Iwai }, 345461e2c78STakashi Iwai }; 346461e2c78STakashi Iwai 347c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 348c9b443d4STobin Davis { 349c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 350c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 351c9b443d4STobin Davis 352c9b443d4STobin Davis codec->num_pcms = 1; 353c9b443d4STobin Davis codec->pcm_info = info; 354c9b443d4STobin Davis 355c9b443d4STobin Davis info->name = "CONEXANT Analog"; 356c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 357c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 358c9b443d4STobin Davis spec->multiout.max_channels; 359c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 360c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3616764bcefSTakashi Iwai if (spec->capture_stream) 3626764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3636764bcefSTakashi Iwai else { 364461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 365461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 366461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3676764bcefSTakashi Iwai else { 368461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 369461e2c78STakashi Iwai conexant_pcm_analog_capture; 3706764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3716764bcefSTakashi Iwai spec->num_adc_nids; 3726764bcefSTakashi Iwai } 3736764bcefSTakashi Iwai } 374c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 375c9b443d4STobin Davis 376c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 377c9b443d4STobin Davis info++; 378c9b443d4STobin Davis codec->num_pcms++; 379c9b443d4STobin Davis info->name = "Conexant Digital"; 3807ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 381c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 382c9b443d4STobin Davis conexant_pcm_digital_playback; 383c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 384c9b443d4STobin Davis spec->multiout.dig_out_nid; 385c9b443d4STobin Davis if (spec->dig_in_nid) { 386c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 387c9b443d4STobin Davis conexant_pcm_digital_capture; 388c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 389c9b443d4STobin Davis spec->dig_in_nid; 390c9b443d4STobin Davis } 391c9b443d4STobin Davis } 392c9b443d4STobin Davis 393c9b443d4STobin Davis return 0; 394c9b443d4STobin Davis } 395c9b443d4STobin Davis 396c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 397c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 398c9b443d4STobin Davis { 399c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 400c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 401c9b443d4STobin Davis 402c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 403c9b443d4STobin Davis } 404c9b443d4STobin Davis 405c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 406c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 407c9b443d4STobin Davis { 408c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 409c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 410c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 411c9b443d4STobin Davis 412c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 413c9b443d4STobin Davis return 0; 414c9b443d4STobin Davis } 415c9b443d4STobin Davis 416c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 417c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 418c9b443d4STobin Davis { 419c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 420c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 421c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 422c9b443d4STobin Davis 423c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 424c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 425c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 426c9b443d4STobin Davis } 427c9b443d4STobin Davis 4284d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4294d7fbdbcSTakashi Iwai unsigned int power_state) 4304d7fbdbcSTakashi Iwai { 4314d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4324d7fbdbcSTakashi Iwai msleep(100); 4334d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4344d7fbdbcSTakashi Iwai power_state); 4354d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4364d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4374d7fbdbcSTakashi Iwai msleep(10); 4384d7fbdbcSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state, true); 4394d7fbdbcSTakashi Iwai } 4404d7fbdbcSTakashi Iwai 441c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 442c9b443d4STobin Davis { 443c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 444c9b443d4STobin Davis int i; 445c9b443d4STobin Davis 446c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 447c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 448c9b443d4STobin Davis return 0; 449c9b443d4STobin Davis } 450c9b443d4STobin Davis 451c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 452c9b443d4STobin Davis { 453ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 454c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 455ee48df57STakashi Iwai kfree(spec); 456c9b443d4STobin Davis } 457c9b443d4STobin Davis 45834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 459b880c74aSTakashi Iwai { 460b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 461b880c74aSTakashi Iwai .name = "Capture Source", 462b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 463b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 464b880c74aSTakashi Iwai .put = conexant_mux_enum_put 465b880c74aSTakashi Iwai }, 466b880c74aSTakashi Iwai {} 467b880c74aSTakashi Iwai }; 468b880c74aSTakashi Iwai 4699322ca54STakashi Iwai static const char * const slave_pfxs[] = { 470f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 471dd5746a8STakashi Iwai NULL 472dd5746a8STakashi Iwai }; 473dd5746a8STakashi Iwai 474c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 475c9b443d4STobin Davis { 476c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 477c9b443d4STobin Davis unsigned int i; 478c9b443d4STobin Davis int err; 479c9b443d4STobin Davis 480c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 481c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 482c9b443d4STobin Davis if (err < 0) 483c9b443d4STobin Davis return err; 484c9b443d4STobin Davis } 485c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 486c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 48774b654c9SStephen Warren spec->multiout.dig_out_nid, 488c9b443d4STobin Davis spec->multiout.dig_out_nid); 489c9b443d4STobin Davis if (err < 0) 490c9b443d4STobin Davis return err; 4919a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4929a08160bSTakashi Iwai &spec->multiout); 4939a08160bSTakashi Iwai if (err < 0) 4949a08160bSTakashi Iwai return err; 4959a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 496c9b443d4STobin Davis } 497c9b443d4STobin Davis if (spec->dig_in_nid) { 498c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 499c9b443d4STobin Davis if (err < 0) 500c9b443d4STobin Davis return err; 501c9b443d4STobin Davis } 502dd5746a8STakashi Iwai 503dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 504dd5746a8STakashi Iwai if (spec->vmaster_nid && 505dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 506dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 507dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 508dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 509dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5109322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5119322ca54STakashi Iwai "Playback Volume"); 512dd5746a8STakashi Iwai if (err < 0) 513dd5746a8STakashi Iwai return err; 514dd5746a8STakashi Iwai } 515dd5746a8STakashi Iwai if (spec->vmaster_nid && 516dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 517aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5189322ca54STakashi Iwai NULL, slave_pfxs, 519aed523f1STakashi Iwai "Playback Switch"); 520dd5746a8STakashi Iwai if (err < 0) 521dd5746a8STakashi Iwai return err; 522dd5746a8STakashi Iwai } 523dd5746a8STakashi Iwai 524b880c74aSTakashi Iwai if (spec->input_mux) { 525b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 526b880c74aSTakashi Iwai if (err < 0) 527b880c74aSTakashi Iwai return err; 528b880c74aSTakashi Iwai } 529b880c74aSTakashi Iwai 530aed523f1STakashi Iwai err = add_beep_ctls(codec); 5313507e2a8STakashi Iwai if (err < 0) 5323507e2a8STakashi Iwai return err; 5333507e2a8STakashi Iwai 534c9b443d4STobin Davis return 0; 535c9b443d4STobin Davis } 536c9b443d4STobin Davis 53734cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 538c9b443d4STobin Davis .build_controls = conexant_build_controls, 539c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 540c9b443d4STobin Davis .init = conexant_init, 541c9b443d4STobin Davis .free = conexant_free, 5424d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 543c9b443d4STobin Davis }; 544c9b443d4STobin Davis 5456764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 546c9b443d4STobin Davis /* 547c9b443d4STobin Davis * EAPD control 548c9b443d4STobin Davis * the private value = nid | (invert << 8) 549c9b443d4STobin Davis */ 550c9b443d4STobin Davis 551a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 552c9b443d4STobin Davis 55382f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 554c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 555c9b443d4STobin Davis { 556c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 557c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 558c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 559c9b443d4STobin Davis if (invert) 560c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 561c9b443d4STobin Davis else 562c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 563c9b443d4STobin Davis return 0; 56482f30040STobin Davis 565c9b443d4STobin Davis } 566c9b443d4STobin Davis 56782f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 568c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 569c9b443d4STobin Davis { 570c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 571c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 572c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 573c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 574c9b443d4STobin Davis unsigned int eapd; 57582f30040STobin Davis 57668ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 577c9b443d4STobin Davis if (invert) 578c9b443d4STobin Davis eapd = !eapd; 57982beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 580c9b443d4STobin Davis return 0; 58182f30040STobin Davis 582c9b443d4STobin Davis spec->cur_eapd = eapd; 58382beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 584c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 585c9b443d4STobin Davis eapd ? 0x02 : 0x00); 586c9b443d4STobin Davis return 1; 587c9b443d4STobin Davis } 588c9b443d4STobin Davis 58986d72bdfSTakashi Iwai /* controls for test mode */ 59086d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 59186d72bdfSTakashi Iwai 59282f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 59382f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 59482f30040STobin Davis .info = cxt_eapd_info, \ 59582f30040STobin Davis .get = cxt_eapd_get, \ 59682f30040STobin Davis .put = cxt_eapd_put, \ 59782f30040STobin Davis .private_value = nid | (mask<<16) } 59882f30040STobin Davis 59982f30040STobin Davis 60082f30040STobin Davis 601c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 602c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 603c9b443d4STobin Davis { 604c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 605c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 606c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 607c9b443d4STobin Davis spec->num_channel_mode); 608c9b443d4STobin Davis } 609c9b443d4STobin Davis 610c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 611c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 612c9b443d4STobin Davis { 613c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 614c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 615c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 616c9b443d4STobin Davis spec->num_channel_mode, 617c9b443d4STobin Davis spec->multiout.max_channels); 618c9b443d4STobin Davis } 619c9b443d4STobin Davis 620c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 621c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 622c9b443d4STobin Davis { 623c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 624c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 625c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 626c9b443d4STobin Davis spec->num_channel_mode, 627c9b443d4STobin Davis &spec->multiout.max_channels); 628c9b443d4STobin Davis return err; 629c9b443d4STobin Davis } 630c9b443d4STobin Davis 631c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 632c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 633c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 634c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 635c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 636c9b443d4STobin Davis .private_value = nid | (dir<<16) } 637c9b443d4STobin Davis 63886d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 63986d72bdfSTakashi Iwai 640c9b443d4STobin Davis /* Conexant 5045 specific */ 641c9b443d4STobin Davis 64234cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 64334cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 64434cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 645cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 646c9b443d4STobin Davis 64734cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6485cd57529STobin Davis { 2, NULL }, 6495cd57529STobin Davis }; 650c9b443d4STobin Davis 65134cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 652c9b443d4STobin Davis .num_items = 2, 653c9b443d4STobin Davis .items = { 6543edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6553edbbb9eSMichael Karcher { "Mic", 0x2 }, 656c9b443d4STobin Davis } 657c9b443d4STobin Davis }; 658c9b443d4STobin Davis 65934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 660e6e03daeSMichael Karcher .num_items = 4, 6615218c892SJiang Zhe .items = { 6623edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6633edbbb9eSMichael Karcher { "Mic", 0x2 }, 6643edbbb9eSMichael Karcher { "Line", 0x3 }, 66522e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6665218c892SJiang Zhe } 6675218c892SJiang Zhe }; 6685218c892SJiang Zhe 66934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_hp530 = { 6702de3c232SJiang zhe .num_items = 2, 6712de3c232SJiang zhe .items = { 6723edbbb9eSMichael Karcher { "Mic", 0x1 }, 6733edbbb9eSMichael Karcher { "Internal Mic", 0x2 }, 6742de3c232SJiang zhe } 6752de3c232SJiang zhe }; 6762de3c232SJiang zhe 677c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 678c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 679c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 680c9b443d4STobin Davis { 681c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 682c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 68382f30040STobin Davis unsigned int bits; 684c9b443d4STobin Davis 68582f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 686c9b443d4STobin Davis return 0; 687c9b443d4STobin Davis 68882f30040STobin Davis /* toggle internal speakers mute depending of presence of 68982f30040STobin Davis * the headphone jack 69082f30040STobin Davis */ 69147fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 69247fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 69347fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 6947f29673bSTobin Davis 69547fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 69647fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 69747fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 698c9b443d4STobin Davis return 1; 699c9b443d4STobin Davis } 700c9b443d4STobin Davis 701c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 70234cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 703cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 704cca3b371STakashi Iwai .values = { 705cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 706cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 707cca3b371STakashi Iwai 0 708cca3b371STakashi Iwai }, 709cca3b371STakashi Iwai }; 710c9b443d4STobin Davis 7117f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 7127f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7137f29673bSTobin Davis { 71434cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7157f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7167f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7177f29673bSTobin Davis {} 7187f29673bSTobin Davis }; 71934cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7207f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7217f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7227f29673bSTobin Davis {} 7237f29673bSTobin Davis }; 7247f29673bSTobin Davis unsigned int present; 7257f29673bSTobin Davis 726d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7277f29673bSTobin Davis if (present) 7287f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7297f29673bSTobin Davis else 7307f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7317f29673bSTobin Davis } 7327f29673bSTobin Davis 733c9b443d4STobin Davis 734c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 735c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 736c9b443d4STobin Davis { 73782f30040STobin Davis struct conexant_spec *spec = codec->spec; 738dd87da1cSTobin Davis unsigned int bits; 739c9b443d4STobin Davis 740d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 741dd87da1cSTobin Davis 74247fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 74347fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 74447fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 745c9b443d4STobin Davis } 746c9b443d4STobin Davis 747c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 748c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 749c9b443d4STobin Davis unsigned int res) 750c9b443d4STobin Davis { 751c9b443d4STobin Davis res >>= 26; 752c9b443d4STobin Davis switch (res) { 753c9b443d4STobin Davis case CONEXANT_HP_EVENT: 754c9b443d4STobin Davis cxt5045_hp_automute(codec); 755c9b443d4STobin Davis break; 7567f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7577f29673bSTobin Davis cxt5045_hp_automic(codec); 7587f29673bSTobin Davis break; 7597f29673bSTobin Davis 760c9b443d4STobin Davis } 761c9b443d4STobin Davis } 762c9b443d4STobin Davis 76334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 764cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 765cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 766c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 767c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 76828c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 76928c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7708607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7718607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 772cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 773c9b443d4STobin Davis { 774c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 775c9b443d4STobin Davis .name = "Master Playback Switch", 77682f30040STobin Davis .info = cxt_eapd_info, 77782f30040STobin Davis .get = cxt_eapd_get, 778c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 77982f30040STobin Davis .private_value = 0x10, 780c9b443d4STobin Davis }, 781c9b443d4STobin Davis 782c9b443d4STobin Davis {} 783c9b443d4STobin Davis }; 784c9b443d4STobin Davis 78534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7863edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7873edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 78822e14130SLukasz Marcinowski 7895218c892SJiang Zhe {} 7905218c892SJiang Zhe }; 7915218c892SJiang Zhe 79234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 793cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 794cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 7952de3c232SJiang zhe HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 7962de3c232SJiang zhe HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 79728c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 79828c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 7998607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 8008607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 8012de3c232SJiang zhe HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 8022de3c232SJiang zhe { 8032de3c232SJiang zhe .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8042de3c232SJiang zhe .name = "Master Playback Switch", 8052de3c232SJiang zhe .info = cxt_eapd_info, 8062de3c232SJiang zhe .get = cxt_eapd_get, 8072de3c232SJiang zhe .put = cxt5045_hp_master_sw_put, 8082de3c232SJiang zhe .private_value = 0x10, 8092de3c232SJiang zhe }, 8102de3c232SJiang zhe 8112de3c232SJiang zhe {} 8122de3c232SJiang zhe }; 8132de3c232SJiang zhe 81434cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 815c9b443d4STobin Davis /* Line in, Mic */ 8164090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8177f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 818c9b443d4STobin Davis /* HP, Amp */ 819c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 820c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 82182f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 822c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 823c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 824c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 825c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 826c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 827c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 82828c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8297f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 83082f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 831c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 832c9b443d4STobin Davis /* SPDIF route: PCM */ 833cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 834c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 835c9b443d4STobin Davis /* EAPD */ 83682f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 837c9b443d4STobin Davis { } /* end */ 838c9b443d4STobin Davis }; 839c9b443d4STobin Davis 84034cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 84128c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8425218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8435218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8445218c892SJiang Zhe /* Line In,HP, Amp */ 8455218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8465218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8475218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8485218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8495218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8505218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8515218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8525218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8535218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 85428c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8555218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8565218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8575218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8585218c892SJiang Zhe /* SPDIF route: PCM */ 859cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8605218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8615218c892SJiang Zhe /* EAPD */ 8625218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8635218c892SJiang Zhe { } /* end */ 8645218c892SJiang Zhe }; 8657f29673bSTobin Davis 86634cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8677f29673bSTobin Davis /* pin sensing on HP jack */ 8687f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 869d3091fadSTakashi Iwai { } /* end */ 8707f29673bSTobin Davis }; 8717f29673bSTobin Davis 87234cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8737f29673bSTobin Davis /* pin sensing on HP jack */ 8747f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 875d3091fadSTakashi Iwai { } /* end */ 8767f29673bSTobin Davis }; 8777f29673bSTobin Davis 878c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 879c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 880c9b443d4STobin Davis * configuration. 881c9b443d4STobin Davis */ 88234cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 883c9b443d4STobin Davis .num_items = 5, 884c9b443d4STobin Davis .items = { 885c9b443d4STobin Davis { "MIXER", 0x0 }, 886c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 887c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 888c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 889c9b443d4STobin Davis { "CD pin", 0x4 }, 890c9b443d4STobin Davis }, 891c9b443d4STobin Davis }; 892c9b443d4STobin Davis 89334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 894c9b443d4STobin Davis 895c9b443d4STobin Davis /* Output controls */ 896c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 897c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 898250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 899250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 900250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 901250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 902c9b443d4STobin Davis 903c9b443d4STobin Davis /* Modes for retasking pin widgets */ 904c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 905c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 906c9b443d4STobin Davis 90782f30040STobin Davis /* EAPD Switch Control */ 90882f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 90982f30040STobin Davis 910c9b443d4STobin Davis /* Loopback mixer controls */ 911c9b443d4STobin Davis 912250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 913250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 914250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 915250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 916250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 917250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 918250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 919250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 920250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 921250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 922c9b443d4STobin Davis { 923c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 924c9b443d4STobin Davis .name = "Input Source", 925c9b443d4STobin Davis .info = conexant_mux_enum_info, 926c9b443d4STobin Davis .get = conexant_mux_enum_get, 927c9b443d4STobin Davis .put = conexant_mux_enum_put, 928c9b443d4STobin Davis }, 929fb3409e7STobin Davis /* Audio input controls */ 930cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 931cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 932c9b443d4STobin Davis { } /* end */ 933c9b443d4STobin Davis }; 934c9b443d4STobin Davis 93534cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9367f29673bSTobin Davis /* Set connections */ 9377f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9387f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9397f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 940c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 941c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9427f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 943c9b443d4STobin Davis 944c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 945c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 946c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 947c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 948c9b443d4STobin Davis * control. 949c9b443d4STobin Davis */ 950cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 951cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 952c9b443d4STobin Davis 953c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 954c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 955c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 956c9b443d4STobin Davis * input/output buffers as needed. 957c9b443d4STobin Davis */ 958c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 959c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 960c9b443d4STobin Davis 961c9b443d4STobin Davis /* Mute capture amp left and right */ 962c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 963c9b443d4STobin Davis 964c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 965c9b443d4STobin Davis * pin) 966c9b443d4STobin Davis */ 967250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 968250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 969c9b443d4STobin Davis 970c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 971250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 972c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 973c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 974c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 975c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 976c9b443d4STobin Davis 977c9b443d4STobin Davis { } 978c9b443d4STobin Davis }; 979c9b443d4STobin Davis #endif 980c9b443d4STobin Davis 981c9b443d4STobin Davis 982c9b443d4STobin Davis /* initialize jack-sensing, too */ 983c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 984c9b443d4STobin Davis { 985c9b443d4STobin Davis conexant_init(codec); 986c9b443d4STobin Davis cxt5045_hp_automute(codec); 987c9b443d4STobin Davis return 0; 988c9b443d4STobin Davis } 989c9b443d4STobin Davis 990c9b443d4STobin Davis 991c9b443d4STobin Davis enum { 99215908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 99315908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 99415908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 9955218c892SJiang Zhe CXT5045_BENQ, 9962de3c232SJiang zhe CXT5045_LAPTOP_HP530, 997c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 998c9b443d4STobin Davis CXT5045_TEST, 999c9b443d4STobin Davis #endif 10001f8458a2STakashi Iwai CXT5045_AUTO, 1001f5fcc13cSTakashi Iwai CXT5045_MODELS 1002c9b443d4STobin Davis }; 1003c9b443d4STobin Davis 1004ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 100515908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 100615908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 100715908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 10085218c892SJiang Zhe [CXT5045_BENQ] = "benq", 10092de3c232SJiang zhe [CXT5045_LAPTOP_HP530] = "laptop-hp530", 1010c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1011f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 1012c9b443d4STobin Davis #endif 10131f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 1014f5fcc13cSTakashi Iwai }; 1015c9b443d4STobin Davis 101634cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 10172de3c232SJiang zhe SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 10186a9dccd6STakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 10195218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 102015908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 102115908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 10229e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 10239e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 102415908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 102515908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 102615908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1027dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 1028dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 102915908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1030c9b443d4STobin Davis {} 1031c9b443d4STobin Davis }; 1032c9b443d4STobin Davis 1033c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 1034c9b443d4STobin Davis { 1035c9b443d4STobin Davis struct conexant_spec *spec; 1036c9b443d4STobin Davis int board_config; 1037c9b443d4STobin Davis 10381f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10391f8458a2STakashi Iwai cxt5045_models, 10401f8458a2STakashi Iwai cxt5045_cfg_tbl); 10411f8458a2STakashi Iwai if (board_config < 0) 1042c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10431f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10441f8458a2STakashi Iwai return patch_conexant_auto(codec); 10451f8458a2STakashi Iwai 1046c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1047c9b443d4STobin Davis if (!spec) 1048c9b443d4STobin Davis return -ENOMEM; 1049c9b443d4STobin Davis codec->spec = spec; 10504f32456eSMichael Karcher codec->single_adc_amp = 1; 1051c9b443d4STobin Davis 1052c9b443d4STobin Davis spec->multiout.max_channels = 2; 1053c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1054c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1055c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1056c9b443d4STobin Davis spec->num_adc_nids = 1; 1057c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1058c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1059c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1060c9b443d4STobin Davis spec->num_mixers = 1; 1061c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1062c9b443d4STobin Davis spec->num_init_verbs = 1; 1063c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1064c9b443d4STobin Davis spec->spdif_route = 0; 10653507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10663507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10675cd57529STobin Davis 10683507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1069c9b443d4STobin Davis 1070c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1071c9b443d4STobin Davis 1072c9b443d4STobin Davis switch (board_config) { 107315908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10747f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1075c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1076c9b443d4STobin Davis spec->num_init_verbs = 2; 10777f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10787f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10797f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10807f29673bSTobin Davis break; 108115908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 108286376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10837f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10847f29673bSTobin Davis spec->num_init_verbs = 2; 10857f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1086c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1087c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1088c9b443d4STobin Davis break; 108915908c36SMarc Boucher default: 109015908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 109115908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 109215908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 109315908c36SMarc Boucher spec->num_init_verbs = 3; 109415908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 109515908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 109615908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 109715908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 109815908c36SMarc Boucher break; 10995218c892SJiang Zhe case CXT5045_BENQ: 11005218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11015218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 11025218c892SJiang Zhe spec->num_init_verbs = 1; 11035218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 11045218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 11055218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 11065218c892SJiang Zhe spec->num_mixers = 2; 11075218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 11085218c892SJiang Zhe break; 11092de3c232SJiang zhe case CXT5045_LAPTOP_HP530: 11102de3c232SJiang zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11112de3c232SJiang zhe spec->input_mux = &cxt5045_capture_source_hp530; 11122de3c232SJiang zhe spec->num_init_verbs = 2; 11132de3c232SJiang zhe spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 11142de3c232SJiang zhe spec->mixers[0] = cxt5045_mixers_hp530; 11152de3c232SJiang zhe codec->patch_ops.init = cxt5045_init; 11162de3c232SJiang zhe break; 1117c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1118c9b443d4STobin Davis case CXT5045_TEST: 1119c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1120c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1121c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 112215908c36SMarc Boucher break; 112315908c36SMarc Boucher 1124c9b443d4STobin Davis #endif 1125c9b443d4STobin Davis } 112648ecb7e8STakashi Iwai 1127031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1128031005f7STakashi Iwai case 0x103c: 11298f0f5ff6SDaniel T Chen case 0x1631: 11300b587fc4SDaniel T Chen case 0x1734: 11310ebf9e36SDaniel T Chen case 0x17aa: 11320ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 11330ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 11340ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 113548ecb7e8STakashi Iwai */ 113648ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 113748ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 113848ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 113948ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 114048ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1141031005f7STakashi Iwai break; 1142031005f7STakashi Iwai } 114348ecb7e8STakashi Iwai 11443507e2a8STakashi Iwai if (spec->beep_amp) 11453507e2a8STakashi Iwai snd_hda_attach_beep_device(codec, spec->beep_amp); 11463507e2a8STakashi Iwai 1147c9b443d4STobin Davis return 0; 1148c9b443d4STobin Davis } 1149c9b443d4STobin Davis 1150c9b443d4STobin Davis 1151c9b443d4STobin Davis /* Conexant 5047 specific */ 115282f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1153c9b443d4STobin Davis 115434cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 115534cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 115634cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1157c9b443d4STobin Davis 115834cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11595cd57529STobin Davis { 2, NULL }, 11605cd57529STobin Davis }; 1161c9b443d4STobin Davis 116234cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 116382f30040STobin Davis .num_items = 2, 116482f30040STobin Davis .items = { 116582f30040STobin Davis { "ExtMic", 0x2 }, 116682f30040STobin Davis { "Line-In", 0x1 }, 1167c9b443d4STobin Davis } 1168c9b443d4STobin Davis }; 1169c9b443d4STobin Davis 1170c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1171c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1172c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1173c9b443d4STobin Davis { 1174c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1175c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 117682f30040STobin Davis unsigned int bits; 1177c9b443d4STobin Davis 117882f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1179c9b443d4STobin Davis return 0; 1180c9b443d4STobin Davis 118182f30040STobin Davis /* toggle internal speakers mute depending of presence of 118282f30040STobin Davis * the headphone jack 118382f30040STobin Davis */ 118447fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11853b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11863b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11873b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11883b7523fcSTakashi Iwai */ 11895d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 119047fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 119147fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 119247fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 119347fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1194c9b443d4STobin Davis return 1; 1195c9b443d4STobin Davis } 1196c9b443d4STobin Davis 1197c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1198c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1199c9b443d4STobin Davis { 120082f30040STobin Davis struct conexant_spec *spec = codec->spec; 1201dd87da1cSTobin Davis unsigned int bits; 1202c9b443d4STobin Davis 1203d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1204dd87da1cSTobin Davis 120547fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 12063b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12075d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 120847fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1209c9b443d4STobin Davis } 1210c9b443d4STobin Davis 1211c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1212c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1213c9b443d4STobin Davis { 121434cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 12159f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12169f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1217c9b443d4STobin Davis {} 1218c9b443d4STobin Davis }; 121934cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 12209f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12219f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1222c9b443d4STobin Davis {} 1223c9b443d4STobin Davis }; 1224c9b443d4STobin Davis unsigned int present; 1225c9b443d4STobin Davis 1226d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1227c9b443d4STobin Davis if (present) 1228c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1229c9b443d4STobin Davis else 1230c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1231c9b443d4STobin Davis } 1232c9b443d4STobin Davis 1233c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1234c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1235c9b443d4STobin Davis unsigned int res) 1236c9b443d4STobin Davis { 12379f113e0eSMarc Boucher switch (res >> 26) { 1238c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1239c9b443d4STobin Davis cxt5047_hp_automute(codec); 1240c9b443d4STobin Davis break; 1241c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1242c9b443d4STobin Davis cxt5047_hp_automic(codec); 1243c9b443d4STobin Davis break; 1244c9b443d4STobin Davis } 1245c9b443d4STobin Davis } 1246c9b443d4STobin Davis 124734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1248df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1249df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12505f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1251c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1252c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1253c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1254c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 125582f30040STobin Davis { 125682f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 125782f30040STobin Davis .name = "Master Playback Switch", 125882f30040STobin Davis .info = cxt_eapd_info, 125982f30040STobin Davis .get = cxt_eapd_get, 1260c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1261c9b443d4STobin Davis .private_value = 0x13, 1262c9b443d4STobin Davis }, 1263c9b443d4STobin Davis 1264c9b443d4STobin Davis {} 1265c9b443d4STobin Davis }; 1266c9b443d4STobin Davis 126734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12683b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12695d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1270df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1271df481e41STakashi Iwai {} 1272df481e41STakashi Iwai }; 1273df481e41STakashi Iwai 127434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1275c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1276c9b443d4STobin Davis { } /* end */ 1277c9b443d4STobin Davis }; 1278c9b443d4STobin Davis 127934cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1280c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1281c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1282c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1283c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12847f29673bSTobin Davis /* HP, Speaker */ 1285b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12865b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12875b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12887f29673bSTobin Davis /* Record selector: Mic */ 12897f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12907f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12917f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12927f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1293c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1294c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1295c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1296c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1297c9b443d4STobin Davis /* SPDIF route: PCM */ 1298c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 129982f30040STobin Davis /* Enable unsolicited events */ 130082f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 130182f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1302c9b443d4STobin Davis { } /* end */ 1303c9b443d4STobin Davis }; 1304c9b443d4STobin Davis 1305c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 130634cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 13073b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1308c9b443d4STobin Davis {} 1309c9b443d4STobin Davis }; 1310c9b443d4STobin Davis 1311c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1312c9b443d4STobin Davis * configuration. 1313c9b443d4STobin Davis */ 1314c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 131534cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 131682f30040STobin Davis .num_items = 4, 1317c9b443d4STobin Davis .items = { 131882f30040STobin Davis { "LINE1 pin", 0x0 }, 131982f30040STobin Davis { "MIC1 pin", 0x1 }, 132082f30040STobin Davis { "MIC2 pin", 0x2 }, 132182f30040STobin Davis { "CD pin", 0x3 }, 1322c9b443d4STobin Davis }, 1323c9b443d4STobin Davis }; 1324c9b443d4STobin Davis 132534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1326c9b443d4STobin Davis 1327c9b443d4STobin Davis /* Output only controls */ 132882f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 132982f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 133082f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 133182f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1332c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1333c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1334c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1335c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 133682f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 133782f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 133882f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 133982f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1340c9b443d4STobin Davis 1341c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1342c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1343c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1344c9b443d4STobin Davis 134582f30040STobin Davis /* EAPD Switch Control */ 134682f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 134782f30040STobin Davis 1348c9b443d4STobin Davis /* Loopback mixer controls */ 134982f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 135082f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 135182f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 135282f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 135382f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 135482f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 135582f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 135682f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1357c9b443d4STobin Davis 135882f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 135982f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 136082f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 136182f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 136282f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 136382f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 136482f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 136582f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1366c9b443d4STobin Davis { 1367c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1368c9b443d4STobin Davis .name = "Input Source", 1369c9b443d4STobin Davis .info = conexant_mux_enum_info, 1370c9b443d4STobin Davis .get = conexant_mux_enum_get, 1371c9b443d4STobin Davis .put = conexant_mux_enum_put, 1372c9b443d4STobin Davis }, 1373854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13749f113e0eSMarc Boucher 1375c9b443d4STobin Davis { } /* end */ 1376c9b443d4STobin Davis }; 1377c9b443d4STobin Davis 137834cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1379c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1380c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1381c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1382c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1383c9b443d4STobin Davis 1384c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1385c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1386c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1387c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1388c9b443d4STobin Davis * control. 1389c9b443d4STobin Davis */ 1390c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1391c9b443d4STobin Davis 1392c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1393c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1394c9b443d4STobin Davis */ 1395c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1396c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1397c9b443d4STobin Davis 1398c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1399c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1400c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1401c9b443d4STobin Davis 1402c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1403c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1404c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1405c9b443d4STobin Davis * input/output buffers as needed. 1406c9b443d4STobin Davis */ 1407c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1408c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1409c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1410c9b443d4STobin Davis 1411c9b443d4STobin Davis /* Mute capture amp left and right */ 1412c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1413c9b443d4STobin Davis 1414c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1415c9b443d4STobin Davis * pin) 1416c9b443d4STobin Davis */ 1417c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1418c9b443d4STobin Davis 1419c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1420c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1421c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1422c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1423c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1424c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1425c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1426c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1427c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1428c9b443d4STobin Davis 1429c9b443d4STobin Davis { } 1430c9b443d4STobin Davis }; 1431c9b443d4STobin Davis #endif 1432c9b443d4STobin Davis 1433c9b443d4STobin Davis 1434c9b443d4STobin Davis /* initialize jack-sensing, too */ 1435c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1436c9b443d4STobin Davis { 1437c9b443d4STobin Davis conexant_init(codec); 1438c9b443d4STobin Davis cxt5047_hp_automute(codec); 1439c9b443d4STobin Davis return 0; 1440c9b443d4STobin Davis } 1441c9b443d4STobin Davis 1442c9b443d4STobin Davis 1443c9b443d4STobin Davis enum { 1444f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1445f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1446f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1447c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1448c9b443d4STobin Davis CXT5047_TEST, 1449c9b443d4STobin Davis #endif 1450fa5dadcbSTakashi Iwai CXT5047_AUTO, 1451f5fcc13cSTakashi Iwai CXT5047_MODELS 1452c9b443d4STobin Davis }; 1453c9b443d4STobin Davis 1454ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1455f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1456f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1457f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1458c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1459f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1460c9b443d4STobin Davis #endif 1461fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1462f5fcc13cSTakashi Iwai }; 1463c9b443d4STobin Davis 146434cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1465ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1466dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1467dea0a509STakashi Iwai CXT5047_LAPTOP), 1468f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1469c9b443d4STobin Davis {} 1470c9b443d4STobin Davis }; 1471c9b443d4STobin Davis 1472c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1473c9b443d4STobin Davis { 1474c9b443d4STobin Davis struct conexant_spec *spec; 1475c9b443d4STobin Davis int board_config; 1476c9b443d4STobin Davis 1477fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1478fa5dadcbSTakashi Iwai cxt5047_models, 1479fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1480fa5dadcbSTakashi Iwai if (board_config < 0) 1481c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1482fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1483fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1484fa5dadcbSTakashi Iwai 1485c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1486c9b443d4STobin Davis if (!spec) 1487c9b443d4STobin Davis return -ENOMEM; 1488c9b443d4STobin Davis codec->spec = spec; 14899421f954STakashi Iwai codec->pin_amp_workaround = 1; 1490c9b443d4STobin Davis 1491c9b443d4STobin Davis spec->multiout.max_channels = 2; 1492c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1493c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1494c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1495c9b443d4STobin Davis spec->num_adc_nids = 1; 1496c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1497c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1498c9b443d4STobin Davis spec->num_mixers = 1; 1499df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1500c9b443d4STobin Davis spec->num_init_verbs = 1; 1501c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1502c9b443d4STobin Davis spec->spdif_route = 0; 15035cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 15045cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1505c9b443d4STobin Davis 1506c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1507c9b443d4STobin Davis 1508c9b443d4STobin Davis switch (board_config) { 1509c9b443d4STobin Davis case CXT5047_LAPTOP: 1510df481e41STakashi Iwai spec->num_mixers = 2; 1511df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1512df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1513c9b443d4STobin Davis break; 1514c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1515df481e41STakashi Iwai spec->num_mixers = 2; 1516df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1517fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1518c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1519c9b443d4STobin Davis break; 1520c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 152182f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1522df481e41STakashi Iwai spec->num_mixers = 2; 1523df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1524c9b443d4STobin Davis spec->num_init_verbs = 2; 1525c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1526fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1527c9b443d4STobin Davis break; 1528c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1529c9b443d4STobin Davis case CXT5047_TEST: 1530c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1531c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1532c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1533fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1534c9b443d4STobin Davis #endif 1535c9b443d4STobin Davis } 1536dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1537025f206cSDaniel T Chen 1538025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1539025f206cSDaniel T Chen case 0x103c: 1540025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1541025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1542025f206cSDaniel T Chen * with 0 dB offset 0x17) 1543025f206cSDaniel T Chen */ 1544025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1545025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1546025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1547025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1548025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1549025f206cSDaniel T Chen break; 1550025f206cSDaniel T Chen } 1551025f206cSDaniel T Chen 1552c9b443d4STobin Davis return 0; 1553c9b443d4STobin Davis } 1554c9b443d4STobin Davis 1555461e2c78STakashi Iwai /* Conexant 5051 specific */ 155634cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 155734cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1558461e2c78STakashi Iwai 155934cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1560461e2c78STakashi Iwai { 2, NULL }, 1561461e2c78STakashi Iwai }; 1562461e2c78STakashi Iwai 1563461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1564461e2c78STakashi Iwai { 1565461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1566461e2c78STakashi Iwai unsigned int pinctl; 156723d2df5bSTakashi Iwai /* headphone pin */ 156823d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1569cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 157023d2df5bSTakashi Iwai /* speaker pin */ 1571461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1572cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1573a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1574f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1575cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1576461e2c78STakashi Iwai } 1577461e2c78STakashi Iwai 1578461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1579461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1580461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1581461e2c78STakashi Iwai { 1582461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1583461e2c78STakashi Iwai 1584461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1585461e2c78STakashi Iwai return 0; 1586461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1587461e2c78STakashi Iwai return 1; 1588461e2c78STakashi Iwai } 1589461e2c78STakashi Iwai 1590461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1591461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1592461e2c78STakashi Iwai { 159379d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1594461e2c78STakashi Iwai unsigned int present; 1595461e2c78STakashi Iwai 1596faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 159779d7d533STakashi Iwai return; 1598d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1599461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1600461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1601461e2c78STakashi Iwai present ? 0x01 : 0x00); 1602461e2c78STakashi Iwai } 1603461e2c78STakashi Iwai 1604461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1605461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1606461e2c78STakashi Iwai { 1607461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1608461e2c78STakashi Iwai unsigned int present; 1609461e2c78STakashi Iwai hda_nid_t new_adc; 1610461e2c78STakashi Iwai 1611faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 161279d7d533STakashi Iwai return; 1613d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1614461e2c78STakashi Iwai if (present) 1615461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1616461e2c78STakashi Iwai else 1617461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1618461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1619461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1620461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1621f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1622461e2c78STakashi Iwai spec->cur_adc = new_adc; 1623461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1624461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1625461e2c78STakashi Iwai spec->cur_adc_format); 1626461e2c78STakashi Iwai } 1627461e2c78STakashi Iwai } 1628461e2c78STakashi Iwai 1629461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1630461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1631461e2c78STakashi Iwai { 1632461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1633461e2c78STakashi Iwai 1634d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1635461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1636461e2c78STakashi Iwai } 1637461e2c78STakashi Iwai 1638461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1639461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1640461e2c78STakashi Iwai unsigned int res) 1641461e2c78STakashi Iwai { 1642461e2c78STakashi Iwai switch (res >> 26) { 1643461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1644461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1645461e2c78STakashi Iwai break; 1646461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1647461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1648461e2c78STakashi Iwai break; 1649461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1650461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1651461e2c78STakashi Iwai break; 1652461e2c78STakashi Iwai } 1653461e2c78STakashi Iwai } 1654461e2c78STakashi Iwai 165534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1656461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1657461e2c78STakashi Iwai { 1658461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1659461e2c78STakashi Iwai .name = "Master Playback Switch", 1660461e2c78STakashi Iwai .info = cxt_eapd_info, 1661461e2c78STakashi Iwai .get = cxt_eapd_get, 1662461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1663461e2c78STakashi Iwai .private_value = 0x1a, 1664461e2c78STakashi Iwai }, 16652c7a3fb3STakashi Iwai {} 16662c7a3fb3STakashi Iwai }; 1667461e2c78STakashi Iwai 166834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16692c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16702c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16718607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16728607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1673c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1674c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1675461e2c78STakashi Iwai {} 1676461e2c78STakashi Iwai }; 1677461e2c78STakashi Iwai 167834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1679461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1680461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16818607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16828607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1683461e2c78STakashi Iwai {} 1684461e2c78STakashi Iwai }; 1685461e2c78STakashi Iwai 168634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16874e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16884e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 168979d7d533STakashi Iwai {} 169079d7d533STakashi Iwai }; 169179d7d533STakashi Iwai 169234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 16935f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 16945f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1695cd9d95a5SKen Prox {} 1696cd9d95a5SKen Prox }; 1697cd9d95a5SKen Prox 169834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1699faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1700faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 17018607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 17028607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1703faddaa5dSTakashi Iwai {} 1704faddaa5dSTakashi Iwai }; 1705faddaa5dSTakashi Iwai 170634cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1707461e2c78STakashi Iwai /* Line in, Mic */ 1708461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1709461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1710461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1711461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1712461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1713461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1714461e2c78STakashi Iwai /* SPK */ 1715461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1716461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1717461e2c78STakashi Iwai /* HP, Amp */ 1718461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1719461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1720461e2c78STakashi Iwai /* DAC1 */ 1721461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172228c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1723461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1724461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1725461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1726461e2c78STakashi Iwai /* SPDIF route: PCM */ 17271965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1728461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1729461e2c78STakashi Iwai /* EAPD */ 1730461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1731461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1732461e2c78STakashi Iwai { } /* end */ 1733461e2c78STakashi Iwai }; 1734461e2c78STakashi Iwai 173534cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 173679d7d533STakashi Iwai /* Line in, Mic */ 173779d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 173879d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 173979d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174079d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174179d7d533STakashi Iwai /* SPK */ 174279d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 174379d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 174479d7d533STakashi Iwai /* HP, Amp */ 174579d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 174679d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 174779d7d533STakashi Iwai /* DAC1 */ 174879d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 174928c4edb7SDavid Henningsson /* Record selector: Internal mic */ 175079d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 175179d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 175279d7d533STakashi Iwai /* SPDIF route: PCM */ 175379d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 175479d7d533STakashi Iwai /* EAPD */ 175579d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 175679d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 175779d7d533STakashi Iwai { } /* end */ 175879d7d533STakashi Iwai }; 175979d7d533STakashi Iwai 176034cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1761cd9d95a5SKen Prox /* Line in, Mic */ 176230ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1763cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1764cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1765cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1766cd9d95a5SKen Prox /* SPK */ 1767cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1768cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1769cd9d95a5SKen Prox /* HP, Amp */ 1770cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1771cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1772cd9d95a5SKen Prox /* DAC1 */ 1773cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 177428c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1775cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1776cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1777cd9d95a5SKen Prox /* SPDIF route: PCM */ 1778cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1779cd9d95a5SKen Prox /* EAPD */ 1780cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1781cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1782cd9d95a5SKen Prox { } /* end */ 1783cd9d95a5SKen Prox }; 1784cd9d95a5SKen Prox 17856953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17866953e552STakashi Iwai unsigned int event) 17876953e552STakashi Iwai { 17886953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17896953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17906953e552STakashi Iwai AC_USRSP_EN | event); 17916953e552STakashi Iwai } 17926953e552STakashi Iwai 179334cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1794f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1795f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1796f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1797f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1798f7154de2SHerton Ronaldo Krzesinski }; 1799f7154de2SHerton Ronaldo Krzesinski 1800461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1801461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1802461e2c78STakashi Iwai { 18036953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 18046953e552STakashi Iwai 1805461e2c78STakashi Iwai conexant_init(codec); 18066953e552STakashi Iwai 18076953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 18086953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 18096953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 18106953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 18116953e552STakashi Iwai 1812461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1813461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1814461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1815461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1816461e2c78STakashi Iwai } 1817461e2c78STakashi Iwai return 0; 1818461e2c78STakashi Iwai } 1819461e2c78STakashi Iwai 1820461e2c78STakashi Iwai 1821461e2c78STakashi Iwai enum { 1822461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1823461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 182479d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1825cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1826faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1827f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 18286764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1829461e2c78STakashi Iwai CXT5051_MODELS 1830461e2c78STakashi Iwai }; 1831461e2c78STakashi Iwai 1832ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1833461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1834461e2c78STakashi Iwai [CXT5051_HP] = "hp", 183579d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 18365f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1837faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1838f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 18396764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1840461e2c78STakashi Iwai }; 1841461e2c78STakashi Iwai 184234cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 184379d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 18441812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 18455f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1846faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1847461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1848461e2c78STakashi Iwai CXT5051_LAPTOP), 1849461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1850f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1851461e2c78STakashi Iwai {} 1852461e2c78STakashi Iwai }; 1853461e2c78STakashi Iwai 1854461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1855461e2c78STakashi Iwai { 1856461e2c78STakashi Iwai struct conexant_spec *spec; 1857461e2c78STakashi Iwai int board_config; 1858461e2c78STakashi Iwai 18596764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18606764bcefSTakashi Iwai cxt5051_models, 18616764bcefSTakashi Iwai cxt5051_cfg_tbl); 18626764bcefSTakashi Iwai if (board_config < 0) 1863c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18641f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18656764bcefSTakashi Iwai return patch_conexant_auto(codec); 18666764bcefSTakashi Iwai 1867461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1868461e2c78STakashi Iwai if (!spec) 1869461e2c78STakashi Iwai return -ENOMEM; 1870461e2c78STakashi Iwai codec->spec = spec; 18719421f954STakashi Iwai codec->pin_amp_workaround = 1; 1872461e2c78STakashi Iwai 1873461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1874461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1875461e2c78STakashi Iwai 1876461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1877461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1878461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1879461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1880461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1881461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18822c7a3fb3STakashi Iwai spec->num_mixers = 2; 18832c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18842c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1885461e2c78STakashi Iwai spec->num_init_verbs = 1; 1886461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1887461e2c78STakashi Iwai spec->spdif_route = 0; 1888461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1889461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1890461e2c78STakashi Iwai spec->cur_adc = 0; 1891461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1892461e2c78STakashi Iwai 18933507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 18943507e2a8STakashi Iwai 189579d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 189679d7d533STakashi Iwai 1897faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1898461e2c78STakashi Iwai switch (board_config) { 1899461e2c78STakashi Iwai case CXT5051_HP: 1900461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1901461e2c78STakashi Iwai break; 190279d7d533STakashi Iwai case CXT5051_HP_DV6736: 190379d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 190479d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1905faddaa5dSTakashi Iwai spec->auto_mic = 0; 190679d7d533STakashi Iwai break; 1907cd9d95a5SKen Prox case CXT5051_F700: 1908cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1909cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1910faddaa5dSTakashi Iwai spec->auto_mic = 0; 1911faddaa5dSTakashi Iwai break; 1912faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1913faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1914faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1915cd9d95a5SKen Prox break; 1916f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1917f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1918f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1919f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1920f7154de2SHerton Ronaldo Krzesinski break; 1921461e2c78STakashi Iwai } 1922461e2c78STakashi Iwai 19233507e2a8STakashi Iwai if (spec->beep_amp) 19243507e2a8STakashi Iwai snd_hda_attach_beep_device(codec, spec->beep_amp); 19253507e2a8STakashi Iwai 1926461e2c78STakashi Iwai return 0; 1927461e2c78STakashi Iwai } 1928461e2c78STakashi Iwai 19290fb67e98SDaniel Drake /* Conexant 5066 specific */ 19300fb67e98SDaniel Drake 193134cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 193234cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 193334cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 193434cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 19350fb67e98SDaniel Drake 1936dbaccc0cSDaniel Drake /* OLPC's microphone port is DC coupled for use with external sensors, 1937dbaccc0cSDaniel Drake * therefore we use a 50% mic bias in order to center the input signal with 1938dbaccc0cSDaniel Drake * the DC input range of the codec. */ 1939dbaccc0cSDaniel Drake #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 1940dbaccc0cSDaniel Drake 194134cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 19420fb67e98SDaniel Drake { 2, NULL }, 19430fb67e98SDaniel Drake }; 19440fb67e98SDaniel Drake 1945a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1946a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1947a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1948a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1949a3de8ab8STakashi Iwai 19500fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 19510fb67e98SDaniel Drake { 19520fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19530fb67e98SDaniel Drake unsigned int pinctl; 19540fb67e98SDaniel Drake 19553a253445SJohn Baboval snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 19563a253445SJohn Baboval spec->hp_present, spec->cur_eapd); 19570fb67e98SDaniel Drake 19580fb67e98SDaniel Drake /* Port A (HP) */ 1959a3de8ab8STakashi Iwai pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; 1960cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x19, pinctl); 19610fb67e98SDaniel Drake 19620fb67e98SDaniel Drake /* Port D (HP/LO) */ 1963a3de8ab8STakashi Iwai pinctl = spec->cur_eapd ? spec->port_d_mode : 0; 1964a3de8ab8STakashi Iwai if (spec->dell_automute || spec->thinkpad) { 1965a3de8ab8STakashi Iwai /* Mute if Port A is connected */ 1966a3de8ab8STakashi Iwai if (hp_port_a_present(spec)) 19673a253445SJohn Baboval pinctl = 0; 19683a253445SJohn Baboval } else { 1969a3de8ab8STakashi Iwai /* Thinkpad/Dell doesn't give pin-D status */ 1970a3de8ab8STakashi Iwai if (!hp_port_d_present(spec)) 1971a3de8ab8STakashi Iwai pinctl = 0; 19723a253445SJohn Baboval } 1973cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1c, pinctl); 19740fb67e98SDaniel Drake 19750fb67e98SDaniel Drake /* CLASS_D AMP */ 19760fb67e98SDaniel Drake pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1977cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1f, pinctl); 19780fb67e98SDaniel Drake } 19790fb67e98SDaniel Drake 19800fb67e98SDaniel Drake /* turn on/off EAPD (+ mute HP) as a master switch */ 19810fb67e98SDaniel Drake static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, 19820fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 19830fb67e98SDaniel Drake { 19840fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 19850fb67e98SDaniel Drake 19860fb67e98SDaniel Drake if (!cxt_eapd_put(kcontrol, ucontrol)) 19870fb67e98SDaniel Drake return 0; 19880fb67e98SDaniel Drake 19890fb67e98SDaniel Drake cxt5066_update_speaker(codec); 19900fb67e98SDaniel Drake return 1; 19910fb67e98SDaniel Drake } 19920fb67e98SDaniel Drake 1993c4cfe66cSDaniel Drake static const struct hda_input_mux cxt5066_olpc_dc_bias = { 1994c4cfe66cSDaniel Drake .num_items = 3, 1995c4cfe66cSDaniel Drake .items = { 1996c4cfe66cSDaniel Drake { "Off", PIN_IN }, 1997c4cfe66cSDaniel Drake { "50%", PIN_VREF50 }, 1998c4cfe66cSDaniel Drake { "80%", PIN_VREF80 }, 1999c4cfe66cSDaniel Drake }, 2000c4cfe66cSDaniel Drake }; 2001c4cfe66cSDaniel Drake 2002c4cfe66cSDaniel Drake static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) 2003c4cfe66cSDaniel Drake { 2004c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2005c4cfe66cSDaniel Drake /* Even though port F is the DC input, the bias is controlled on port B. 2006c4cfe66cSDaniel Drake * we also leave that port as an active input (but unselected) in DC mode 2007c4cfe66cSDaniel Drake * just in case that is necessary to make the bias setting take effect. */ 2008cdd03cedSTakashi Iwai return snd_hda_set_pin_ctl_cache(codec, 0x1a, 2009c4cfe66cSDaniel Drake cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); 2010c4cfe66cSDaniel Drake } 2011c4cfe66cSDaniel Drake 201275f8991dSDaniel Drake /* OLPC defers mic widget control until when capture is started because the 201375f8991dSDaniel Drake * microphone LED comes on as soon as these settings are put in place. if we 201475f8991dSDaniel Drake * did this before recording, it would give the false indication that recording 201575f8991dSDaniel Drake * is happening when it is not. */ 201675f8991dSDaniel Drake static void cxt5066_olpc_select_mic(struct hda_codec *codec) 20170fb67e98SDaniel Drake { 2018dbaccc0cSDaniel Drake struct conexant_spec *spec = codec->spec; 201975f8991dSDaniel Drake if (!spec->recording) 202075f8991dSDaniel Drake return; 20210fb67e98SDaniel Drake 2022c4cfe66cSDaniel Drake if (spec->dc_enable) { 2023c4cfe66cSDaniel Drake /* in DC mode we ignore presence detection and just use the jack 2024c4cfe66cSDaniel Drake * through our special DC port */ 2025c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2026c4cfe66cSDaniel Drake /* disble internal mic, port C */ 2027c4cfe66cSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2028c4cfe66cSDaniel Drake 2029c4cfe66cSDaniel Drake /* enable DC capture, port F */ 2030c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2031c4cfe66cSDaniel Drake {}, 2032c4cfe66cSDaniel Drake }; 2033c4cfe66cSDaniel Drake 2034c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2035c4cfe66cSDaniel Drake /* port B input disabled (and bias set) through the following call */ 2036c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 2037c4cfe66cSDaniel Drake return; 2038c4cfe66cSDaniel Drake } 2039c4cfe66cSDaniel Drake 2040c4cfe66cSDaniel Drake /* disable DC (port F) */ 2041cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1e, 0); 2042c4cfe66cSDaniel Drake 204375f8991dSDaniel Drake /* external mic, port B */ 2044cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, 204575f8991dSDaniel Drake spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); 20460fb67e98SDaniel Drake 204775f8991dSDaniel Drake /* internal mic, port C */ 2048cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, 204975f8991dSDaniel Drake spec->ext_mic_present ? 0 : PIN_VREF80); 205075f8991dSDaniel Drake } 20510fb67e98SDaniel Drake 205275f8991dSDaniel Drake /* toggle input of built-in and mic jack appropriately */ 205375f8991dSDaniel Drake static void cxt5066_olpc_automic(struct hda_codec *codec) 205475f8991dSDaniel Drake { 205575f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 20560fb67e98SDaniel Drake unsigned int present; 20570fb67e98SDaniel Drake 2058c4cfe66cSDaniel Drake if (spec->dc_enable) /* don't do presence detection in DC mode */ 2059c4cfe66cSDaniel Drake return; 2060c4cfe66cSDaniel Drake 206175f8991dSDaniel Drake present = snd_hda_codec_read(codec, 0x1a, 0, 206275f8991dSDaniel Drake AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 206375f8991dSDaniel Drake if (present) 20640fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone detected\n"); 206575f8991dSDaniel Drake else 20660fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone absent\n"); 206775f8991dSDaniel Drake 206875f8991dSDaniel Drake snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 206975f8991dSDaniel Drake present ? 0 : 1); 207075f8991dSDaniel Drake spec->ext_mic_present = !!present; 207175f8991dSDaniel Drake 207275f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 20730fb67e98SDaniel Drake } 20740fb67e98SDaniel Drake 207595a618bdSEinar Rünkaru /* toggle input of built-in digital mic and mic jack appropriately */ 207695a618bdSEinar Rünkaru static void cxt5066_vostro_automic(struct hda_codec *codec) 207795a618bdSEinar Rünkaru { 207895a618bdSEinar Rünkaru unsigned int present; 207995a618bdSEinar Rünkaru 208095a618bdSEinar Rünkaru struct hda_verb ext_mic_present[] = { 208195a618bdSEinar Rünkaru /* enable external mic, port B */ 208275f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 208395a618bdSEinar Rünkaru 208495a618bdSEinar Rünkaru /* switch to external mic input */ 208595a618bdSEinar Rünkaru {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 208695a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 208795a618bdSEinar Rünkaru 208895a618bdSEinar Rünkaru /* disable internal digital mic */ 208995a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 209095a618bdSEinar Rünkaru {} 209195a618bdSEinar Rünkaru }; 209234cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 209395a618bdSEinar Rünkaru /* enable internal mic, port C */ 209495a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 209595a618bdSEinar Rünkaru 209695a618bdSEinar Rünkaru /* switch to internal mic input */ 209795a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 209895a618bdSEinar Rünkaru 209995a618bdSEinar Rünkaru /* disable external mic, port B */ 210095a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 210195a618bdSEinar Rünkaru {} 210295a618bdSEinar Rünkaru }; 210395a618bdSEinar Rünkaru 210495a618bdSEinar Rünkaru present = snd_hda_jack_detect(codec, 0x1a); 210595a618bdSEinar Rünkaru if (present) { 210695a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone detected\n"); 210795a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 210895a618bdSEinar Rünkaru } else { 210995a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone absent\n"); 211095a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_absent); 211195a618bdSEinar Rünkaru } 211295a618bdSEinar Rünkaru } 211395a618bdSEinar Rünkaru 2114cfd3d8dcSGreg Alexander /* toggle input of built-in digital mic and mic jack appropriately */ 2115cfd3d8dcSGreg Alexander static void cxt5066_ideapad_automic(struct hda_codec *codec) 2116cfd3d8dcSGreg Alexander { 2117cfd3d8dcSGreg Alexander unsigned int present; 2118cfd3d8dcSGreg Alexander 2119cfd3d8dcSGreg Alexander struct hda_verb ext_mic_present[] = { 2120cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 2121cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2122cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2123cfd3d8dcSGreg Alexander {} 2124cfd3d8dcSGreg Alexander }; 212534cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 2126cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 2127cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2128cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2129cfd3d8dcSGreg Alexander {} 2130cfd3d8dcSGreg Alexander }; 2131cfd3d8dcSGreg Alexander 2132cfd3d8dcSGreg Alexander present = snd_hda_jack_detect(codec, 0x1b); 2133cfd3d8dcSGreg Alexander if (present) { 2134cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone detected\n"); 2135cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2136cfd3d8dcSGreg Alexander } else { 2137cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone absent\n"); 2138cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_absent); 2139cfd3d8dcSGreg Alexander } 2140cfd3d8dcSGreg Alexander } 2141cfd3d8dcSGreg Alexander 2142a1d6906eSDavid Henningsson 2143a1d6906eSDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2144a1d6906eSDavid Henningsson static void cxt5066_asus_automic(struct hda_codec *codec) 2145a1d6906eSDavid Henningsson { 2146a1d6906eSDavid Henningsson unsigned int present; 2147a1d6906eSDavid Henningsson 2148a1d6906eSDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2149a1d6906eSDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2150a1d6906eSDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2151a1d6906eSDavid Henningsson present ? 1 : 0); 2152a1d6906eSDavid Henningsson } 2153a1d6906eSDavid Henningsson 2154a1d6906eSDavid Henningsson 2155048e78a5SDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2156048e78a5SDavid Henningsson static void cxt5066_hp_laptop_automic(struct hda_codec *codec) 2157048e78a5SDavid Henningsson { 2158048e78a5SDavid Henningsson unsigned int present; 2159048e78a5SDavid Henningsson 2160048e78a5SDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2161048e78a5SDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2162048e78a5SDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2163048e78a5SDavid Henningsson present ? 1 : 3); 2164048e78a5SDavid Henningsson } 2165048e78a5SDavid Henningsson 2166048e78a5SDavid Henningsson 21677b2bfdbcSJens Taprogge /* toggle input of built-in digital mic and mic jack appropriately 21687b2bfdbcSJens Taprogge order is: external mic -> dock mic -> interal mic */ 21697b2bfdbcSJens Taprogge static void cxt5066_thinkpad_automic(struct hda_codec *codec) 21707b2bfdbcSJens Taprogge { 21717b2bfdbcSJens Taprogge unsigned int ext_present, dock_present; 21727b2bfdbcSJens Taprogge 217334cbe3a6STakashi Iwai static const struct hda_verb ext_mic_present[] = { 21747b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21757b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 21767b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21777b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21787b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21797b2bfdbcSJens Taprogge {} 21807b2bfdbcSJens Taprogge }; 218134cbe3a6STakashi Iwai static const struct hda_verb dock_mic_present[] = { 21827b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21837b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 21847b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21857b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21867b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21877b2bfdbcSJens Taprogge {} 21887b2bfdbcSJens Taprogge }; 218934cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 21907b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 21917b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 21927b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21937b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21947b2bfdbcSJens Taprogge {} 21957b2bfdbcSJens Taprogge }; 21967b2bfdbcSJens Taprogge 21977b2bfdbcSJens Taprogge ext_present = snd_hda_jack_detect(codec, 0x1b); 21987b2bfdbcSJens Taprogge dock_present = snd_hda_jack_detect(codec, 0x1a); 21997b2bfdbcSJens Taprogge if (ext_present) { 22007b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone detected\n"); 22017b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 22027b2bfdbcSJens Taprogge } else if (dock_present) { 22037b2bfdbcSJens Taprogge snd_printdd("CXT5066: dock microphone detected\n"); 22047b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 22057b2bfdbcSJens Taprogge } else { 22067b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone absent\n"); 22077b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_absent); 22087b2bfdbcSJens Taprogge } 22097b2bfdbcSJens Taprogge } 22107b2bfdbcSJens Taprogge 22110fb67e98SDaniel Drake /* mute internal speaker if HP is plugged */ 22120fb67e98SDaniel Drake static void cxt5066_hp_automute(struct hda_codec *codec) 22130fb67e98SDaniel Drake { 22140fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 22150fb67e98SDaniel Drake unsigned int portA, portD; 22160fb67e98SDaniel Drake 22170fb67e98SDaniel Drake /* Port A */ 2218d56757abSTakashi Iwai portA = snd_hda_jack_detect(codec, 0x19); 22190fb67e98SDaniel Drake 22200fb67e98SDaniel Drake /* Port D */ 2221d56757abSTakashi Iwai portD = snd_hda_jack_detect(codec, 0x1c); 22220fb67e98SDaniel Drake 2223a3de8ab8STakashi Iwai spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2224a3de8ab8STakashi Iwai spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 22250fb67e98SDaniel Drake snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 22260fb67e98SDaniel Drake portA, portD, spec->hp_present); 22270fb67e98SDaniel Drake cxt5066_update_speaker(codec); 22280fb67e98SDaniel Drake } 22290fb67e98SDaniel Drake 223002b6b5b6SDavid Henningsson /* Dispatch the right mic autoswitch function */ 223102b6b5b6SDavid Henningsson static void cxt5066_automic(struct hda_codec *codec) 223202b6b5b6SDavid Henningsson { 223302b6b5b6SDavid Henningsson struct conexant_spec *spec = codec->spec; 223402b6b5b6SDavid Henningsson 223502b6b5b6SDavid Henningsson if (spec->dell_vostro) 223602b6b5b6SDavid Henningsson cxt5066_vostro_automic(codec); 223702b6b5b6SDavid Henningsson else if (spec->ideapad) 223802b6b5b6SDavid Henningsson cxt5066_ideapad_automic(codec); 223902b6b5b6SDavid Henningsson else if (spec->thinkpad) 224002b6b5b6SDavid Henningsson cxt5066_thinkpad_automic(codec); 224102b6b5b6SDavid Henningsson else if (spec->hp_laptop) 224202b6b5b6SDavid Henningsson cxt5066_hp_laptop_automic(codec); 2243a1d6906eSDavid Henningsson else if (spec->asus) 2244a1d6906eSDavid Henningsson cxt5066_asus_automic(codec); 224502b6b5b6SDavid Henningsson } 224602b6b5b6SDavid Henningsson 22470fb67e98SDaniel Drake /* unsolicited event for jack sensing */ 224875f8991dSDaniel Drake static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 22490fb67e98SDaniel Drake { 2250c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 22510fb67e98SDaniel Drake snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 22520fb67e98SDaniel Drake switch (res >> 26) { 22530fb67e98SDaniel Drake case CONEXANT_HP_EVENT: 22540fb67e98SDaniel Drake cxt5066_hp_automute(codec); 22550fb67e98SDaniel Drake break; 22560fb67e98SDaniel Drake case CONEXANT_MIC_EVENT: 2257c4cfe66cSDaniel Drake /* ignore mic events in DC mode; we're always using the jack */ 2258c4cfe66cSDaniel Drake if (!spec->dc_enable) 225975f8991dSDaniel Drake cxt5066_olpc_automic(codec); 22600fb67e98SDaniel Drake break; 22610fb67e98SDaniel Drake } 22620fb67e98SDaniel Drake } 22630fb67e98SDaniel Drake 226495a618bdSEinar Rünkaru /* unsolicited event for jack sensing */ 226502b6b5b6SDavid Henningsson static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 226695a618bdSEinar Rünkaru { 226702b6b5b6SDavid Henningsson snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 226895a618bdSEinar Rünkaru switch (res >> 26) { 226995a618bdSEinar Rünkaru case CONEXANT_HP_EVENT: 227095a618bdSEinar Rünkaru cxt5066_hp_automute(codec); 227195a618bdSEinar Rünkaru break; 227295a618bdSEinar Rünkaru case CONEXANT_MIC_EVENT: 227302b6b5b6SDavid Henningsson cxt5066_automic(codec); 227495a618bdSEinar Rünkaru break; 227595a618bdSEinar Rünkaru } 227695a618bdSEinar Rünkaru } 227795a618bdSEinar Rünkaru 22787b2bfdbcSJens Taprogge 22790fb67e98SDaniel Drake static const struct hda_input_mux cxt5066_analog_mic_boost = { 22800fb67e98SDaniel Drake .num_items = 5, 22810fb67e98SDaniel Drake .items = { 22820fb67e98SDaniel Drake { "0dB", 0 }, 22830fb67e98SDaniel Drake { "10dB", 1 }, 22840fb67e98SDaniel Drake { "20dB", 2 }, 22850fb67e98SDaniel Drake { "30dB", 3 }, 22860fb67e98SDaniel Drake { "40dB", 4 }, 22870fb67e98SDaniel Drake }, 22880fb67e98SDaniel Drake }; 22890fb67e98SDaniel Drake 2290cfd3d8dcSGreg Alexander static void cxt5066_set_mic_boost(struct hda_codec *codec) 2291c4cfe66cSDaniel Drake { 2292c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2293cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x17, 0, 2294c4cfe66cSDaniel Drake AC_VERB_SET_AMP_GAIN_MUTE, 2295c4cfe66cSDaniel Drake AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2296c4cfe66cSDaniel Drake cxt5066_analog_mic_boost.items[spec->mic_boost].index); 22977b2bfdbcSJens Taprogge if (spec->ideapad || spec->thinkpad) { 2298cfd3d8dcSGreg Alexander /* adjust the internal mic as well...it is not through 0x17 */ 2299cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x23, 0, 2300cfd3d8dcSGreg Alexander AC_VERB_SET_AMP_GAIN_MUTE, 2301cfd3d8dcSGreg Alexander AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | 2302cfd3d8dcSGreg Alexander cxt5066_analog_mic_boost. 2303cfd3d8dcSGreg Alexander items[spec->mic_boost].index); 2304cfd3d8dcSGreg Alexander } 2305c4cfe66cSDaniel Drake } 2306c4cfe66cSDaniel Drake 23070fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 23080fb67e98SDaniel Drake struct snd_ctl_elem_info *uinfo) 23090fb67e98SDaniel Drake { 23100fb67e98SDaniel Drake return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); 23110fb67e98SDaniel Drake } 23120fb67e98SDaniel Drake 23130fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, 23140fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23150fb67e98SDaniel Drake { 23160fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2317c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2318c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->mic_boost; 23190fb67e98SDaniel Drake return 0; 23200fb67e98SDaniel Drake } 23210fb67e98SDaniel Drake 23220fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, 23230fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23240fb67e98SDaniel Drake { 23250fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2326c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 23270fb67e98SDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 23280fb67e98SDaniel Drake unsigned int idx; 23290fb67e98SDaniel Drake idx = ucontrol->value.enumerated.item[0]; 23300fb67e98SDaniel Drake if (idx >= imux->num_items) 23310fb67e98SDaniel Drake idx = imux->num_items - 1; 23320fb67e98SDaniel Drake 2333c4cfe66cSDaniel Drake spec->mic_boost = idx; 2334c4cfe66cSDaniel Drake if (!spec->dc_enable) 2335c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2336c4cfe66cSDaniel Drake return 1; 2337c4cfe66cSDaniel Drake } 23380fb67e98SDaniel Drake 2339c4cfe66cSDaniel Drake static void cxt5066_enable_dc(struct hda_codec *codec) 2340c4cfe66cSDaniel Drake { 2341c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2342c4cfe66cSDaniel Drake /* disable gain */ 2343c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2344c4cfe66cSDaniel Drake 2345c4cfe66cSDaniel Drake /* switch to DC input */ 2346c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_CONNECT_SEL, 3}, 2347c4cfe66cSDaniel Drake {} 2348c4cfe66cSDaniel Drake }; 2349c4cfe66cSDaniel Drake 2350c4cfe66cSDaniel Drake /* configure as input source */ 2351c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2352c4cfe66cSDaniel Drake cxt5066_olpc_select_mic(codec); /* also sets configured bias */ 2353c4cfe66cSDaniel Drake } 2354c4cfe66cSDaniel Drake 2355c4cfe66cSDaniel Drake static void cxt5066_disable_dc(struct hda_codec *codec) 2356c4cfe66cSDaniel Drake { 2357c4cfe66cSDaniel Drake /* reconfigure input source */ 2358c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2359c4cfe66cSDaniel Drake /* automic also selects the right mic if we're recording */ 2360c4cfe66cSDaniel Drake cxt5066_olpc_automic(codec); 2361c4cfe66cSDaniel Drake } 2362c4cfe66cSDaniel Drake 2363c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, 2364c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2365c4cfe66cSDaniel Drake { 2366c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2367c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2368c4cfe66cSDaniel Drake ucontrol->value.integer.value[0] = spec->dc_enable; 2369c4cfe66cSDaniel Drake return 0; 2370c4cfe66cSDaniel Drake } 2371c4cfe66cSDaniel Drake 2372c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, 2373c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2374c4cfe66cSDaniel Drake { 2375c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2376c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2377c4cfe66cSDaniel Drake int dc_enable = !!ucontrol->value.integer.value[0]; 2378c4cfe66cSDaniel Drake 2379c4cfe66cSDaniel Drake if (dc_enable == spec->dc_enable) 2380c4cfe66cSDaniel Drake return 0; 2381c4cfe66cSDaniel Drake 2382c4cfe66cSDaniel Drake spec->dc_enable = dc_enable; 2383c4cfe66cSDaniel Drake if (dc_enable) 2384c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2385c4cfe66cSDaniel Drake else 2386c4cfe66cSDaniel Drake cxt5066_disable_dc(codec); 2387c4cfe66cSDaniel Drake 2388c4cfe66cSDaniel Drake return 1; 2389c4cfe66cSDaniel Drake } 2390c4cfe66cSDaniel Drake 2391c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 2392c4cfe66cSDaniel Drake struct snd_ctl_elem_info *uinfo) 2393c4cfe66cSDaniel Drake { 2394c4cfe66cSDaniel Drake return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); 2395c4cfe66cSDaniel Drake } 2396c4cfe66cSDaniel Drake 2397c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 2398c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2399c4cfe66cSDaniel Drake { 2400c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2401c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2402c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 2403c4cfe66cSDaniel Drake return 0; 2404c4cfe66cSDaniel Drake } 2405c4cfe66cSDaniel Drake 2406c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 2407c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2408c4cfe66cSDaniel Drake { 2409c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2410c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2411c4cfe66cSDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2412c4cfe66cSDaniel Drake unsigned int idx; 2413c4cfe66cSDaniel Drake 2414c4cfe66cSDaniel Drake idx = ucontrol->value.enumerated.item[0]; 2415c4cfe66cSDaniel Drake if (idx >= imux->num_items) 2416c4cfe66cSDaniel Drake idx = imux->num_items - 1; 2417c4cfe66cSDaniel Drake 2418c4cfe66cSDaniel Drake spec->dc_input_bias = idx; 2419c4cfe66cSDaniel Drake if (spec->dc_enable) 2420c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 24210fb67e98SDaniel Drake return 1; 24220fb67e98SDaniel Drake } 24230fb67e98SDaniel Drake 242475f8991dSDaniel Drake static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) 242575f8991dSDaniel Drake { 242675f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 242775f8991dSDaniel Drake /* mark as recording and configure the microphone widget so that the 242875f8991dSDaniel Drake * recording LED comes on. */ 242975f8991dSDaniel Drake spec->recording = 1; 243075f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 243175f8991dSDaniel Drake } 243275f8991dSDaniel Drake 243375f8991dSDaniel Drake static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) 243475f8991dSDaniel Drake { 243575f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 243675f8991dSDaniel Drake const struct hda_verb disable_mics[] = { 243775f8991dSDaniel Drake /* disable external mic, port B */ 243875f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 243975f8991dSDaniel Drake 244075f8991dSDaniel Drake /* disble internal mic, port C */ 244175f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2442c4cfe66cSDaniel Drake 2443c4cfe66cSDaniel Drake /* disable DC capture, port F */ 2444c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 244575f8991dSDaniel Drake {}, 244675f8991dSDaniel Drake }; 244775f8991dSDaniel Drake 244875f8991dSDaniel Drake snd_hda_sequence_write(codec, disable_mics); 244975f8991dSDaniel Drake spec->recording = 0; 245075f8991dSDaniel Drake } 245175f8991dSDaniel Drake 2452f6a2491cSAndy Robinson static void conexant_check_dig_outs(struct hda_codec *codec, 245334cbe3a6STakashi Iwai const hda_nid_t *dig_pins, 2454f6a2491cSAndy Robinson int num_pins) 2455f6a2491cSAndy Robinson { 2456f6a2491cSAndy Robinson struct conexant_spec *spec = codec->spec; 2457f6a2491cSAndy Robinson hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; 2458f6a2491cSAndy Robinson int i; 2459f6a2491cSAndy Robinson 2460f6a2491cSAndy Robinson for (i = 0; i < num_pins; i++, dig_pins++) { 2461f6a2491cSAndy Robinson unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); 2462f6a2491cSAndy Robinson if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) 2463f6a2491cSAndy Robinson continue; 2464f6a2491cSAndy Robinson if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) 2465f6a2491cSAndy Robinson continue; 2466f6a2491cSAndy Robinson } 2467f6a2491cSAndy Robinson } 2468f6a2491cSAndy Robinson 246934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5066_capture_source = { 24700fb67e98SDaniel Drake .num_items = 4, 24710fb67e98SDaniel Drake .items = { 24720fb67e98SDaniel Drake { "Mic B", 0 }, 24730fb67e98SDaniel Drake { "Mic C", 1 }, 24740fb67e98SDaniel Drake { "Mic E", 2 }, 24750fb67e98SDaniel Drake { "Mic F", 3 }, 24760fb67e98SDaniel Drake }, 24770fb67e98SDaniel Drake }; 24780fb67e98SDaniel Drake 247934cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { 24800fb67e98SDaniel Drake .ops = &snd_hda_bind_vol, 24810fb67e98SDaniel Drake .values = { 24820fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24830fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24840fb67e98SDaniel Drake 0 24850fb67e98SDaniel Drake }, 24860fb67e98SDaniel Drake }; 24870fb67e98SDaniel Drake 248834cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { 24890fb67e98SDaniel Drake .ops = &snd_hda_bind_sw, 24900fb67e98SDaniel Drake .values = { 24910fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24920fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24930fb67e98SDaniel Drake 0 24940fb67e98SDaniel Drake }, 24950fb67e98SDaniel Drake }; 24960fb67e98SDaniel Drake 249734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master[] = { 24980fb67e98SDaniel Drake HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 24990fb67e98SDaniel Drake {} 25000fb67e98SDaniel Drake }; 25010fb67e98SDaniel Drake 250234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { 25030fb67e98SDaniel Drake { 25040fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25050fb67e98SDaniel Drake .name = "Master Playback Volume", 25060fb67e98SDaniel Drake .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 25070fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_READ | 25080fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, 25095e26dfd0SJaroslav Kysela .subdevice = HDA_SUBDEV_AMP_FLAG, 25100fb67e98SDaniel Drake .info = snd_hda_mixer_amp_volume_info, 25110fb67e98SDaniel Drake .get = snd_hda_mixer_amp_volume_get, 25120fb67e98SDaniel Drake .put = snd_hda_mixer_amp_volume_put, 25130fb67e98SDaniel Drake .tlv = { .c = snd_hda_mixer_amp_tlv }, 25140fb67e98SDaniel Drake /* offset by 28 volume steps to limit minimum gain to -46dB */ 25150fb67e98SDaniel Drake .private_value = 25160fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), 25170fb67e98SDaniel Drake }, 25180fb67e98SDaniel Drake {} 25190fb67e98SDaniel Drake }; 25200fb67e98SDaniel Drake 252134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { 2522c4cfe66cSDaniel Drake { 2523c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2524c4cfe66cSDaniel Drake .name = "DC Mode Enable Switch", 2525c4cfe66cSDaniel Drake .info = snd_ctl_boolean_mono_info, 2526c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_get, 2527c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_put, 2528c4cfe66cSDaniel Drake }, 2529c4cfe66cSDaniel Drake { 2530c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2531c4cfe66cSDaniel Drake .name = "DC Input Bias Enum", 2532c4cfe66cSDaniel Drake .info = cxt5066_olpc_dc_bias_enum_info, 2533c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_bias_enum_get, 2534c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_bias_enum_put, 2535c4cfe66cSDaniel Drake }, 2536c4cfe66cSDaniel Drake {} 2537c4cfe66cSDaniel Drake }; 2538c4cfe66cSDaniel Drake 253934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixers[] = { 25400fb67e98SDaniel Drake { 25410fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25420fb67e98SDaniel Drake .name = "Master Playback Switch", 25430fb67e98SDaniel Drake .info = cxt_eapd_info, 25440fb67e98SDaniel Drake .get = cxt_eapd_get, 25450fb67e98SDaniel Drake .put = cxt5066_hp_master_sw_put, 25460fb67e98SDaniel Drake .private_value = 0x1d, 25470fb67e98SDaniel Drake }, 25480fb67e98SDaniel Drake 25490fb67e98SDaniel Drake { 25500fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2551c4cfe66cSDaniel Drake .name = "Analog Mic Boost Capture Enum", 25520fb67e98SDaniel Drake .info = cxt5066_mic_boost_mux_enum_info, 25530fb67e98SDaniel Drake .get = cxt5066_mic_boost_mux_enum_get, 25540fb67e98SDaniel Drake .put = cxt5066_mic_boost_mux_enum_put, 25550fb67e98SDaniel Drake }, 25560fb67e98SDaniel Drake 25570fb67e98SDaniel Drake HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), 25580fb67e98SDaniel Drake HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), 25590fb67e98SDaniel Drake {} 25600fb67e98SDaniel Drake }; 25610fb67e98SDaniel Drake 256234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { 2563254bba6aSEinar Rünkaru { 2564254bba6aSEinar Rünkaru .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 256528c4edb7SDavid Henningsson .name = "Internal Mic Boost Capture Enum", 2566254bba6aSEinar Rünkaru .info = cxt5066_mic_boost_mux_enum_info, 2567254bba6aSEinar Rünkaru .get = cxt5066_mic_boost_mux_enum_get, 2568254bba6aSEinar Rünkaru .put = cxt5066_mic_boost_mux_enum_put, 2569254bba6aSEinar Rünkaru .private_value = 0x23 | 0x100, 2570254bba6aSEinar Rünkaru }, 2571254bba6aSEinar Rünkaru {} 2572254bba6aSEinar Rünkaru }; 2573254bba6aSEinar Rünkaru 257434cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs[] = { 25750fb67e98SDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 25760fb67e98SDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 25770fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 25780fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 25790fb67e98SDaniel Drake 25800fb67e98SDaniel Drake /* Speakers */ 25810fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 25820fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25830fb67e98SDaniel Drake 25840fb67e98SDaniel Drake /* HP, Amp */ 25850fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25860fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25870fb67e98SDaniel Drake 25880fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25890fb67e98SDaniel Drake {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25900fb67e98SDaniel Drake 25910fb67e98SDaniel Drake /* DAC1 */ 25920fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 25930fb67e98SDaniel Drake 25940fb67e98SDaniel Drake /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 25950fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 25960fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 25970fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 25980fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 25990fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 26000fb67e98SDaniel Drake 26010fb67e98SDaniel Drake /* no digital microphone support yet */ 26020fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26030fb67e98SDaniel Drake 26040fb67e98SDaniel Drake /* Audio input selector */ 26050fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26060fb67e98SDaniel Drake 26070fb67e98SDaniel Drake /* SPDIF route: PCM */ 26080fb67e98SDaniel Drake {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 26090fb67e98SDaniel Drake {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 26100fb67e98SDaniel Drake 26110fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26120fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26130fb67e98SDaniel Drake 26140fb67e98SDaniel Drake /* EAPD */ 26150fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26160fb67e98SDaniel Drake 26170fb67e98SDaniel Drake /* not handling these yet */ 26180fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26190fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26200fb67e98SDaniel Drake {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26210fb67e98SDaniel Drake {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26220fb67e98SDaniel Drake {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26230fb67e98SDaniel Drake {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26240fb67e98SDaniel Drake {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26250fb67e98SDaniel Drake {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26260fb67e98SDaniel Drake { } /* end */ 26270fb67e98SDaniel Drake }; 26280fb67e98SDaniel Drake 262934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_olpc[] = { 26300fb67e98SDaniel Drake /* Port A: headphones */ 26310fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 26320fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26330fb67e98SDaniel Drake 26340fb67e98SDaniel Drake /* Port B: external microphone */ 263575f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26360fb67e98SDaniel Drake 26370fb67e98SDaniel Drake /* Port C: internal microphone */ 263875f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26390fb67e98SDaniel Drake 26400fb67e98SDaniel Drake /* Port D: unused */ 26410fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26420fb67e98SDaniel Drake 26430fb67e98SDaniel Drake /* Port E: unused, but has primary EAPD */ 26440fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26450fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26460fb67e98SDaniel Drake 2647c4cfe66cSDaniel Drake /* Port F: external DC input through microphone port */ 26480fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26490fb67e98SDaniel Drake 26500fb67e98SDaniel Drake /* Port G: internal speakers */ 26510fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26520fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26530fb67e98SDaniel Drake 26540fb67e98SDaniel Drake /* DAC1 */ 26550fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 26560fb67e98SDaniel Drake 26570fb67e98SDaniel Drake /* DAC2: unused */ 26580fb67e98SDaniel Drake {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 26590fb67e98SDaniel Drake 26600fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26610fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26620fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26630fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26640fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26650fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26660fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26670fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26680fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26690fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26700fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26710fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26720fb67e98SDaniel Drake 26730fb67e98SDaniel Drake /* Disable digital microphone port */ 26740fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26750fb67e98SDaniel Drake 26760fb67e98SDaniel Drake /* Audio input selectors */ 26770fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26780fb67e98SDaniel Drake {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 26790fb67e98SDaniel Drake 26800fb67e98SDaniel Drake /* Disable SPDIF */ 26810fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26820fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26830fb67e98SDaniel Drake 26840fb67e98SDaniel Drake /* enable unsolicited events for Port A and B */ 26850fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 26860fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 26870fb67e98SDaniel Drake { } /* end */ 26880fb67e98SDaniel Drake }; 26890fb67e98SDaniel Drake 269034cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_vostro[] = { 269195a618bdSEinar Rünkaru /* Port A: headphones */ 269295a618bdSEinar Rünkaru {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 269395a618bdSEinar Rünkaru {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 269495a618bdSEinar Rünkaru 269595a618bdSEinar Rünkaru /* Port B: external microphone */ 269695a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 269795a618bdSEinar Rünkaru 269895a618bdSEinar Rünkaru /* Port C: unused */ 269995a618bdSEinar Rünkaru {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270095a618bdSEinar Rünkaru 270195a618bdSEinar Rünkaru /* Port D: unused */ 270295a618bdSEinar Rünkaru {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270395a618bdSEinar Rünkaru 270495a618bdSEinar Rünkaru /* Port E: unused, but has primary EAPD */ 270595a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270695a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 270795a618bdSEinar Rünkaru 270895a618bdSEinar Rünkaru /* Port F: unused */ 270995a618bdSEinar Rünkaru {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271095a618bdSEinar Rünkaru 271195a618bdSEinar Rünkaru /* Port G: internal speakers */ 271295a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 271395a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 271495a618bdSEinar Rünkaru 271595a618bdSEinar Rünkaru /* DAC1 */ 271695a618bdSEinar Rünkaru {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 271795a618bdSEinar Rünkaru 271895a618bdSEinar Rünkaru /* DAC2: unused */ 271995a618bdSEinar Rünkaru {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 272095a618bdSEinar Rünkaru 272195a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 272295a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 272395a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 272495a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 272595a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 272695a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 272795a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 272895a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 272995a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273095a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273195a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273295a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273395a618bdSEinar Rünkaru 273495a618bdSEinar Rünkaru /* Digital microphone port */ 273595a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 273695a618bdSEinar Rünkaru 273795a618bdSEinar Rünkaru /* Audio input selectors */ 273895a618bdSEinar Rünkaru {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 273995a618bdSEinar Rünkaru {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 274095a618bdSEinar Rünkaru 274195a618bdSEinar Rünkaru /* Disable SPDIF */ 274295a618bdSEinar Rünkaru {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274395a618bdSEinar Rünkaru {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274495a618bdSEinar Rünkaru 274595a618bdSEinar Rünkaru /* enable unsolicited events for Port A and B */ 274695a618bdSEinar Rünkaru {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 274795a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 274895a618bdSEinar Rünkaru { } /* end */ 274995a618bdSEinar Rünkaru }; 275095a618bdSEinar Rünkaru 275134cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_ideapad[] = { 2752cfd3d8dcSGreg Alexander {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 2753cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 2754cfd3d8dcSGreg Alexander {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 2755cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 2756cfd3d8dcSGreg Alexander 2757cfd3d8dcSGreg Alexander /* Speakers */ 2758cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2759cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2760cfd3d8dcSGreg Alexander 2761cfd3d8dcSGreg Alexander /* HP, Amp */ 2762cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2763cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2764cfd3d8dcSGreg Alexander 2765cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2766cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2767cfd3d8dcSGreg Alexander 2768cfd3d8dcSGreg Alexander /* DAC1 */ 2769cfd3d8dcSGreg Alexander {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2770cfd3d8dcSGreg Alexander 2771cfd3d8dcSGreg Alexander /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 2772cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 2773cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2774cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 2775cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2776cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2777cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 2778cfd3d8dcSGreg Alexander 2779cfd3d8dcSGreg Alexander /* Audio input selector */ 2780cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 2781cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 2782cfd3d8dcSGreg Alexander 2783cfd3d8dcSGreg Alexander /* SPDIF route: PCM */ 2784cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 2785cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 2786cfd3d8dcSGreg Alexander 2787cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2788cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2789cfd3d8dcSGreg Alexander 2790cfd3d8dcSGreg Alexander /* internal microphone */ 279128c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 2792cfd3d8dcSGreg Alexander 2793cfd3d8dcSGreg Alexander /* EAPD */ 2794cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2795cfd3d8dcSGreg Alexander 2796cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2797cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2798cfd3d8dcSGreg Alexander { } /* end */ 2799cfd3d8dcSGreg Alexander }; 2800cfd3d8dcSGreg Alexander 280134cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { 28027b2bfdbcSJens Taprogge {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 28037b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 28047b2bfdbcSJens Taprogge 28057b2bfdbcSJens Taprogge /* Port G: internal speakers */ 28067b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28077b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28087b2bfdbcSJens Taprogge 28097b2bfdbcSJens Taprogge /* Port A: HP, Amp */ 28107b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28117b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28127b2bfdbcSJens Taprogge 28137b2bfdbcSJens Taprogge /* Port B: Mic Dock */ 28147b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28157b2bfdbcSJens Taprogge 28167b2bfdbcSJens Taprogge /* Port C: Mic */ 28177b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28187b2bfdbcSJens Taprogge 28197b2bfdbcSJens Taprogge /* Port D: HP Dock, Amp */ 28207b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28217b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28227b2bfdbcSJens Taprogge 28237b2bfdbcSJens Taprogge /* DAC1 */ 28247b2bfdbcSJens Taprogge {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 28257b2bfdbcSJens Taprogge 28267b2bfdbcSJens Taprogge /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 28277b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 28287b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 28297b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 28307b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 28317b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 28327b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 28337b2bfdbcSJens Taprogge 28347b2bfdbcSJens Taprogge /* Audio input selector */ 28357b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 28367b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 28377b2bfdbcSJens Taprogge 28387b2bfdbcSJens Taprogge /* SPDIF route: PCM */ 28397b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 28407b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 28417b2bfdbcSJens Taprogge 28427b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28437b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28447b2bfdbcSJens Taprogge 28457b2bfdbcSJens Taprogge /* internal microphone */ 284628c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 28477b2bfdbcSJens Taprogge 28487b2bfdbcSJens Taprogge /* EAPD */ 28497b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 28507b2bfdbcSJens Taprogge 28517b2bfdbcSJens Taprogge /* enable unsolicited events for Port A, B, C and D */ 28527b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28537b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28547b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28557b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28567b2bfdbcSJens Taprogge { } /* end */ 28577b2bfdbcSJens Taprogge }; 28587b2bfdbcSJens Taprogge 285934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { 28600fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28610fb67e98SDaniel Drake { } /* end */ 28620fb67e98SDaniel Drake }; 28630fb67e98SDaniel Drake 2864048e78a5SDavid Henningsson 286534cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { 2866048e78a5SDavid Henningsson {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, 2867048e78a5SDavid Henningsson {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2868048e78a5SDavid Henningsson {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2869048e78a5SDavid Henningsson { } /* end */ 2870048e78a5SDavid Henningsson }; 2871048e78a5SDavid Henningsson 28720fb67e98SDaniel Drake /* initialize jack-sensing, too */ 28730fb67e98SDaniel Drake static int cxt5066_init(struct hda_codec *codec) 28740fb67e98SDaniel Drake { 28750fb67e98SDaniel Drake snd_printdd("CXT5066: init\n"); 28760fb67e98SDaniel Drake conexant_init(codec); 28770fb67e98SDaniel Drake if (codec->patch_ops.unsol_event) { 28780fb67e98SDaniel Drake cxt5066_hp_automute(codec); 287902b6b5b6SDavid Henningsson cxt5066_automic(codec); 28800fb67e98SDaniel Drake } 2881c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 28820fb67e98SDaniel Drake return 0; 28830fb67e98SDaniel Drake } 28840fb67e98SDaniel Drake 288575f8991dSDaniel Drake static int cxt5066_olpc_init(struct hda_codec *codec) 288675f8991dSDaniel Drake { 2887c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 288875f8991dSDaniel Drake snd_printdd("CXT5066: init\n"); 288975f8991dSDaniel Drake conexant_init(codec); 289075f8991dSDaniel Drake cxt5066_hp_automute(codec); 2891c4cfe66cSDaniel Drake if (!spec->dc_enable) { 2892c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 289375f8991dSDaniel Drake cxt5066_olpc_automic(codec); 2894c4cfe66cSDaniel Drake } else { 2895c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2896c4cfe66cSDaniel Drake } 289775f8991dSDaniel Drake return 0; 289875f8991dSDaniel Drake } 289975f8991dSDaniel Drake 29000fb67e98SDaniel Drake enum { 29010fb67e98SDaniel Drake CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 29020fb67e98SDaniel Drake CXT5066_DELL_LAPTOP, /* Dell Laptop */ 29030fb67e98SDaniel Drake CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ 29041feba3b7SDavid Henningsson CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2905cfd3d8dcSGreg Alexander CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 29067b2bfdbcSJens Taprogge CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2907a1d6906eSDavid Henningsson CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ 2908048e78a5SDavid Henningsson CXT5066_HP_LAPTOP, /* HP Laptop */ 2909fea4a4f9STakashi Iwai CXT5066_AUTO, /* BIOS auto-parser */ 29100fb67e98SDaniel Drake CXT5066_MODELS 29110fb67e98SDaniel Drake }; 29120fb67e98SDaniel Drake 2913ea734963STakashi Iwai static const char * const cxt5066_models[CXT5066_MODELS] = { 29140fb67e98SDaniel Drake [CXT5066_LAPTOP] = "laptop", 29150fb67e98SDaniel Drake [CXT5066_DELL_LAPTOP] = "dell-laptop", 29160fb67e98SDaniel Drake [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", 29171feba3b7SDavid Henningsson [CXT5066_DELL_VOSTRO] = "dell-vostro", 2918cfd3d8dcSGreg Alexander [CXT5066_IDEAPAD] = "ideapad", 29197b2bfdbcSJens Taprogge [CXT5066_THINKPAD] = "thinkpad", 2920a1d6906eSDavid Henningsson [CXT5066_ASUS] = "asus", 2921048e78a5SDavid Henningsson [CXT5066_HP_LAPTOP] = "hp-laptop", 2922fea4a4f9STakashi Iwai [CXT5066_AUTO] = "auto", 29230fb67e98SDaniel Drake }; 29240fb67e98SDaniel Drake 292534cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { 292600cd0bb7STakashi Iwai SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 29271feba3b7SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 29288a96b1e0SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), 2929ca6cd851SDaniel T Chen SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2930231f50bcSAnisse Astier SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2931ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2932ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), 2933048e78a5SDavid Henningsson SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2934f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2935a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2936f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 29372ca9cac9SAnisse Astier SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 2938c5366681SDaniel T Chen SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 29395637edb2SDavid Henningsson SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 29405637edb2SDavid Henningsson CXT5066_LAPTOP), 29415637edb2SDavid Henningsson SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 29424d155641STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2943ef61d4e6SManoj Iyer SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 294419593875SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 294584012657SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD), 2946b2cb1292SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), 2947d2859fd4SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), 2948a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), 29490fb67e98SDaniel Drake {} 29500fb67e98SDaniel Drake }; 29510fb67e98SDaniel Drake 29520fb67e98SDaniel Drake static int patch_cxt5066(struct hda_codec *codec) 29530fb67e98SDaniel Drake { 29540fb67e98SDaniel Drake struct conexant_spec *spec; 29550fb67e98SDaniel Drake int board_config; 29560fb67e98SDaniel Drake 2957fea4a4f9STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, 2958fea4a4f9STakashi Iwai cxt5066_models, cxt5066_cfg_tbl); 2959fea4a4f9STakashi Iwai if (board_config < 0) 2960c82693dbSTakashi Iwai board_config = CXT5066_AUTO; /* model=auto as default */ 2961fea4a4f9STakashi Iwai if (board_config == CXT5066_AUTO) 2962fea4a4f9STakashi Iwai return patch_conexant_auto(codec); 2963fea4a4f9STakashi Iwai 29640fb67e98SDaniel Drake spec = kzalloc(sizeof(*spec), GFP_KERNEL); 29650fb67e98SDaniel Drake if (!spec) 29660fb67e98SDaniel Drake return -ENOMEM; 29670fb67e98SDaniel Drake codec->spec = spec; 29680fb67e98SDaniel Drake 29690fb67e98SDaniel Drake codec->patch_ops = conexant_patch_ops; 297075f8991dSDaniel Drake codec->patch_ops.init = conexant_init; 29710fb67e98SDaniel Drake 29720fb67e98SDaniel Drake spec->dell_automute = 0; 29730fb67e98SDaniel Drake spec->multiout.max_channels = 2; 29740fb67e98SDaniel Drake spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); 29750fb67e98SDaniel Drake spec->multiout.dac_nids = cxt5066_dac_nids; 2976f6a2491cSAndy Robinson conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, 2977f6a2491cSAndy Robinson ARRAY_SIZE(cxt5066_digout_pin_nids)); 29780fb67e98SDaniel Drake spec->num_adc_nids = 1; 29790fb67e98SDaniel Drake spec->adc_nids = cxt5066_adc_nids; 29800fb67e98SDaniel Drake spec->capsrc_nids = cxt5066_capsrc_nids; 29810fb67e98SDaniel Drake spec->input_mux = &cxt5066_capture_source; 29820fb67e98SDaniel Drake 29830fb67e98SDaniel Drake spec->port_d_mode = PIN_HP; 29840fb67e98SDaniel Drake 29850fb67e98SDaniel Drake spec->num_init_verbs = 1; 29860fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs; 29870fb67e98SDaniel Drake spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); 29880fb67e98SDaniel Drake spec->channel_mode = cxt5066_modes; 29890fb67e98SDaniel Drake spec->cur_adc = 0; 29900fb67e98SDaniel Drake spec->cur_adc_idx = 0; 29910fb67e98SDaniel Drake 29923507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 29933507e2a8STakashi Iwai 29940fb67e98SDaniel Drake switch (board_config) { 29950fb67e98SDaniel Drake default: 29960fb67e98SDaniel Drake case CXT5066_LAPTOP: 29970fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 29980fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 29990fb67e98SDaniel Drake break; 30000fb67e98SDaniel Drake case CXT5066_DELL_LAPTOP: 30010fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30020fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30030fb67e98SDaniel Drake 30040fb67e98SDaniel Drake spec->port_d_mode = PIN_OUT; 30050fb67e98SDaniel Drake spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; 30060fb67e98SDaniel Drake spec->num_init_verbs++; 30070fb67e98SDaniel Drake spec->dell_automute = 1; 30080fb67e98SDaniel Drake break; 3009a1d6906eSDavid Henningsson case CXT5066_ASUS: 3010048e78a5SDavid Henningsson case CXT5066_HP_LAPTOP: 3011048e78a5SDavid Henningsson codec->patch_ops.init = cxt5066_init; 301202b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3013048e78a5SDavid Henningsson spec->init_verbs[spec->num_init_verbs] = 3014048e78a5SDavid Henningsson cxt5066_init_verbs_hp_laptop; 3015048e78a5SDavid Henningsson spec->num_init_verbs++; 3016a1d6906eSDavid Henningsson spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; 3017a1d6906eSDavid Henningsson spec->asus = board_config == CXT5066_ASUS; 3018048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3019048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3020048e78a5SDavid Henningsson /* no S/PDIF out */ 3021f6a2491cSAndy Robinson if (board_config == CXT5066_HP_LAPTOP) 3022048e78a5SDavid Henningsson spec->multiout.dig_out_nid = 0; 3023048e78a5SDavid Henningsson /* input source automatically selected */ 3024048e78a5SDavid Henningsson spec->input_mux = NULL; 3025048e78a5SDavid Henningsson spec->port_d_mode = 0; 3026048e78a5SDavid Henningsson spec->mic_boost = 3; /* default 30dB gain */ 3027048e78a5SDavid Henningsson break; 3028048e78a5SDavid Henningsson 30290fb67e98SDaniel Drake case CXT5066_OLPC_XO_1_5: 303075f8991dSDaniel Drake codec->patch_ops.init = cxt5066_olpc_init; 303175f8991dSDaniel Drake codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; 30320fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs_olpc; 30330fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 3034c4cfe66cSDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; 30350fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30360fb67e98SDaniel Drake spec->port_d_mode = 0; 3037c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 30380fb67e98SDaniel Drake 30390fb67e98SDaniel Drake /* no S/PDIF out */ 30400fb67e98SDaniel Drake spec->multiout.dig_out_nid = 0; 30410fb67e98SDaniel Drake 30420fb67e98SDaniel Drake /* input source automatically selected */ 30430fb67e98SDaniel Drake spec->input_mux = NULL; 304475f8991dSDaniel Drake 304575f8991dSDaniel Drake /* our capture hooks which allow us to turn on the microphone LED 304675f8991dSDaniel Drake * at the right time */ 304775f8991dSDaniel Drake spec->capture_prepare = cxt5066_olpc_capture_prepare; 304875f8991dSDaniel Drake spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 30490fb67e98SDaniel Drake break; 30501feba3b7SDavid Henningsson case CXT5066_DELL_VOSTRO: 305175f8991dSDaniel Drake codec->patch_ops.init = cxt5066_init; 305202b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 305395a618bdSEinar Rünkaru spec->init_verbs[0] = cxt5066_init_verbs_vostro; 305495a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 305595a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3056254bba6aSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 305795a618bdSEinar Rünkaru spec->port_d_mode = 0; 3058254bba6aSEinar Rünkaru spec->dell_vostro = 1; 3059c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 306095a618bdSEinar Rünkaru 306195a618bdSEinar Rünkaru /* no S/PDIF out */ 306295a618bdSEinar Rünkaru spec->multiout.dig_out_nid = 0; 306395a618bdSEinar Rünkaru 306495a618bdSEinar Rünkaru /* input source automatically selected */ 306595a618bdSEinar Rünkaru spec->input_mux = NULL; 306695a618bdSEinar Rünkaru break; 3067cfd3d8dcSGreg Alexander case CXT5066_IDEAPAD: 3068cfd3d8dcSGreg Alexander codec->patch_ops.init = cxt5066_init; 306902b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3070cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3071cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3072cfd3d8dcSGreg Alexander spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 3073cfd3d8dcSGreg Alexander spec->port_d_mode = 0; 3074cfd3d8dcSGreg Alexander spec->ideapad = 1; 3075cfd3d8dcSGreg Alexander spec->mic_boost = 2; /* default 20dB gain */ 3076cfd3d8dcSGreg Alexander 3077cfd3d8dcSGreg Alexander /* no S/PDIF out */ 3078cfd3d8dcSGreg Alexander spec->multiout.dig_out_nid = 0; 3079cfd3d8dcSGreg Alexander 3080cfd3d8dcSGreg Alexander /* input source automatically selected */ 3081cfd3d8dcSGreg Alexander spec->input_mux = NULL; 3082cfd3d8dcSGreg Alexander break; 30837b2bfdbcSJens Taprogge case CXT5066_THINKPAD: 30847b2bfdbcSJens Taprogge codec->patch_ops.init = cxt5066_init; 308502b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 30867b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30877b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30887b2bfdbcSJens Taprogge spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 30897b2bfdbcSJens Taprogge spec->thinkpad = 1; 30907b2bfdbcSJens Taprogge spec->port_d_mode = PIN_OUT; 30917b2bfdbcSJens Taprogge spec->mic_boost = 2; /* default 20dB gain */ 30927b2bfdbcSJens Taprogge 30937b2bfdbcSJens Taprogge /* no S/PDIF out */ 30947b2bfdbcSJens Taprogge spec->multiout.dig_out_nid = 0; 30957b2bfdbcSJens Taprogge 30967b2bfdbcSJens Taprogge /* input source automatically selected */ 30977b2bfdbcSJens Taprogge spec->input_mux = NULL; 30987b2bfdbcSJens Taprogge break; 30990fb67e98SDaniel Drake } 31000fb67e98SDaniel Drake 31013507e2a8STakashi Iwai if (spec->beep_amp) 31023507e2a8STakashi Iwai snd_hda_attach_beep_device(codec, spec->beep_amp); 31033507e2a8STakashi Iwai 31040fb67e98SDaniel Drake return 0; 31050fb67e98SDaniel Drake } 3106461e2c78STakashi Iwai 3107*bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 3108*bf92d1d5STakashi Iwai 3109*bf92d1d5STakashi Iwai 3110461e2c78STakashi Iwai /* 3111f2e5731dSTakashi Iwai * Automatic parser for CX20641 & co 3112f2e5731dSTakashi Iwai */ 3113f2e5731dSTakashi Iwai 3114f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 3115f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec) 3116f2e5731dSTakashi Iwai { 3117f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 3118f2e5731dSTakashi Iwai hda_nid_t nid, end_nid; 3119f2e5731dSTakashi Iwai 3120f2e5731dSTakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 3121f2e5731dSTakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) 3122f2e5731dSTakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 3123f2e5731dSTakashi Iwai set_beep_amp(spec, nid, 0, HDA_OUTPUT); 3124f2e5731dSTakashi Iwai break; 3125f2e5731dSTakashi Iwai } 3126f2e5731dSTakashi Iwai } 3127f2e5731dSTakashi Iwai #else 3128f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec) 3129f2e5731dSTakashi Iwai #endif 3130f2e5731dSTakashi Iwai 3131254f2968STakashi Iwai /* parse EAPDs */ 313219110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 313319110595STakashi Iwai { 313419110595STakashi Iwai struct conexant_spec *spec = codec->spec; 313519110595STakashi Iwai hda_nid_t nid, end_nid; 313619110595STakashi Iwai 313719110595STakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 313819110595STakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) { 313919110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 314019110595STakashi Iwai continue; 314119110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 314219110595STakashi Iwai continue; 314319110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 314419110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 314519110595STakashi Iwai break; 314619110595STakashi Iwai } 3147254f2968STakashi Iwai 3148254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 3149254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 3150254f2968STakashi Iwai * pins, and we can control EAPD per pin. 3151254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 3152254f2968STakashi Iwai * thus it might control over all pins. 3153254f2968STakashi Iwai */ 3154aed523f1STakashi Iwai if (spec->num_eapds > 2) 3155aed523f1STakashi Iwai spec->gen.own_eapd_ctl = 1; 3156f2e5731dSTakashi Iwai } 3157f2e5731dSTakashi Iwai 3158da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 3159da339866STakashi Iwai hda_nid_t *pins, bool on) 3160f2e5731dSTakashi Iwai { 3161f2e5731dSTakashi Iwai int i; 3162f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 3163f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 3164f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 3165da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 3166da339866STakashi Iwai on ? 0x02 : 0); 3167f2e5731dSTakashi Iwai } 3168f2e5731dSTakashi Iwai } 3169f2e5731dSTakashi Iwai 3170527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 3171527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 3172527c73baSTakashi Iwai { 3173527c73baSTakashi Iwai struct hda_codec *codec = private_data; 3174527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 3175527c73baSTakashi Iwai 3176527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 3177527c73baSTakashi Iwai } 3178527c73baSTakashi Iwai 3179f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec) 3180f2e5731dSTakashi Iwai { 3181f2e5731dSTakashi Iwai int err; 3182f2e5731dSTakashi Iwai 3183aed523f1STakashi Iwai err = snd_hda_gen_build_controls(codec); 3184f2e5731dSTakashi Iwai if (err < 0) 3185f2e5731dSTakashi Iwai return err; 3186f2e5731dSTakashi Iwai 3187aed523f1STakashi Iwai err = add_beep_ctls(codec); 3188aed523f1STakashi Iwai if (err < 0) 3189aed523f1STakashi Iwai return err; 319022ce5f74STakashi Iwai 319122ce5f74STakashi Iwai return 0; 319222ce5f74STakashi Iwai } 319322ce5f74STakashi Iwai 319434cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 3195f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 3196aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 3197aed523f1STakashi Iwai .init = snd_hda_gen_init, 3198aed523f1STakashi Iwai .free = snd_hda_gen_free, 319929adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 3200f2e5731dSTakashi Iwai }; 3201f2e5731dSTakashi Iwai 3202e92d4b08STakashi Iwai /* 3203e92d4b08STakashi Iwai * pin fix-up 3204e92d4b08STakashi Iwai */ 320518dcd304SDavid Henningsson enum { 320618dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 3207d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 3208239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 3209239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 321018dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 3211239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 321218dcd304SDavid Henningsson }; 321318dcd304SDavid Henningsson 321423d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 321523d30f28STakashi Iwai const struct hda_fixup *fix, int action) 3216e92d4b08STakashi Iwai { 321718dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 3218aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 3219e92d4b08STakashi Iwai } 3220e92d4b08STakashi Iwai 3221239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 3222239fb862SHuacai Chen const struct hda_fixup *fix, int action) 3223239fb862SHuacai Chen { 3224239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 3225239fb862SHuacai Chen return; 3226239fb862SHuacai Chen 3227239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 3228239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 3229239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3230239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3231239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 3232239fb862SHuacai Chen } 3233239fb862SHuacai Chen 3234d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 323523d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3236e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3237e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3238e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 32393e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3240e92d4b08STakashi Iwai {} 3241e92d4b08STakashi Iwai }; 3242e92d4b08STakashi Iwai 3243d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 324423d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3245d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3246d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3247d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3248d70f3632STakashi Iwai {} 3249e92d4b08STakashi Iwai }; 3250e92d4b08STakashi Iwai 3251239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3252239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3253239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3254239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3255239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3256239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3257239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3258239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3259239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3260239fb862SHuacai Chen {} 3261239fb862SHuacai Chen }; 3262239fb862SHuacai Chen 326323d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 326423d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 326523d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 326623d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 326723d30f28STakashi Iwai }, 326823d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 326923d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 327023d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 327123d30f28STakashi Iwai }, 3272239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3273239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3274239fb862SHuacai Chen .chained = true, 3275239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3276239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3277239fb862SHuacai Chen }, 3278239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3279239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3280239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3281239fb862SHuacai Chen }, 328223d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 328323d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 328423d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 328523d30f28STakashi Iwai }, 3286239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3287239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3288239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3289239fb862SHuacai Chen }, 3290e92d4b08STakashi Iwai }; 3291e92d4b08STakashi Iwai 3292d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3293e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3294e92d4b08STakashi Iwai {} 3295e92d4b08STakashi Iwai }; 3296e92d4b08STakashi Iwai 3297d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 329863a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 3299d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3300d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3301d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3302d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3303d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 330418dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3305e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3306b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 3307239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3308239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3309f2e5731dSTakashi Iwai {} 3310f2e5731dSTakashi Iwai }; 3311f2e5731dSTakashi Iwai 33123868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 33133868137eSTakashi Iwai * can be created (bko#42825) 33143868137eSTakashi Iwai */ 33153868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 33163868137eSTakashi Iwai { 33173868137eSTakashi Iwai static hda_nid_t out_nids[] = { 33183868137eSTakashi Iwai 0x10, 0x11, 0 33193868137eSTakashi Iwai }; 33203868137eSTakashi Iwai hda_nid_t *p; 33213868137eSTakashi Iwai 33223868137eSTakashi Iwai for (p = out_nids; *p; p++) 33233868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 33243868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 33253868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 33263868137eSTakashi Iwai } 33273868137eSTakashi Iwai 3328f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3329f2e5731dSTakashi Iwai { 3330f2e5731dSTakashi Iwai struct conexant_spec *spec; 3331f2e5731dSTakashi Iwai int err; 3332f2e5731dSTakashi Iwai 33331f8458a2STakashi Iwai printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 33341f8458a2STakashi Iwai codec->chip_name); 33351f8458a2STakashi Iwai 3336f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3337f2e5731dSTakashi Iwai if (!spec) 3338f2e5731dSTakashi Iwai return -ENOMEM; 3339aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3340f2e5731dSTakashi Iwai codec->spec = spec; 3341e92d4b08STakashi Iwai 3342aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3343aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3344aed523f1STakashi Iwai if (spec->gen.own_eapd_ctl) 3345aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3346aed523f1STakashi Iwai 33476b452142STakashi Iwai switch (codec->vendor_id) { 33486b452142STakashi Iwai case 0x14f15045: 33494f32456eSMichael Karcher codec->single_adc_amp = 1; 33506b452142STakashi Iwai break; 33513868137eSTakashi Iwai case 0x14f15051: 33523868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 335351969d62SMichael Karcher codec->pin_amp_workaround = 1; 335423d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); 33553868137eSTakashi Iwai break; 335651969d62SMichael Karcher default: 335751969d62SMichael Karcher codec->pin_amp_workaround = 1; 335823d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); 335923d30f28STakashi Iwai break; 33606b452142STakashi Iwai } 33616b452142STakashi Iwai 3362f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3363f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3364f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3365f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3366f29735cbSTakashi Iwai * not good to expose it blindly. 3367527c73baSTakashi Iwai */ 3368f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3369f29735cbSTakashi Iwai case 0x103c: 3370aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3371f29735cbSTakashi Iwai break; 3372f29735cbSTakashi Iwai } 3373527c73baSTakashi Iwai 3374aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3375aed523f1STakashi Iwai 3376aed523f1STakashi Iwai err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); 337722ce5f74STakashi Iwai if (err < 0) 3378aed523f1STakashi Iwai goto error; 3379aed523f1STakashi Iwai 3380aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3381aed523f1STakashi Iwai if (err < 0) 3382aed523f1STakashi Iwai goto error; 3383aed523f1STakashi Iwai 3384f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 3385f2e5731dSTakashi Iwai if (spec->beep_amp) 3386f2e5731dSTakashi Iwai snd_hda_attach_beep_device(codec, spec->beep_amp); 33874f2864a4STakashi Iwai 33884f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 33894f2864a4STakashi Iwai * which falls into the single-cmd mode. 33904f2864a4STakashi Iwai * Better to make reset, then. 33914f2864a4STakashi Iwai */ 33924f2864a4STakashi Iwai if (!codec->bus->sync_write) { 33934f2864a4STakashi Iwai snd_printd("hda_codec: " 33944f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 33954f2864a4STakashi Iwai codec->bus->sync_write = 1; 33964f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 33974f2864a4STakashi Iwai } 33984f2864a4STakashi Iwai 3399f2e5731dSTakashi Iwai return 0; 3400aed523f1STakashi Iwai 3401aed523f1STakashi Iwai error: 3402aed523f1STakashi Iwai snd_hda_gen_free(codec); 3403aed523f1STakashi Iwai return err; 3404f2e5731dSTakashi Iwai } 3405f2e5731dSTakashi Iwai 3406*bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3407*bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3408*bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3409*bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3410*bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3411*bf92d1d5STakashi Iwai #endif 3412*bf92d1d5STakashi Iwai 3413f2e5731dSTakashi Iwai /* 3414461e2c78STakashi Iwai */ 3415461e2c78STakashi Iwai 341634cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 341782f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 341882f30040STobin Davis .patch = patch_cxt5045 }, 341982f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 342082f30040STobin Davis .patch = patch_cxt5047 }, 3421461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3422461e2c78STakashi Iwai .patch = patch_cxt5051 }, 34230fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 34240fb67e98SDaniel Drake .patch = patch_cxt5066 }, 342595a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 342695a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3427850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3428850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 34297b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 34307b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3431f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3432f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 34336da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 34346da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3435f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3436f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3437f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3438f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3439f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3440f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3441f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3442f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3443f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3444f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3445f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3446f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3447f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3448f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3449f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3450f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 34512d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 34522d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34532d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 34542d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34552d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 34562d825fd8STakashi Iwai .patch = patch_conexant_auto }, 3457c9b443d4STobin Davis {} /* terminator */ 3458c9b443d4STobin Davis }; 34591289e9e8STakashi Iwai 34601289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 34611289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 34621289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 34630fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 346495a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3465850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 34667b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3467f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 34686da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3469f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3470f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3471f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3472f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3473f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3474f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3475f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3476f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 34772d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 34782d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 34792d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 34801289e9e8STakashi Iwai 34811289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 34821289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 34831289e9e8STakashi Iwai 34841289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 34851289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 34861289e9e8STakashi Iwai .owner = THIS_MODULE, 34871289e9e8STakashi Iwai }; 34881289e9e8STakashi Iwai 34891289e9e8STakashi Iwai static int __init patch_conexant_init(void) 34901289e9e8STakashi Iwai { 34911289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 34921289e9e8STakashi Iwai } 34931289e9e8STakashi Iwai 34941289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 34951289e9e8STakashi Iwai { 34961289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 34971289e9e8STakashi Iwai } 34981289e9e8STakashi Iwai 34991289e9e8STakashi Iwai module_init(patch_conexant_init) 35001289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3501