1c9b443d4STobin Davis /* 2c9b443d4STobin Davis * HD audio interface patch for Conexant HDA audio codec 3c9b443d4STobin Davis * 4c9b443d4STobin Davis * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> 5c9b443d4STobin Davis * Takashi Iwai <tiwai@suse.de> 6c9b443d4STobin Davis * Tobin Davis <tdavis@dsl-only.net> 7c9b443d4STobin Davis * 8c9b443d4STobin Davis * This driver is free software; you can redistribute it and/or modify 9c9b443d4STobin Davis * it under the terms of the GNU General Public License as published by 10c9b443d4STobin Davis * the Free Software Foundation; either version 2 of the License, or 11c9b443d4STobin Davis * (at your option) any later version. 12c9b443d4STobin Davis * 13c9b443d4STobin Davis * This driver is distributed in the hope that it will be useful, 14c9b443d4STobin Davis * but WITHOUT ANY WARRANTY; without even the implied warranty of 15c9b443d4STobin Davis * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16c9b443d4STobin Davis * GNU General Public License for more details. 17c9b443d4STobin Davis * 18c9b443d4STobin Davis * You should have received a copy of the GNU General Public License 19c9b443d4STobin Davis * along with this program; if not, write to the Free Software 20c9b443d4STobin Davis * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21c9b443d4STobin Davis */ 22c9b443d4STobin Davis 23c9b443d4STobin Davis #include <linux/init.h> 24c9b443d4STobin Davis #include <linux/delay.h> 25c9b443d4STobin Davis #include <linux/slab.h> 26c9b443d4STobin Davis #include <linux/pci.h> 27da155d5bSPaul Gortmaker #include <linux/module.h> 28c9b443d4STobin Davis #include <sound/core.h> 29bc7a166dSUlrich Dangel #include <sound/jack.h> 30bc7a166dSUlrich Dangel 31c9b443d4STobin Davis #include "hda_codec.h" 32c9b443d4STobin Davis #include "hda_local.h" 3323d30f28STakashi Iwai #include "hda_auto_parser.h" 34c0f8faf0SEinar Rünkaru #include "hda_beep.h" 351835a0f9STakashi Iwai #include "hda_jack.h" 36aed523f1STakashi Iwai #include "hda_generic.h" 37c9b443d4STobin Davis 38bf92d1d5STakashi Iwai #define ENABLE_CXT_STATIC_QUIRKS 39c9b443d4STobin Davis 40c9b443d4STobin Davis #define CXT_PIN_DIR_IN 0x00 41c9b443d4STobin Davis #define CXT_PIN_DIR_OUT 0x01 42c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT 0x02 43c9b443d4STobin Davis #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 44c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 45c9b443d4STobin Davis 46c9b443d4STobin Davis #define CONEXANT_HP_EVENT 0x37 47c9b443d4STobin Davis #define CONEXANT_MIC_EVENT 0x38 4803697e2aSTakashi Iwai #define CONEXANT_LINE_EVENT 0x39 49c9b443d4STobin Davis 50bc7a166dSUlrich Dangel /* Conexant 5051 specific */ 51c9b443d4STobin Davis 52ecda0cffSTakashi Iwai #define CXT5051_SPDIF_OUT 0x12 53bc7a166dSUlrich Dangel #define CXT5051_PORTB_EVENT 0x38 54bc7a166dSUlrich Dangel #define CXT5051_PORTC_EVENT 0x39 55bc7a166dSUlrich Dangel 56faddaa5dSTakashi Iwai #define AUTO_MIC_PORTB (1 << 1) 57faddaa5dSTakashi Iwai #define AUTO_MIC_PORTC (1 << 2) 58bc7a166dSUlrich Dangel 59c9b443d4STobin Davis struct conexant_spec { 6023d30f28STakashi Iwai struct hda_gen_spec gen; 61c9b443d4STobin Davis 62bf92d1d5STakashi Iwai unsigned int beep_amp; 63bf92d1d5STakashi Iwai 64bf92d1d5STakashi Iwai /* extra EAPD pins */ 65bf92d1d5STakashi Iwai unsigned int num_eapds; 66bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 67*ff359b14STakashi Iwai bool dynamic_eapd; 68bf92d1d5STakashi Iwai 69bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 7034cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 71c9b443d4STobin Davis int num_mixers; 72dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 73c9b443d4STobin Davis 74c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 75c9b443d4STobin Davis * don't forget NULL 76c9b443d4STobin Davis * termination! 77c9b443d4STobin Davis */ 78c9b443d4STobin Davis unsigned int num_init_verbs; 79c9b443d4STobin Davis 80c9b443d4STobin Davis /* playback */ 81c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 82c9b443d4STobin Davis * max_channels, dacs must be set 83c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 84c9b443d4STobin Davis */ 85c9b443d4STobin Davis unsigned int cur_eapd; 8682f30040STobin Davis unsigned int hp_present; 8703697e2aSTakashi Iwai unsigned int line_present; 88faddaa5dSTakashi Iwai unsigned int auto_mic; 89c9b443d4STobin Davis 90c9b443d4STobin Davis /* capture */ 91c9b443d4STobin Davis unsigned int num_adc_nids; 9234cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 93c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 94c9b443d4STobin Davis 95461e2c78STakashi Iwai unsigned int cur_adc_idx; 96461e2c78STakashi Iwai hda_nid_t cur_adc; 97461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 98461e2c78STakashi Iwai unsigned int cur_adc_format; 99461e2c78STakashi Iwai 1006764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1016764bcefSTakashi Iwai 102c9b443d4STobin Davis /* capture source */ 103c9b443d4STobin Davis const struct hda_input_mux *input_mux; 10434cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 105c9b443d4STobin Davis unsigned int cur_mux[3]; 106c9b443d4STobin Davis 107c9b443d4STobin Davis /* channel model */ 108c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 109c9b443d4STobin Davis int num_channel_mode; 110c9b443d4STobin Davis 111c9b443d4STobin Davis /* PCM information */ 112c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 113c9b443d4STobin Davis 114c9b443d4STobin Davis unsigned int spdif_route; 115c9b443d4STobin Davis 1160fb67e98SDaniel Drake unsigned int port_d_mode; 117f2e5731dSTakashi Iwai unsigned int dell_automute:1; 118cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 119cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1207b2bfdbcSJens Taprogge unsigned int thinkpad:1; 121048e78a5SDavid Henningsson unsigned int hp_laptop:1; 122a1d6906eSDavid Henningsson unsigned int asus:1; 1236764bcefSTakashi Iwai 12475f8991dSDaniel Drake unsigned int ext_mic_present; 12575f8991dSDaniel Drake unsigned int recording; 12675f8991dSDaniel Drake void (*capture_prepare)(struct hda_codec *codec); 12775f8991dSDaniel Drake void (*capture_cleanup)(struct hda_codec *codec); 128c4cfe66cSDaniel Drake 129c4cfe66cSDaniel Drake /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 130c4cfe66cSDaniel Drake * through the microphone jack. 131c4cfe66cSDaniel Drake * When the user enables this through a mixer switch, both internal and 132c4cfe66cSDaniel Drake * external microphones are disabled. Gain is fixed at 0dB. In this mode, 133c4cfe66cSDaniel Drake * we also allow the bias to be configured through a separate mixer 134c4cfe66cSDaniel Drake * control. */ 135c4cfe66cSDaniel Drake unsigned int dc_enable; 136c4cfe66cSDaniel Drake unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ 137c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 138bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 139c9b443d4STobin Davis }; 140c9b443d4STobin Davis 141bf92d1d5STakashi Iwai 142bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 1437504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 1447504b6cdSTakashi Iwai int idx, int dir) 1457504b6cdSTakashi Iwai { 1467504b6cdSTakashi Iwai spec->gen.beep_nid = nid; 1477504b6cdSTakashi Iwai spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 1487504b6cdSTakashi Iwai } 149bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 150bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 151bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 152bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 153bf92d1d5STakashi Iwai { } /* end */ 154bf92d1d5STakashi Iwai }; 155bf92d1d5STakashi Iwai 156bf92d1d5STakashi Iwai /* create beep controls if needed */ 157bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 158bf92d1d5STakashi Iwai { 159bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 160bf92d1d5STakashi Iwai int err; 161bf92d1d5STakashi Iwai 162bf92d1d5STakashi Iwai if (spec->beep_amp) { 163bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 164bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 165bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 166bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 167bf92d1d5STakashi Iwai if (!kctl) 168bf92d1d5STakashi Iwai return -ENOMEM; 169bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 170bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 171bf92d1d5STakashi Iwai if (err < 0) 172bf92d1d5STakashi Iwai return err; 173bf92d1d5STakashi Iwai } 174bf92d1d5STakashi Iwai } 175bf92d1d5STakashi Iwai return 0; 176bf92d1d5STakashi Iwai } 177bf92d1d5STakashi Iwai #else 178bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 179bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 180bf92d1d5STakashi Iwai #endif 181bf92d1d5STakashi Iwai 182bf92d1d5STakashi Iwai 183bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 184c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 185c9b443d4STobin Davis struct hda_codec *codec, 186c9b443d4STobin Davis struct snd_pcm_substream *substream) 187c9b443d4STobin Davis { 188c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1899a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1909a08160bSTakashi Iwai hinfo); 191c9b443d4STobin Davis } 192c9b443d4STobin Davis 193c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 194c9b443d4STobin Davis struct hda_codec *codec, 195c9b443d4STobin Davis unsigned int stream_tag, 196c9b443d4STobin Davis unsigned int format, 197c9b443d4STobin Davis struct snd_pcm_substream *substream) 198c9b443d4STobin Davis { 199c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 200c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 201c9b443d4STobin Davis stream_tag, 202c9b443d4STobin Davis format, substream); 203c9b443d4STobin Davis } 204c9b443d4STobin Davis 205c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 206c9b443d4STobin Davis struct hda_codec *codec, 207c9b443d4STobin Davis struct snd_pcm_substream *substream) 208c9b443d4STobin Davis { 209c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 210c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 211c9b443d4STobin Davis } 212c9b443d4STobin Davis 213c9b443d4STobin Davis /* 214c9b443d4STobin Davis * Digital out 215c9b443d4STobin Davis */ 216c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 217c9b443d4STobin Davis struct hda_codec *codec, 218c9b443d4STobin Davis struct snd_pcm_substream *substream) 219c9b443d4STobin Davis { 220c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 221c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 222c9b443d4STobin Davis } 223c9b443d4STobin Davis 224c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 225c9b443d4STobin Davis struct hda_codec *codec, 226c9b443d4STobin Davis struct snd_pcm_substream *substream) 227c9b443d4STobin Davis { 228c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 229c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 230c9b443d4STobin Davis } 231c9b443d4STobin Davis 2326b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2336b97eb45STakashi Iwai struct hda_codec *codec, 2346b97eb45STakashi Iwai unsigned int stream_tag, 2356b97eb45STakashi Iwai unsigned int format, 2366b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2376b97eb45STakashi Iwai { 2386b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2396b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2406b97eb45STakashi Iwai stream_tag, 2416b97eb45STakashi Iwai format, substream); 2426b97eb45STakashi Iwai } 2436b97eb45STakashi Iwai 244c9b443d4STobin Davis /* 245c9b443d4STobin Davis * Analog capture 246c9b443d4STobin Davis */ 247c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 248c9b443d4STobin Davis struct hda_codec *codec, 249c9b443d4STobin Davis unsigned int stream_tag, 250c9b443d4STobin Davis unsigned int format, 251c9b443d4STobin Davis struct snd_pcm_substream *substream) 252c9b443d4STobin Davis { 253c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 25475f8991dSDaniel Drake if (spec->capture_prepare) 25575f8991dSDaniel Drake spec->capture_prepare(codec); 256c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 257c9b443d4STobin Davis stream_tag, 0, format); 258c9b443d4STobin Davis return 0; 259c9b443d4STobin Davis } 260c9b443d4STobin Davis 261c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 262c9b443d4STobin Davis struct hda_codec *codec, 263c9b443d4STobin Davis struct snd_pcm_substream *substream) 264c9b443d4STobin Davis { 265c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 266888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 26775f8991dSDaniel Drake if (spec->capture_cleanup) 26875f8991dSDaniel Drake spec->capture_cleanup(codec); 269c9b443d4STobin Davis return 0; 270c9b443d4STobin Davis } 271c9b443d4STobin Davis 272c9b443d4STobin Davis 273c9b443d4STobin Davis 27434cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 275c9b443d4STobin Davis .substreams = 1, 276c9b443d4STobin Davis .channels_min = 2, 277c9b443d4STobin Davis .channels_max = 2, 278c9b443d4STobin Davis .nid = 0, /* fill later */ 279c9b443d4STobin Davis .ops = { 280c9b443d4STobin Davis .open = conexant_playback_pcm_open, 281c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 282c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 283c9b443d4STobin Davis }, 284c9b443d4STobin Davis }; 285c9b443d4STobin Davis 28634cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 287c9b443d4STobin Davis .substreams = 1, 288c9b443d4STobin Davis .channels_min = 2, 289c9b443d4STobin Davis .channels_max = 2, 290c9b443d4STobin Davis .nid = 0, /* fill later */ 291c9b443d4STobin Davis .ops = { 292c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 293c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 294c9b443d4STobin Davis }, 295c9b443d4STobin Davis }; 296c9b443d4STobin Davis 297c9b443d4STobin Davis 29834cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 299c9b443d4STobin Davis .substreams = 1, 300c9b443d4STobin Davis .channels_min = 2, 301c9b443d4STobin Davis .channels_max = 2, 302c9b443d4STobin Davis .nid = 0, /* fill later */ 303c9b443d4STobin Davis .ops = { 304c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 3056b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 3066b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 307c9b443d4STobin Davis }, 308c9b443d4STobin Davis }; 309c9b443d4STobin Davis 31034cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 311c9b443d4STobin Davis .substreams = 1, 312c9b443d4STobin Davis .channels_min = 2, 313c9b443d4STobin Davis .channels_max = 2, 314c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 315c9b443d4STobin Davis }; 316c9b443d4STobin Davis 317461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 318461e2c78STakashi Iwai struct hda_codec *codec, 319461e2c78STakashi Iwai unsigned int stream_tag, 320461e2c78STakashi Iwai unsigned int format, 321461e2c78STakashi Iwai struct snd_pcm_substream *substream) 322461e2c78STakashi Iwai { 323461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 324461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 325461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 326461e2c78STakashi Iwai spec->cur_adc_format = format; 327461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 328461e2c78STakashi Iwai return 0; 329461e2c78STakashi Iwai } 330461e2c78STakashi Iwai 331461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 332461e2c78STakashi Iwai struct hda_codec *codec, 333461e2c78STakashi Iwai struct snd_pcm_substream *substream) 334461e2c78STakashi Iwai { 335461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 336888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 337461e2c78STakashi Iwai spec->cur_adc = 0; 338461e2c78STakashi Iwai return 0; 339461e2c78STakashi Iwai } 340461e2c78STakashi Iwai 34134cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 342461e2c78STakashi Iwai .substreams = 1, 343461e2c78STakashi Iwai .channels_min = 2, 344461e2c78STakashi Iwai .channels_max = 2, 345461e2c78STakashi Iwai .nid = 0, /* fill later */ 346461e2c78STakashi Iwai .ops = { 347461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 348461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 349461e2c78STakashi Iwai }, 350461e2c78STakashi Iwai }; 351461e2c78STakashi Iwai 352c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 353c9b443d4STobin Davis { 354c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 355c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 356c9b443d4STobin Davis 357c9b443d4STobin Davis codec->num_pcms = 1; 358c9b443d4STobin Davis codec->pcm_info = info; 359c9b443d4STobin Davis 360c9b443d4STobin Davis info->name = "CONEXANT Analog"; 361c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 362c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 363c9b443d4STobin Davis spec->multiout.max_channels; 364c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 365c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3666764bcefSTakashi Iwai if (spec->capture_stream) 3676764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3686764bcefSTakashi Iwai else { 369461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 370461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 371461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3726764bcefSTakashi Iwai else { 373461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 374461e2c78STakashi Iwai conexant_pcm_analog_capture; 3756764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3766764bcefSTakashi Iwai spec->num_adc_nids; 3776764bcefSTakashi Iwai } 3786764bcefSTakashi Iwai } 379c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 380c9b443d4STobin Davis 381c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 382c9b443d4STobin Davis info++; 383c9b443d4STobin Davis codec->num_pcms++; 384c9b443d4STobin Davis info->name = "Conexant Digital"; 3857ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 386c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 387c9b443d4STobin Davis conexant_pcm_digital_playback; 388c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 389c9b443d4STobin Davis spec->multiout.dig_out_nid; 390c9b443d4STobin Davis if (spec->dig_in_nid) { 391c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 392c9b443d4STobin Davis conexant_pcm_digital_capture; 393c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 394c9b443d4STobin Davis spec->dig_in_nid; 395c9b443d4STobin Davis } 396c9b443d4STobin Davis } 397c9b443d4STobin Davis 398c9b443d4STobin Davis return 0; 399c9b443d4STobin Davis } 400c9b443d4STobin Davis 401c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 402c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 403c9b443d4STobin Davis { 404c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 405c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 406c9b443d4STobin Davis 407c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 408c9b443d4STobin Davis } 409c9b443d4STobin Davis 410c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 411c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 412c9b443d4STobin Davis { 413c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 414c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 415c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 416c9b443d4STobin Davis 417c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 418c9b443d4STobin Davis return 0; 419c9b443d4STobin Davis } 420c9b443d4STobin Davis 421c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 422c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 423c9b443d4STobin Davis { 424c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 425c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 426c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 427c9b443d4STobin Davis 428c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 429c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 430c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 431c9b443d4STobin Davis } 432c9b443d4STobin Davis 4334d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4344d7fbdbcSTakashi Iwai unsigned int power_state) 4354d7fbdbcSTakashi Iwai { 4364d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4374d7fbdbcSTakashi Iwai msleep(100); 4384d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4394d7fbdbcSTakashi Iwai power_state); 4404d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4414d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4424d7fbdbcSTakashi Iwai msleep(10); 4439419ab6bSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state); 4444d7fbdbcSTakashi Iwai } 4454d7fbdbcSTakashi Iwai 446c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 447c9b443d4STobin Davis { 448c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 449c9b443d4STobin Davis int i; 450c9b443d4STobin Davis 451c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 452c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 453c9b443d4STobin Davis return 0; 454c9b443d4STobin Davis } 455c9b443d4STobin Davis 456c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 457c9b443d4STobin Davis { 458ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 459c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 460ee48df57STakashi Iwai kfree(spec); 461c9b443d4STobin Davis } 462c9b443d4STobin Davis 46334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 464b880c74aSTakashi Iwai { 465b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 466b880c74aSTakashi Iwai .name = "Capture Source", 467b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 468b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 469b880c74aSTakashi Iwai .put = conexant_mux_enum_put 470b880c74aSTakashi Iwai }, 471b880c74aSTakashi Iwai {} 472b880c74aSTakashi Iwai }; 473b880c74aSTakashi Iwai 4749322ca54STakashi Iwai static const char * const slave_pfxs[] = { 475f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 476dd5746a8STakashi Iwai NULL 477dd5746a8STakashi Iwai }; 478dd5746a8STakashi Iwai 479c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 480c9b443d4STobin Davis { 481c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 482c9b443d4STobin Davis unsigned int i; 483c9b443d4STobin Davis int err; 484c9b443d4STobin Davis 485c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 486c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 487c9b443d4STobin Davis if (err < 0) 488c9b443d4STobin Davis return err; 489c9b443d4STobin Davis } 490c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 491c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 49274b654c9SStephen Warren spec->multiout.dig_out_nid, 493c9b443d4STobin Davis spec->multiout.dig_out_nid); 494c9b443d4STobin Davis if (err < 0) 495c9b443d4STobin Davis return err; 4969a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4979a08160bSTakashi Iwai &spec->multiout); 4989a08160bSTakashi Iwai if (err < 0) 4999a08160bSTakashi Iwai return err; 5009a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 501c9b443d4STobin Davis } 502c9b443d4STobin Davis if (spec->dig_in_nid) { 503c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 504c9b443d4STobin Davis if (err < 0) 505c9b443d4STobin Davis return err; 506c9b443d4STobin Davis } 507dd5746a8STakashi Iwai 508dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 509dd5746a8STakashi Iwai if (spec->vmaster_nid && 510dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 511dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 512dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 513dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 514dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5159322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5169322ca54STakashi Iwai "Playback Volume"); 517dd5746a8STakashi Iwai if (err < 0) 518dd5746a8STakashi Iwai return err; 519dd5746a8STakashi Iwai } 520dd5746a8STakashi Iwai if (spec->vmaster_nid && 521dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 522aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5239322ca54STakashi Iwai NULL, slave_pfxs, 524aed523f1STakashi Iwai "Playback Switch"); 525dd5746a8STakashi Iwai if (err < 0) 526dd5746a8STakashi Iwai return err; 527dd5746a8STakashi Iwai } 528dd5746a8STakashi Iwai 529b880c74aSTakashi Iwai if (spec->input_mux) { 530b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 531b880c74aSTakashi Iwai if (err < 0) 532b880c74aSTakashi Iwai return err; 533b880c74aSTakashi Iwai } 534b880c74aSTakashi Iwai 535aed523f1STakashi Iwai err = add_beep_ctls(codec); 5363507e2a8STakashi Iwai if (err < 0) 5373507e2a8STakashi Iwai return err; 5383507e2a8STakashi Iwai 539c9b443d4STobin Davis return 0; 540c9b443d4STobin Davis } 541c9b443d4STobin Davis 54234cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 543c9b443d4STobin Davis .build_controls = conexant_build_controls, 544c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 545c9b443d4STobin Davis .init = conexant_init, 546c9b443d4STobin Davis .free = conexant_free, 5474d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 548c9b443d4STobin Davis }; 549c9b443d4STobin Davis 5506764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 551c9b443d4STobin Davis /* 552c9b443d4STobin Davis * EAPD control 553c9b443d4STobin Davis * the private value = nid | (invert << 8) 554c9b443d4STobin Davis */ 555c9b443d4STobin Davis 556a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 557c9b443d4STobin Davis 55882f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 559c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 560c9b443d4STobin Davis { 561c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 562c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 563c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 564c9b443d4STobin Davis if (invert) 565c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 566c9b443d4STobin Davis else 567c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 568c9b443d4STobin Davis return 0; 56982f30040STobin Davis 570c9b443d4STobin Davis } 571c9b443d4STobin Davis 57282f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 573c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 574c9b443d4STobin Davis { 575c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 576c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 577c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 578c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 579c9b443d4STobin Davis unsigned int eapd; 58082f30040STobin Davis 58168ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 582c9b443d4STobin Davis if (invert) 583c9b443d4STobin Davis eapd = !eapd; 58482beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 585c9b443d4STobin Davis return 0; 58682f30040STobin Davis 587c9b443d4STobin Davis spec->cur_eapd = eapd; 58882beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 589c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 590c9b443d4STobin Davis eapd ? 0x02 : 0x00); 591c9b443d4STobin Davis return 1; 592c9b443d4STobin Davis } 593c9b443d4STobin Davis 59486d72bdfSTakashi Iwai /* controls for test mode */ 59586d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 59686d72bdfSTakashi Iwai 59782f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 59882f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 59982f30040STobin Davis .info = cxt_eapd_info, \ 60082f30040STobin Davis .get = cxt_eapd_get, \ 60182f30040STobin Davis .put = cxt_eapd_put, \ 60282f30040STobin Davis .private_value = nid | (mask<<16) } 60382f30040STobin Davis 60482f30040STobin Davis 60582f30040STobin Davis 606c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 607c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 608c9b443d4STobin Davis { 609c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 610c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 611c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 612c9b443d4STobin Davis spec->num_channel_mode); 613c9b443d4STobin Davis } 614c9b443d4STobin Davis 615c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 616c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 617c9b443d4STobin Davis { 618c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 619c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 620c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 621c9b443d4STobin Davis spec->num_channel_mode, 622c9b443d4STobin Davis spec->multiout.max_channels); 623c9b443d4STobin Davis } 624c9b443d4STobin Davis 625c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 626c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 627c9b443d4STobin Davis { 628c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 629c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 630c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 631c9b443d4STobin Davis spec->num_channel_mode, 632c9b443d4STobin Davis &spec->multiout.max_channels); 633c9b443d4STobin Davis return err; 634c9b443d4STobin Davis } 635c9b443d4STobin Davis 636c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 637c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 638c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 639c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 640c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 641c9b443d4STobin Davis .private_value = nid | (dir<<16) } 642c9b443d4STobin Davis 64386d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 64486d72bdfSTakashi Iwai 645c9b443d4STobin Davis /* Conexant 5045 specific */ 646c9b443d4STobin Davis 64734cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 64834cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 64934cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 650cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 651c9b443d4STobin Davis 65234cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6535cd57529STobin Davis { 2, NULL }, 6545cd57529STobin Davis }; 655c9b443d4STobin Davis 65634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 657c9b443d4STobin Davis .num_items = 2, 658c9b443d4STobin Davis .items = { 6593edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6603edbbb9eSMichael Karcher { "Mic", 0x2 }, 661c9b443d4STobin Davis } 662c9b443d4STobin Davis }; 663c9b443d4STobin Davis 66434cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 665e6e03daeSMichael Karcher .num_items = 4, 6665218c892SJiang Zhe .items = { 6673edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6683edbbb9eSMichael Karcher { "Mic", 0x2 }, 6693edbbb9eSMichael Karcher { "Line", 0x3 }, 67022e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6715218c892SJiang Zhe } 6725218c892SJiang Zhe }; 6735218c892SJiang Zhe 67434cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_hp530 = { 6752de3c232SJiang zhe .num_items = 2, 6762de3c232SJiang zhe .items = { 6773edbbb9eSMichael Karcher { "Mic", 0x1 }, 6783edbbb9eSMichael Karcher { "Internal Mic", 0x2 }, 6792de3c232SJiang zhe } 6802de3c232SJiang zhe }; 6812de3c232SJiang zhe 682c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 683c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 684c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 685c9b443d4STobin Davis { 686c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 687c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 68882f30040STobin Davis unsigned int bits; 689c9b443d4STobin Davis 69082f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 691c9b443d4STobin Davis return 0; 692c9b443d4STobin Davis 69382f30040STobin Davis /* toggle internal speakers mute depending of presence of 69482f30040STobin Davis * the headphone jack 69582f30040STobin Davis */ 69647fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 69747fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 69847fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 6997f29673bSTobin Davis 70047fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 70147fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 70247fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 703c9b443d4STobin Davis return 1; 704c9b443d4STobin Davis } 705c9b443d4STobin Davis 706c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 70734cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 708cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 709cca3b371STakashi Iwai .values = { 710cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 711cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 712cca3b371STakashi Iwai 0 713cca3b371STakashi Iwai }, 714cca3b371STakashi Iwai }; 715c9b443d4STobin Davis 7167f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 7177f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7187f29673bSTobin Davis { 71934cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7207f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7217f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7227f29673bSTobin Davis {} 7237f29673bSTobin Davis }; 72434cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7257f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7267f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7277f29673bSTobin Davis {} 7287f29673bSTobin Davis }; 7297f29673bSTobin Davis unsigned int present; 7307f29673bSTobin Davis 731d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7327f29673bSTobin Davis if (present) 7337f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7347f29673bSTobin Davis else 7357f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7367f29673bSTobin Davis } 7377f29673bSTobin Davis 738c9b443d4STobin Davis 739c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 740c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 741c9b443d4STobin Davis { 74282f30040STobin Davis struct conexant_spec *spec = codec->spec; 743dd87da1cSTobin Davis unsigned int bits; 744c9b443d4STobin Davis 745d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 746dd87da1cSTobin Davis 74747fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 74847fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 74947fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 750c9b443d4STobin Davis } 751c9b443d4STobin Davis 752c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 753c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 754c9b443d4STobin Davis unsigned int res) 755c9b443d4STobin Davis { 756c9b443d4STobin Davis res >>= 26; 757c9b443d4STobin Davis switch (res) { 758c9b443d4STobin Davis case CONEXANT_HP_EVENT: 759c9b443d4STobin Davis cxt5045_hp_automute(codec); 760c9b443d4STobin Davis break; 7617f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7627f29673bSTobin Davis cxt5045_hp_automic(codec); 7637f29673bSTobin Davis break; 7647f29673bSTobin Davis 765c9b443d4STobin Davis } 766c9b443d4STobin Davis } 767c9b443d4STobin Davis 76834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 769cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 770cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 771c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 772c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 77328c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 77428c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7758607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7768607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 777cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 778c9b443d4STobin Davis { 779c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 780c9b443d4STobin Davis .name = "Master Playback Switch", 78182f30040STobin Davis .info = cxt_eapd_info, 78282f30040STobin Davis .get = cxt_eapd_get, 783c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 78482f30040STobin Davis .private_value = 0x10, 785c9b443d4STobin Davis }, 786c9b443d4STobin Davis 787c9b443d4STobin Davis {} 788c9b443d4STobin Davis }; 789c9b443d4STobin Davis 79034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7913edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7923edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 79322e14130SLukasz Marcinowski 7945218c892SJiang Zhe {} 7955218c892SJiang Zhe }; 7965218c892SJiang Zhe 79734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 798cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 799cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 8002de3c232SJiang zhe HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 8012de3c232SJiang zhe HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 80228c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 80328c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 8048607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 8058607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 8062de3c232SJiang zhe HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 8072de3c232SJiang zhe { 8082de3c232SJiang zhe .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8092de3c232SJiang zhe .name = "Master Playback Switch", 8102de3c232SJiang zhe .info = cxt_eapd_info, 8112de3c232SJiang zhe .get = cxt_eapd_get, 8122de3c232SJiang zhe .put = cxt5045_hp_master_sw_put, 8132de3c232SJiang zhe .private_value = 0x10, 8142de3c232SJiang zhe }, 8152de3c232SJiang zhe 8162de3c232SJiang zhe {} 8172de3c232SJiang zhe }; 8182de3c232SJiang zhe 81934cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 820c9b443d4STobin Davis /* Line in, Mic */ 8214090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8227f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 823c9b443d4STobin Davis /* HP, Amp */ 824c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 825c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 82682f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 827c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 828c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 829c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 830c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 831c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 832c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 83328c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8347f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 83582f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 836c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 837c9b443d4STobin Davis /* SPDIF route: PCM */ 838cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 839c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 840c9b443d4STobin Davis /* EAPD */ 84182f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 842c9b443d4STobin Davis { } /* end */ 843c9b443d4STobin Davis }; 844c9b443d4STobin Davis 84534cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 84628c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8475218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8485218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8495218c892SJiang Zhe /* Line In,HP, Amp */ 8505218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8515218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8525218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8535218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8545218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8555218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8565218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8575218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8585218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 85928c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8605218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8615218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8625218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8635218c892SJiang Zhe /* SPDIF route: PCM */ 864cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8655218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8665218c892SJiang Zhe /* EAPD */ 8675218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8685218c892SJiang Zhe { } /* end */ 8695218c892SJiang Zhe }; 8707f29673bSTobin Davis 87134cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8727f29673bSTobin Davis /* pin sensing on HP jack */ 8737f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 874d3091fadSTakashi Iwai { } /* end */ 8757f29673bSTobin Davis }; 8767f29673bSTobin Davis 87734cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8787f29673bSTobin Davis /* pin sensing on HP jack */ 8797f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 880d3091fadSTakashi Iwai { } /* end */ 8817f29673bSTobin Davis }; 8827f29673bSTobin Davis 883c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 884c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 885c9b443d4STobin Davis * configuration. 886c9b443d4STobin Davis */ 88734cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 888c9b443d4STobin Davis .num_items = 5, 889c9b443d4STobin Davis .items = { 890c9b443d4STobin Davis { "MIXER", 0x0 }, 891c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 892c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 893c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 894c9b443d4STobin Davis { "CD pin", 0x4 }, 895c9b443d4STobin Davis }, 896c9b443d4STobin Davis }; 897c9b443d4STobin Davis 89834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 899c9b443d4STobin Davis 900c9b443d4STobin Davis /* Output controls */ 901c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 902c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 903250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 904250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 905250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 906250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 907c9b443d4STobin Davis 908c9b443d4STobin Davis /* Modes for retasking pin widgets */ 909c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 910c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 911c9b443d4STobin Davis 91282f30040STobin Davis /* EAPD Switch Control */ 91382f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 91482f30040STobin Davis 915c9b443d4STobin Davis /* Loopback mixer controls */ 916c9b443d4STobin Davis 917250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 918250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 919250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 920250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 921250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 922250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 923250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 924250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 925250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 926250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 927c9b443d4STobin Davis { 928c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 929c9b443d4STobin Davis .name = "Input Source", 930c9b443d4STobin Davis .info = conexant_mux_enum_info, 931c9b443d4STobin Davis .get = conexant_mux_enum_get, 932c9b443d4STobin Davis .put = conexant_mux_enum_put, 933c9b443d4STobin Davis }, 934fb3409e7STobin Davis /* Audio input controls */ 935cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 936cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 937c9b443d4STobin Davis { } /* end */ 938c9b443d4STobin Davis }; 939c9b443d4STobin Davis 94034cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9417f29673bSTobin Davis /* Set connections */ 9427f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9437f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9447f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 945c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 946c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9477f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 948c9b443d4STobin Davis 949c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 950c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 951c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 952c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 953c9b443d4STobin Davis * control. 954c9b443d4STobin Davis */ 955cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 956cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 957c9b443d4STobin Davis 958c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 959c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 960c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 961c9b443d4STobin Davis * input/output buffers as needed. 962c9b443d4STobin Davis */ 963c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 964c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 965c9b443d4STobin Davis 966c9b443d4STobin Davis /* Mute capture amp left and right */ 967c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 968c9b443d4STobin Davis 969c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 970c9b443d4STobin Davis * pin) 971c9b443d4STobin Davis */ 972250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 973250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 974c9b443d4STobin Davis 975c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 976250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 977c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 978c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 979c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 980c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 981c9b443d4STobin Davis 982c9b443d4STobin Davis { } 983c9b443d4STobin Davis }; 984c9b443d4STobin Davis #endif 985c9b443d4STobin Davis 986c9b443d4STobin Davis 987c9b443d4STobin Davis /* initialize jack-sensing, too */ 988c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 989c9b443d4STobin Davis { 990c9b443d4STobin Davis conexant_init(codec); 991c9b443d4STobin Davis cxt5045_hp_automute(codec); 992c9b443d4STobin Davis return 0; 993c9b443d4STobin Davis } 994c9b443d4STobin Davis 995c9b443d4STobin Davis 996c9b443d4STobin Davis enum { 99715908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 99815908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 99915908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 10005218c892SJiang Zhe CXT5045_BENQ, 10012de3c232SJiang zhe CXT5045_LAPTOP_HP530, 1002c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1003c9b443d4STobin Davis CXT5045_TEST, 1004c9b443d4STobin Davis #endif 10051f8458a2STakashi Iwai CXT5045_AUTO, 1006f5fcc13cSTakashi Iwai CXT5045_MODELS 1007c9b443d4STobin Davis }; 1008c9b443d4STobin Davis 1009ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 101015908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 101115908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 101215908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 10135218c892SJiang Zhe [CXT5045_BENQ] = "benq", 10142de3c232SJiang zhe [CXT5045_LAPTOP_HP530] = "laptop-hp530", 1015c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1016f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 1017c9b443d4STobin Davis #endif 10181f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 1019f5fcc13cSTakashi Iwai }; 1020c9b443d4STobin Davis 102134cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 10222de3c232SJiang zhe SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 10236a9dccd6STakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 10245218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 102515908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 102615908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 10279e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 10289e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 102915908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 103015908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 103115908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1032dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 1033dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 103415908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1035c9b443d4STobin Davis {} 1036c9b443d4STobin Davis }; 1037c9b443d4STobin Davis 1038c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 1039c9b443d4STobin Davis { 1040c9b443d4STobin Davis struct conexant_spec *spec; 1041c9b443d4STobin Davis int board_config; 1042c9b443d4STobin Davis 10431f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10441f8458a2STakashi Iwai cxt5045_models, 10451f8458a2STakashi Iwai cxt5045_cfg_tbl); 10461f8458a2STakashi Iwai if (board_config < 0) 1047c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10481f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10491f8458a2STakashi Iwai return patch_conexant_auto(codec); 10501f8458a2STakashi Iwai 1051c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1052c9b443d4STobin Davis if (!spec) 1053c9b443d4STobin Davis return -ENOMEM; 1054c9b443d4STobin Davis codec->spec = spec; 10554f32456eSMichael Karcher codec->single_adc_amp = 1; 1056c9b443d4STobin Davis 1057c9b443d4STobin Davis spec->multiout.max_channels = 2; 1058c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1059c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1060c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1061c9b443d4STobin Davis spec->num_adc_nids = 1; 1062c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1063c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1064c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1065c9b443d4STobin Davis spec->num_mixers = 1; 1066c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1067c9b443d4STobin Davis spec->num_init_verbs = 1; 1068c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1069c9b443d4STobin Davis spec->spdif_route = 0; 10703507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10713507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10725cd57529STobin Davis 10733507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1074c9b443d4STobin Davis 1075c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1076c9b443d4STobin Davis 1077c9b443d4STobin Davis switch (board_config) { 107815908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10797f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1080c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1081c9b443d4STobin Davis spec->num_init_verbs = 2; 10827f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10837f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10847f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10857f29673bSTobin Davis break; 108615908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 108786376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10887f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10897f29673bSTobin Davis spec->num_init_verbs = 2; 10907f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1091c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1092c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1093c9b443d4STobin Davis break; 109415908c36SMarc Boucher default: 109515908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 109615908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 109715908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 109815908c36SMarc Boucher spec->num_init_verbs = 3; 109915908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 110015908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 110115908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 110215908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 110315908c36SMarc Boucher break; 11045218c892SJiang Zhe case CXT5045_BENQ: 11055218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11065218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 11075218c892SJiang Zhe spec->num_init_verbs = 1; 11085218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 11095218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 11105218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 11115218c892SJiang Zhe spec->num_mixers = 2; 11125218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 11135218c892SJiang Zhe break; 11142de3c232SJiang zhe case CXT5045_LAPTOP_HP530: 11152de3c232SJiang zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11162de3c232SJiang zhe spec->input_mux = &cxt5045_capture_source_hp530; 11172de3c232SJiang zhe spec->num_init_verbs = 2; 11182de3c232SJiang zhe spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 11192de3c232SJiang zhe spec->mixers[0] = cxt5045_mixers_hp530; 11202de3c232SJiang zhe codec->patch_ops.init = cxt5045_init; 11212de3c232SJiang zhe break; 1122c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1123c9b443d4STobin Davis case CXT5045_TEST: 1124c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1125c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1126c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 112715908c36SMarc Boucher break; 112815908c36SMarc Boucher 1129c9b443d4STobin Davis #endif 1130c9b443d4STobin Davis } 113148ecb7e8STakashi Iwai 1132031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1133031005f7STakashi Iwai case 0x103c: 11348f0f5ff6SDaniel T Chen case 0x1631: 11350b587fc4SDaniel T Chen case 0x1734: 11360ebf9e36SDaniel T Chen case 0x17aa: 11370ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 11380ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 11390ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 114048ecb7e8STakashi Iwai */ 114148ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 114248ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 114348ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 114448ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 114548ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1146031005f7STakashi Iwai break; 1147031005f7STakashi Iwai } 114848ecb7e8STakashi Iwai 11493507e2a8STakashi Iwai if (spec->beep_amp) 1150a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 11513507e2a8STakashi Iwai 1152c9b443d4STobin Davis return 0; 1153c9b443d4STobin Davis } 1154c9b443d4STobin Davis 1155c9b443d4STobin Davis 1156c9b443d4STobin Davis /* Conexant 5047 specific */ 115782f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1158c9b443d4STobin Davis 115934cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 116034cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 116134cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1162c9b443d4STobin Davis 116334cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11645cd57529STobin Davis { 2, NULL }, 11655cd57529STobin Davis }; 1166c9b443d4STobin Davis 116734cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 116882f30040STobin Davis .num_items = 2, 116982f30040STobin Davis .items = { 117082f30040STobin Davis { "ExtMic", 0x2 }, 117182f30040STobin Davis { "Line-In", 0x1 }, 1172c9b443d4STobin Davis } 1173c9b443d4STobin Davis }; 1174c9b443d4STobin Davis 1175c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1176c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1177c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1178c9b443d4STobin Davis { 1179c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1180c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 118182f30040STobin Davis unsigned int bits; 1182c9b443d4STobin Davis 118382f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1184c9b443d4STobin Davis return 0; 1185c9b443d4STobin Davis 118682f30040STobin Davis /* toggle internal speakers mute depending of presence of 118782f30040STobin Davis * the headphone jack 118882f30040STobin Davis */ 118947fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11903b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11913b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11923b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11933b7523fcSTakashi Iwai */ 11945d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 119547fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 119647fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 119747fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 119847fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1199c9b443d4STobin Davis return 1; 1200c9b443d4STobin Davis } 1201c9b443d4STobin Davis 1202c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1203c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1204c9b443d4STobin Davis { 120582f30040STobin Davis struct conexant_spec *spec = codec->spec; 1206dd87da1cSTobin Davis unsigned int bits; 1207c9b443d4STobin Davis 1208d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1209dd87da1cSTobin Davis 121047fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 12113b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12125d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 121347fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1214c9b443d4STobin Davis } 1215c9b443d4STobin Davis 1216c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1217c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1218c9b443d4STobin Davis { 121934cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 12209f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12219f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1222c9b443d4STobin Davis {} 1223c9b443d4STobin Davis }; 122434cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 12259f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12269f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1227c9b443d4STobin Davis {} 1228c9b443d4STobin Davis }; 1229c9b443d4STobin Davis unsigned int present; 1230c9b443d4STobin Davis 1231d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1232c9b443d4STobin Davis if (present) 1233c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1234c9b443d4STobin Davis else 1235c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1236c9b443d4STobin Davis } 1237c9b443d4STobin Davis 1238c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1239c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1240c9b443d4STobin Davis unsigned int res) 1241c9b443d4STobin Davis { 12429f113e0eSMarc Boucher switch (res >> 26) { 1243c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1244c9b443d4STobin Davis cxt5047_hp_automute(codec); 1245c9b443d4STobin Davis break; 1246c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1247c9b443d4STobin Davis cxt5047_hp_automic(codec); 1248c9b443d4STobin Davis break; 1249c9b443d4STobin Davis } 1250c9b443d4STobin Davis } 1251c9b443d4STobin Davis 125234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1253df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1254df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12555f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1256c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1257c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1258c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1259c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 126082f30040STobin Davis { 126182f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 126282f30040STobin Davis .name = "Master Playback Switch", 126382f30040STobin Davis .info = cxt_eapd_info, 126482f30040STobin Davis .get = cxt_eapd_get, 1265c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1266c9b443d4STobin Davis .private_value = 0x13, 1267c9b443d4STobin Davis }, 1268c9b443d4STobin Davis 1269c9b443d4STobin Davis {} 1270c9b443d4STobin Davis }; 1271c9b443d4STobin Davis 127234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12733b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12745d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1275df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1276df481e41STakashi Iwai {} 1277df481e41STakashi Iwai }; 1278df481e41STakashi Iwai 127934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1280c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1281c9b443d4STobin Davis { } /* end */ 1282c9b443d4STobin Davis }; 1283c9b443d4STobin Davis 128434cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1285c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1286c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1287c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1288c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12897f29673bSTobin Davis /* HP, Speaker */ 1290b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12915b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12925b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12937f29673bSTobin Davis /* Record selector: Mic */ 12947f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12957f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12967f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12977f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1298c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1299c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1300c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1301c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1302c9b443d4STobin Davis /* SPDIF route: PCM */ 1303c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 130482f30040STobin Davis /* Enable unsolicited events */ 130582f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 130682f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1307c9b443d4STobin Davis { } /* end */ 1308c9b443d4STobin Davis }; 1309c9b443d4STobin Davis 1310c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 131134cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 13123b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1313c9b443d4STobin Davis {} 1314c9b443d4STobin Davis }; 1315c9b443d4STobin Davis 1316c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1317c9b443d4STobin Davis * configuration. 1318c9b443d4STobin Davis */ 1319c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 132034cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 132182f30040STobin Davis .num_items = 4, 1322c9b443d4STobin Davis .items = { 132382f30040STobin Davis { "LINE1 pin", 0x0 }, 132482f30040STobin Davis { "MIC1 pin", 0x1 }, 132582f30040STobin Davis { "MIC2 pin", 0x2 }, 132682f30040STobin Davis { "CD pin", 0x3 }, 1327c9b443d4STobin Davis }, 1328c9b443d4STobin Davis }; 1329c9b443d4STobin Davis 133034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1331c9b443d4STobin Davis 1332c9b443d4STobin Davis /* Output only controls */ 133382f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 133482f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 133582f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 133682f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1337c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1338c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1339c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1340c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 134182f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 134282f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 134382f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 134482f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1345c9b443d4STobin Davis 1346c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1347c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1348c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1349c9b443d4STobin Davis 135082f30040STobin Davis /* EAPD Switch Control */ 135182f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 135282f30040STobin Davis 1353c9b443d4STobin Davis /* Loopback mixer controls */ 135482f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 135582f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 135682f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 135782f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 135882f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 135982f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 136082f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 136182f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1362c9b443d4STobin Davis 136382f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 136482f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 136582f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 136682f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 136782f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 136882f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 136982f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 137082f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1371c9b443d4STobin Davis { 1372c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1373c9b443d4STobin Davis .name = "Input Source", 1374c9b443d4STobin Davis .info = conexant_mux_enum_info, 1375c9b443d4STobin Davis .get = conexant_mux_enum_get, 1376c9b443d4STobin Davis .put = conexant_mux_enum_put, 1377c9b443d4STobin Davis }, 1378854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13799f113e0eSMarc Boucher 1380c9b443d4STobin Davis { } /* end */ 1381c9b443d4STobin Davis }; 1382c9b443d4STobin Davis 138334cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1384c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1385c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1386c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1387c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1388c9b443d4STobin Davis 1389c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1390c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1391c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1392c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1393c9b443d4STobin Davis * control. 1394c9b443d4STobin Davis */ 1395c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1396c9b443d4STobin Davis 1397c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1398c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1399c9b443d4STobin Davis */ 1400c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1401c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1402c9b443d4STobin Davis 1403c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1404c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1405c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1406c9b443d4STobin Davis 1407c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1408c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1409c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1410c9b443d4STobin Davis * input/output buffers as needed. 1411c9b443d4STobin Davis */ 1412c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1413c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1414c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1415c9b443d4STobin Davis 1416c9b443d4STobin Davis /* Mute capture amp left and right */ 1417c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1418c9b443d4STobin Davis 1419c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1420c9b443d4STobin Davis * pin) 1421c9b443d4STobin Davis */ 1422c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1423c9b443d4STobin Davis 1424c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1425c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1426c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1427c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1428c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1429c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1430c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1431c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1432c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1433c9b443d4STobin Davis 1434c9b443d4STobin Davis { } 1435c9b443d4STobin Davis }; 1436c9b443d4STobin Davis #endif 1437c9b443d4STobin Davis 1438c9b443d4STobin Davis 1439c9b443d4STobin Davis /* initialize jack-sensing, too */ 1440c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1441c9b443d4STobin Davis { 1442c9b443d4STobin Davis conexant_init(codec); 1443c9b443d4STobin Davis cxt5047_hp_automute(codec); 1444c9b443d4STobin Davis return 0; 1445c9b443d4STobin Davis } 1446c9b443d4STobin Davis 1447c9b443d4STobin Davis 1448c9b443d4STobin Davis enum { 1449f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1450f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1451f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1452c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1453c9b443d4STobin Davis CXT5047_TEST, 1454c9b443d4STobin Davis #endif 1455fa5dadcbSTakashi Iwai CXT5047_AUTO, 1456f5fcc13cSTakashi Iwai CXT5047_MODELS 1457c9b443d4STobin Davis }; 1458c9b443d4STobin Davis 1459ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1460f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1461f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1462f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1463c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1464f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1465c9b443d4STobin Davis #endif 1466fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1467f5fcc13cSTakashi Iwai }; 1468c9b443d4STobin Davis 146934cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1470ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1471dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1472dea0a509STakashi Iwai CXT5047_LAPTOP), 1473f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1474c9b443d4STobin Davis {} 1475c9b443d4STobin Davis }; 1476c9b443d4STobin Davis 1477c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1478c9b443d4STobin Davis { 1479c9b443d4STobin Davis struct conexant_spec *spec; 1480c9b443d4STobin Davis int board_config; 1481c9b443d4STobin Davis 1482fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1483fa5dadcbSTakashi Iwai cxt5047_models, 1484fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1485fa5dadcbSTakashi Iwai if (board_config < 0) 1486c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1487fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1488fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1489fa5dadcbSTakashi Iwai 1490c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1491c9b443d4STobin Davis if (!spec) 1492c9b443d4STobin Davis return -ENOMEM; 1493c9b443d4STobin Davis codec->spec = spec; 14949421f954STakashi Iwai codec->pin_amp_workaround = 1; 1495c9b443d4STobin Davis 1496c9b443d4STobin Davis spec->multiout.max_channels = 2; 1497c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1498c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1499c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1500c9b443d4STobin Davis spec->num_adc_nids = 1; 1501c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1502c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1503c9b443d4STobin Davis spec->num_mixers = 1; 1504df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1505c9b443d4STobin Davis spec->num_init_verbs = 1; 1506c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1507c9b443d4STobin Davis spec->spdif_route = 0; 15085cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 15095cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1510c9b443d4STobin Davis 1511c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1512c9b443d4STobin Davis 1513c9b443d4STobin Davis switch (board_config) { 1514c9b443d4STobin Davis case CXT5047_LAPTOP: 1515df481e41STakashi Iwai spec->num_mixers = 2; 1516df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1517df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1518c9b443d4STobin Davis break; 1519c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1520df481e41STakashi Iwai spec->num_mixers = 2; 1521df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1522fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1523c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1524c9b443d4STobin Davis break; 1525c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 152682f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1527df481e41STakashi Iwai spec->num_mixers = 2; 1528df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1529c9b443d4STobin Davis spec->num_init_verbs = 2; 1530c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1531fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1532c9b443d4STobin Davis break; 1533c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1534c9b443d4STobin Davis case CXT5047_TEST: 1535c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1536c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1537c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1538fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1539c9b443d4STobin Davis #endif 1540c9b443d4STobin Davis } 1541dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1542025f206cSDaniel T Chen 1543025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1544025f206cSDaniel T Chen case 0x103c: 1545025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1546025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1547025f206cSDaniel T Chen * with 0 dB offset 0x17) 1548025f206cSDaniel T Chen */ 1549025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1550025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1551025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1552025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1553025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1554025f206cSDaniel T Chen break; 1555025f206cSDaniel T Chen } 1556025f206cSDaniel T Chen 1557c9b443d4STobin Davis return 0; 1558c9b443d4STobin Davis } 1559c9b443d4STobin Davis 1560461e2c78STakashi Iwai /* Conexant 5051 specific */ 156134cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 156234cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1563461e2c78STakashi Iwai 156434cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1565461e2c78STakashi Iwai { 2, NULL }, 1566461e2c78STakashi Iwai }; 1567461e2c78STakashi Iwai 1568461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1569461e2c78STakashi Iwai { 1570461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1571461e2c78STakashi Iwai unsigned int pinctl; 157223d2df5bSTakashi Iwai /* headphone pin */ 157323d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1574cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 157523d2df5bSTakashi Iwai /* speaker pin */ 1576461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1577cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1578a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1579f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1580cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1581461e2c78STakashi Iwai } 1582461e2c78STakashi Iwai 1583461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1584461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1585461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1586461e2c78STakashi Iwai { 1587461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1588461e2c78STakashi Iwai 1589461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1590461e2c78STakashi Iwai return 0; 1591461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1592461e2c78STakashi Iwai return 1; 1593461e2c78STakashi Iwai } 1594461e2c78STakashi Iwai 1595461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1596461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1597461e2c78STakashi Iwai { 159879d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1599461e2c78STakashi Iwai unsigned int present; 1600461e2c78STakashi Iwai 1601faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 160279d7d533STakashi Iwai return; 1603d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1604461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1605461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1606461e2c78STakashi Iwai present ? 0x01 : 0x00); 1607461e2c78STakashi Iwai } 1608461e2c78STakashi Iwai 1609461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1610461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1611461e2c78STakashi Iwai { 1612461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1613461e2c78STakashi Iwai unsigned int present; 1614461e2c78STakashi Iwai hda_nid_t new_adc; 1615461e2c78STakashi Iwai 1616faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 161779d7d533STakashi Iwai return; 1618d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1619461e2c78STakashi Iwai if (present) 1620461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1621461e2c78STakashi Iwai else 1622461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1623461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1624461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1625461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1626f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1627461e2c78STakashi Iwai spec->cur_adc = new_adc; 1628461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1629461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1630461e2c78STakashi Iwai spec->cur_adc_format); 1631461e2c78STakashi Iwai } 1632461e2c78STakashi Iwai } 1633461e2c78STakashi Iwai 1634461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1635461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1636461e2c78STakashi Iwai { 1637461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1638461e2c78STakashi Iwai 1639d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1640461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1641461e2c78STakashi Iwai } 1642461e2c78STakashi Iwai 1643461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1644461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1645461e2c78STakashi Iwai unsigned int res) 1646461e2c78STakashi Iwai { 1647461e2c78STakashi Iwai switch (res >> 26) { 1648461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1649461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1650461e2c78STakashi Iwai break; 1651461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1652461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1653461e2c78STakashi Iwai break; 1654461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1655461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1656461e2c78STakashi Iwai break; 1657461e2c78STakashi Iwai } 1658461e2c78STakashi Iwai } 1659461e2c78STakashi Iwai 166034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1661461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1662461e2c78STakashi Iwai { 1663461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1664461e2c78STakashi Iwai .name = "Master Playback Switch", 1665461e2c78STakashi Iwai .info = cxt_eapd_info, 1666461e2c78STakashi Iwai .get = cxt_eapd_get, 1667461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1668461e2c78STakashi Iwai .private_value = 0x1a, 1669461e2c78STakashi Iwai }, 16702c7a3fb3STakashi Iwai {} 16712c7a3fb3STakashi Iwai }; 1672461e2c78STakashi Iwai 167334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16742c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16752c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16768607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16778607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1678c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1679c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1680461e2c78STakashi Iwai {} 1681461e2c78STakashi Iwai }; 1682461e2c78STakashi Iwai 168334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1684461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1685461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16868607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16878607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1688461e2c78STakashi Iwai {} 1689461e2c78STakashi Iwai }; 1690461e2c78STakashi Iwai 169134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16924e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16934e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 169479d7d533STakashi Iwai {} 169579d7d533STakashi Iwai }; 169679d7d533STakashi Iwai 169734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 16985f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 16995f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1700cd9d95a5SKen Prox {} 1701cd9d95a5SKen Prox }; 1702cd9d95a5SKen Prox 170334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1704faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1705faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 17068607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 17078607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1708faddaa5dSTakashi Iwai {} 1709faddaa5dSTakashi Iwai }; 1710faddaa5dSTakashi Iwai 171134cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1712461e2c78STakashi Iwai /* Line in, Mic */ 1713461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1714461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1715461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1716461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1717461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1718461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1719461e2c78STakashi Iwai /* SPK */ 1720461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1721461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1722461e2c78STakashi Iwai /* HP, Amp */ 1723461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1724461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1725461e2c78STakashi Iwai /* DAC1 */ 1726461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172728c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1728461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1729461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1730461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1731461e2c78STakashi Iwai /* SPDIF route: PCM */ 17321965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1733461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1734461e2c78STakashi Iwai /* EAPD */ 1735461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1736461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1737461e2c78STakashi Iwai { } /* end */ 1738461e2c78STakashi Iwai }; 1739461e2c78STakashi Iwai 174034cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 174179d7d533STakashi Iwai /* Line in, Mic */ 174279d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 174379d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 174479d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174579d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174679d7d533STakashi Iwai /* SPK */ 174779d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 174879d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 174979d7d533STakashi Iwai /* HP, Amp */ 175079d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 175179d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 175279d7d533STakashi Iwai /* DAC1 */ 175379d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 175428c4edb7SDavid Henningsson /* Record selector: Internal mic */ 175579d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 175679d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 175779d7d533STakashi Iwai /* SPDIF route: PCM */ 175879d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 175979d7d533STakashi Iwai /* EAPD */ 176079d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 176179d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 176279d7d533STakashi Iwai { } /* end */ 176379d7d533STakashi Iwai }; 176479d7d533STakashi Iwai 176534cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1766cd9d95a5SKen Prox /* Line in, Mic */ 176730ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1768cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1769cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1770cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1771cd9d95a5SKen Prox /* SPK */ 1772cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1773cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1774cd9d95a5SKen Prox /* HP, Amp */ 1775cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1776cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1777cd9d95a5SKen Prox /* DAC1 */ 1778cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 177928c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1780cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1781cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1782cd9d95a5SKen Prox /* SPDIF route: PCM */ 1783cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1784cd9d95a5SKen Prox /* EAPD */ 1785cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1786cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1787cd9d95a5SKen Prox { } /* end */ 1788cd9d95a5SKen Prox }; 1789cd9d95a5SKen Prox 17906953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17916953e552STakashi Iwai unsigned int event) 17926953e552STakashi Iwai { 17936953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17946953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17956953e552STakashi Iwai AC_USRSP_EN | event); 17966953e552STakashi Iwai } 17976953e552STakashi Iwai 179834cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1799f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1800f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1801f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1802f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1803f7154de2SHerton Ronaldo Krzesinski }; 1804f7154de2SHerton Ronaldo Krzesinski 1805461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1806461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1807461e2c78STakashi Iwai { 18086953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 18096953e552STakashi Iwai 1810461e2c78STakashi Iwai conexant_init(codec); 18116953e552STakashi Iwai 18126953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 18136953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 18146953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 18156953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 18166953e552STakashi Iwai 1817461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1818461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1819461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1820461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1821461e2c78STakashi Iwai } 1822461e2c78STakashi Iwai return 0; 1823461e2c78STakashi Iwai } 1824461e2c78STakashi Iwai 1825461e2c78STakashi Iwai 1826461e2c78STakashi Iwai enum { 1827461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1828461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 182979d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1830cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1831faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1832f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 18336764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1834461e2c78STakashi Iwai CXT5051_MODELS 1835461e2c78STakashi Iwai }; 1836461e2c78STakashi Iwai 1837ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1838461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1839461e2c78STakashi Iwai [CXT5051_HP] = "hp", 184079d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 18415f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1842faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1843f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 18446764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1845461e2c78STakashi Iwai }; 1846461e2c78STakashi Iwai 184734cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 184879d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 18491812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 18505f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1851faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1852461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1853461e2c78STakashi Iwai CXT5051_LAPTOP), 1854461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1855f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1856461e2c78STakashi Iwai {} 1857461e2c78STakashi Iwai }; 1858461e2c78STakashi Iwai 1859461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1860461e2c78STakashi Iwai { 1861461e2c78STakashi Iwai struct conexant_spec *spec; 1862461e2c78STakashi Iwai int board_config; 1863461e2c78STakashi Iwai 18646764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18656764bcefSTakashi Iwai cxt5051_models, 18666764bcefSTakashi Iwai cxt5051_cfg_tbl); 18676764bcefSTakashi Iwai if (board_config < 0) 1868c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18691f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18706764bcefSTakashi Iwai return patch_conexant_auto(codec); 18716764bcefSTakashi Iwai 1872461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1873461e2c78STakashi Iwai if (!spec) 1874461e2c78STakashi Iwai return -ENOMEM; 1875461e2c78STakashi Iwai codec->spec = spec; 18769421f954STakashi Iwai codec->pin_amp_workaround = 1; 1877461e2c78STakashi Iwai 1878461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1879461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1880461e2c78STakashi Iwai 1881461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1882461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1883461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1884461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1885461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1886461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18872c7a3fb3STakashi Iwai spec->num_mixers = 2; 18882c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18892c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1890461e2c78STakashi Iwai spec->num_init_verbs = 1; 1891461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1892461e2c78STakashi Iwai spec->spdif_route = 0; 1893461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1894461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1895461e2c78STakashi Iwai spec->cur_adc = 0; 1896461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1897461e2c78STakashi Iwai 18983507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 18993507e2a8STakashi Iwai 190079d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 190179d7d533STakashi Iwai 1902faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1903461e2c78STakashi Iwai switch (board_config) { 1904461e2c78STakashi Iwai case CXT5051_HP: 1905461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1906461e2c78STakashi Iwai break; 190779d7d533STakashi Iwai case CXT5051_HP_DV6736: 190879d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 190979d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1910faddaa5dSTakashi Iwai spec->auto_mic = 0; 191179d7d533STakashi Iwai break; 1912cd9d95a5SKen Prox case CXT5051_F700: 1913cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1914cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1915faddaa5dSTakashi Iwai spec->auto_mic = 0; 1916faddaa5dSTakashi Iwai break; 1917faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1918faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1919faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1920cd9d95a5SKen Prox break; 1921f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1922f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1923f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1924f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1925f7154de2SHerton Ronaldo Krzesinski break; 1926461e2c78STakashi Iwai } 1927461e2c78STakashi Iwai 19283507e2a8STakashi Iwai if (spec->beep_amp) 1929a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 19303507e2a8STakashi Iwai 1931461e2c78STakashi Iwai return 0; 1932461e2c78STakashi Iwai } 1933461e2c78STakashi Iwai 19340fb67e98SDaniel Drake /* Conexant 5066 specific */ 19350fb67e98SDaniel Drake 193634cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 193734cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 193834cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 193934cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 19400fb67e98SDaniel Drake 1941dbaccc0cSDaniel Drake /* OLPC's microphone port is DC coupled for use with external sensors, 1942dbaccc0cSDaniel Drake * therefore we use a 50% mic bias in order to center the input signal with 1943dbaccc0cSDaniel Drake * the DC input range of the codec. */ 1944dbaccc0cSDaniel Drake #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 1945dbaccc0cSDaniel Drake 194634cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 19470fb67e98SDaniel Drake { 2, NULL }, 19480fb67e98SDaniel Drake }; 19490fb67e98SDaniel Drake 1950a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1951a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1952a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1953a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1954a3de8ab8STakashi Iwai 19550fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 19560fb67e98SDaniel Drake { 19570fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19580fb67e98SDaniel Drake unsigned int pinctl; 19590fb67e98SDaniel Drake 19603a253445SJohn Baboval snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 19613a253445SJohn Baboval spec->hp_present, spec->cur_eapd); 19620fb67e98SDaniel Drake 19630fb67e98SDaniel Drake /* Port A (HP) */ 1964a3de8ab8STakashi Iwai pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; 1965cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x19, pinctl); 19660fb67e98SDaniel Drake 19670fb67e98SDaniel Drake /* Port D (HP/LO) */ 1968a3de8ab8STakashi Iwai pinctl = spec->cur_eapd ? spec->port_d_mode : 0; 1969a3de8ab8STakashi Iwai if (spec->dell_automute || spec->thinkpad) { 1970a3de8ab8STakashi Iwai /* Mute if Port A is connected */ 1971a3de8ab8STakashi Iwai if (hp_port_a_present(spec)) 19723a253445SJohn Baboval pinctl = 0; 19733a253445SJohn Baboval } else { 1974a3de8ab8STakashi Iwai /* Thinkpad/Dell doesn't give pin-D status */ 1975a3de8ab8STakashi Iwai if (!hp_port_d_present(spec)) 1976a3de8ab8STakashi Iwai pinctl = 0; 19773a253445SJohn Baboval } 1978cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1c, pinctl); 19790fb67e98SDaniel Drake 19800fb67e98SDaniel Drake /* CLASS_D AMP */ 19810fb67e98SDaniel Drake pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1982cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1f, pinctl); 19830fb67e98SDaniel Drake } 19840fb67e98SDaniel Drake 19850fb67e98SDaniel Drake /* turn on/off EAPD (+ mute HP) as a master switch */ 19860fb67e98SDaniel Drake static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, 19870fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 19880fb67e98SDaniel Drake { 19890fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 19900fb67e98SDaniel Drake 19910fb67e98SDaniel Drake if (!cxt_eapd_put(kcontrol, ucontrol)) 19920fb67e98SDaniel Drake return 0; 19930fb67e98SDaniel Drake 19940fb67e98SDaniel Drake cxt5066_update_speaker(codec); 19950fb67e98SDaniel Drake return 1; 19960fb67e98SDaniel Drake } 19970fb67e98SDaniel Drake 1998c4cfe66cSDaniel Drake static const struct hda_input_mux cxt5066_olpc_dc_bias = { 1999c4cfe66cSDaniel Drake .num_items = 3, 2000c4cfe66cSDaniel Drake .items = { 2001c4cfe66cSDaniel Drake { "Off", PIN_IN }, 2002c4cfe66cSDaniel Drake { "50%", PIN_VREF50 }, 2003c4cfe66cSDaniel Drake { "80%", PIN_VREF80 }, 2004c4cfe66cSDaniel Drake }, 2005c4cfe66cSDaniel Drake }; 2006c4cfe66cSDaniel Drake 2007c4cfe66cSDaniel Drake static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) 2008c4cfe66cSDaniel Drake { 2009c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2010c4cfe66cSDaniel Drake /* Even though port F is the DC input, the bias is controlled on port B. 2011c4cfe66cSDaniel Drake * we also leave that port as an active input (but unselected) in DC mode 2012c4cfe66cSDaniel Drake * just in case that is necessary to make the bias setting take effect. */ 2013cdd03cedSTakashi Iwai return snd_hda_set_pin_ctl_cache(codec, 0x1a, 2014c4cfe66cSDaniel Drake cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); 2015c4cfe66cSDaniel Drake } 2016c4cfe66cSDaniel Drake 201775f8991dSDaniel Drake /* OLPC defers mic widget control until when capture is started because the 201875f8991dSDaniel Drake * microphone LED comes on as soon as these settings are put in place. if we 201975f8991dSDaniel Drake * did this before recording, it would give the false indication that recording 202075f8991dSDaniel Drake * is happening when it is not. */ 202175f8991dSDaniel Drake static void cxt5066_olpc_select_mic(struct hda_codec *codec) 20220fb67e98SDaniel Drake { 2023dbaccc0cSDaniel Drake struct conexant_spec *spec = codec->spec; 202475f8991dSDaniel Drake if (!spec->recording) 202575f8991dSDaniel Drake return; 20260fb67e98SDaniel Drake 2027c4cfe66cSDaniel Drake if (spec->dc_enable) { 2028c4cfe66cSDaniel Drake /* in DC mode we ignore presence detection and just use the jack 2029c4cfe66cSDaniel Drake * through our special DC port */ 2030c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2031c4cfe66cSDaniel Drake /* disble internal mic, port C */ 2032c4cfe66cSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2033c4cfe66cSDaniel Drake 2034c4cfe66cSDaniel Drake /* enable DC capture, port F */ 2035c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2036c4cfe66cSDaniel Drake {}, 2037c4cfe66cSDaniel Drake }; 2038c4cfe66cSDaniel Drake 2039c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2040c4cfe66cSDaniel Drake /* port B input disabled (and bias set) through the following call */ 2041c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 2042c4cfe66cSDaniel Drake return; 2043c4cfe66cSDaniel Drake } 2044c4cfe66cSDaniel Drake 2045c4cfe66cSDaniel Drake /* disable DC (port F) */ 2046cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1e, 0); 2047c4cfe66cSDaniel Drake 204875f8991dSDaniel Drake /* external mic, port B */ 2049cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, 205075f8991dSDaniel Drake spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); 20510fb67e98SDaniel Drake 205275f8991dSDaniel Drake /* internal mic, port C */ 2053cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, 205475f8991dSDaniel Drake spec->ext_mic_present ? 0 : PIN_VREF80); 205575f8991dSDaniel Drake } 20560fb67e98SDaniel Drake 205775f8991dSDaniel Drake /* toggle input of built-in and mic jack appropriately */ 205875f8991dSDaniel Drake static void cxt5066_olpc_automic(struct hda_codec *codec) 205975f8991dSDaniel Drake { 206075f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 20610fb67e98SDaniel Drake unsigned int present; 20620fb67e98SDaniel Drake 2063c4cfe66cSDaniel Drake if (spec->dc_enable) /* don't do presence detection in DC mode */ 2064c4cfe66cSDaniel Drake return; 2065c4cfe66cSDaniel Drake 206675f8991dSDaniel Drake present = snd_hda_codec_read(codec, 0x1a, 0, 206775f8991dSDaniel Drake AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 206875f8991dSDaniel Drake if (present) 20690fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone detected\n"); 207075f8991dSDaniel Drake else 20710fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone absent\n"); 207275f8991dSDaniel Drake 207375f8991dSDaniel Drake snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 207475f8991dSDaniel Drake present ? 0 : 1); 207575f8991dSDaniel Drake spec->ext_mic_present = !!present; 207675f8991dSDaniel Drake 207775f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 20780fb67e98SDaniel Drake } 20790fb67e98SDaniel Drake 208095a618bdSEinar Rünkaru /* toggle input of built-in digital mic and mic jack appropriately */ 208195a618bdSEinar Rünkaru static void cxt5066_vostro_automic(struct hda_codec *codec) 208295a618bdSEinar Rünkaru { 208395a618bdSEinar Rünkaru unsigned int present; 208495a618bdSEinar Rünkaru 208595a618bdSEinar Rünkaru struct hda_verb ext_mic_present[] = { 208695a618bdSEinar Rünkaru /* enable external mic, port B */ 208775f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 208895a618bdSEinar Rünkaru 208995a618bdSEinar Rünkaru /* switch to external mic input */ 209095a618bdSEinar Rünkaru {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 209195a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 209295a618bdSEinar Rünkaru 209395a618bdSEinar Rünkaru /* disable internal digital mic */ 209495a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 209595a618bdSEinar Rünkaru {} 209695a618bdSEinar Rünkaru }; 209734cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 209895a618bdSEinar Rünkaru /* enable internal mic, port C */ 209995a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 210095a618bdSEinar Rünkaru 210195a618bdSEinar Rünkaru /* switch to internal mic input */ 210295a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 210395a618bdSEinar Rünkaru 210495a618bdSEinar Rünkaru /* disable external mic, port B */ 210595a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 210695a618bdSEinar Rünkaru {} 210795a618bdSEinar Rünkaru }; 210895a618bdSEinar Rünkaru 210995a618bdSEinar Rünkaru present = snd_hda_jack_detect(codec, 0x1a); 211095a618bdSEinar Rünkaru if (present) { 211195a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone detected\n"); 211295a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 211395a618bdSEinar Rünkaru } else { 211495a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone absent\n"); 211595a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_absent); 211695a618bdSEinar Rünkaru } 211795a618bdSEinar Rünkaru } 211895a618bdSEinar Rünkaru 2119cfd3d8dcSGreg Alexander /* toggle input of built-in digital mic and mic jack appropriately */ 2120cfd3d8dcSGreg Alexander static void cxt5066_ideapad_automic(struct hda_codec *codec) 2121cfd3d8dcSGreg Alexander { 2122cfd3d8dcSGreg Alexander unsigned int present; 2123cfd3d8dcSGreg Alexander 2124cfd3d8dcSGreg Alexander struct hda_verb ext_mic_present[] = { 2125cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 2126cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2127cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2128cfd3d8dcSGreg Alexander {} 2129cfd3d8dcSGreg Alexander }; 213034cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 2131cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 2132cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2133cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2134cfd3d8dcSGreg Alexander {} 2135cfd3d8dcSGreg Alexander }; 2136cfd3d8dcSGreg Alexander 2137cfd3d8dcSGreg Alexander present = snd_hda_jack_detect(codec, 0x1b); 2138cfd3d8dcSGreg Alexander if (present) { 2139cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone detected\n"); 2140cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2141cfd3d8dcSGreg Alexander } else { 2142cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone absent\n"); 2143cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_absent); 2144cfd3d8dcSGreg Alexander } 2145cfd3d8dcSGreg Alexander } 2146cfd3d8dcSGreg Alexander 2147a1d6906eSDavid Henningsson 2148a1d6906eSDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2149a1d6906eSDavid Henningsson static void cxt5066_asus_automic(struct hda_codec *codec) 2150a1d6906eSDavid Henningsson { 2151a1d6906eSDavid Henningsson unsigned int present; 2152a1d6906eSDavid Henningsson 2153a1d6906eSDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2154a1d6906eSDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2155a1d6906eSDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2156a1d6906eSDavid Henningsson present ? 1 : 0); 2157a1d6906eSDavid Henningsson } 2158a1d6906eSDavid Henningsson 2159a1d6906eSDavid Henningsson 2160048e78a5SDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2161048e78a5SDavid Henningsson static void cxt5066_hp_laptop_automic(struct hda_codec *codec) 2162048e78a5SDavid Henningsson { 2163048e78a5SDavid Henningsson unsigned int present; 2164048e78a5SDavid Henningsson 2165048e78a5SDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2166048e78a5SDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2167048e78a5SDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2168048e78a5SDavid Henningsson present ? 1 : 3); 2169048e78a5SDavid Henningsson } 2170048e78a5SDavid Henningsson 2171048e78a5SDavid Henningsson 21727b2bfdbcSJens Taprogge /* toggle input of built-in digital mic and mic jack appropriately 21737b2bfdbcSJens Taprogge order is: external mic -> dock mic -> interal mic */ 21747b2bfdbcSJens Taprogge static void cxt5066_thinkpad_automic(struct hda_codec *codec) 21757b2bfdbcSJens Taprogge { 21767b2bfdbcSJens Taprogge unsigned int ext_present, dock_present; 21777b2bfdbcSJens Taprogge 217834cbe3a6STakashi Iwai static const struct hda_verb ext_mic_present[] = { 21797b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21807b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 21817b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21827b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21837b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21847b2bfdbcSJens Taprogge {} 21857b2bfdbcSJens Taprogge }; 218634cbe3a6STakashi Iwai static const struct hda_verb dock_mic_present[] = { 21877b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21887b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 21897b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21907b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21917b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21927b2bfdbcSJens Taprogge {} 21937b2bfdbcSJens Taprogge }; 219434cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 21957b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 21967b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 21977b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21987b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21997b2bfdbcSJens Taprogge {} 22007b2bfdbcSJens Taprogge }; 22017b2bfdbcSJens Taprogge 22027b2bfdbcSJens Taprogge ext_present = snd_hda_jack_detect(codec, 0x1b); 22037b2bfdbcSJens Taprogge dock_present = snd_hda_jack_detect(codec, 0x1a); 22047b2bfdbcSJens Taprogge if (ext_present) { 22057b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone detected\n"); 22067b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 22077b2bfdbcSJens Taprogge } else if (dock_present) { 22087b2bfdbcSJens Taprogge snd_printdd("CXT5066: dock microphone detected\n"); 22097b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 22107b2bfdbcSJens Taprogge } else { 22117b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone absent\n"); 22127b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_absent); 22137b2bfdbcSJens Taprogge } 22147b2bfdbcSJens Taprogge } 22157b2bfdbcSJens Taprogge 22160fb67e98SDaniel Drake /* mute internal speaker if HP is plugged */ 22170fb67e98SDaniel Drake static void cxt5066_hp_automute(struct hda_codec *codec) 22180fb67e98SDaniel Drake { 22190fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 22200fb67e98SDaniel Drake unsigned int portA, portD; 22210fb67e98SDaniel Drake 22220fb67e98SDaniel Drake /* Port A */ 2223d56757abSTakashi Iwai portA = snd_hda_jack_detect(codec, 0x19); 22240fb67e98SDaniel Drake 22250fb67e98SDaniel Drake /* Port D */ 2226d56757abSTakashi Iwai portD = snd_hda_jack_detect(codec, 0x1c); 22270fb67e98SDaniel Drake 2228a3de8ab8STakashi Iwai spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2229a3de8ab8STakashi Iwai spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 22300fb67e98SDaniel Drake snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 22310fb67e98SDaniel Drake portA, portD, spec->hp_present); 22320fb67e98SDaniel Drake cxt5066_update_speaker(codec); 22330fb67e98SDaniel Drake } 22340fb67e98SDaniel Drake 223502b6b5b6SDavid Henningsson /* Dispatch the right mic autoswitch function */ 223602b6b5b6SDavid Henningsson static void cxt5066_automic(struct hda_codec *codec) 223702b6b5b6SDavid Henningsson { 223802b6b5b6SDavid Henningsson struct conexant_spec *spec = codec->spec; 223902b6b5b6SDavid Henningsson 224002b6b5b6SDavid Henningsson if (spec->dell_vostro) 224102b6b5b6SDavid Henningsson cxt5066_vostro_automic(codec); 224202b6b5b6SDavid Henningsson else if (spec->ideapad) 224302b6b5b6SDavid Henningsson cxt5066_ideapad_automic(codec); 224402b6b5b6SDavid Henningsson else if (spec->thinkpad) 224502b6b5b6SDavid Henningsson cxt5066_thinkpad_automic(codec); 224602b6b5b6SDavid Henningsson else if (spec->hp_laptop) 224702b6b5b6SDavid Henningsson cxt5066_hp_laptop_automic(codec); 2248a1d6906eSDavid Henningsson else if (spec->asus) 2249a1d6906eSDavid Henningsson cxt5066_asus_automic(codec); 225002b6b5b6SDavid Henningsson } 225102b6b5b6SDavid Henningsson 22520fb67e98SDaniel Drake /* unsolicited event for jack sensing */ 225375f8991dSDaniel Drake static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 22540fb67e98SDaniel Drake { 2255c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 22560fb67e98SDaniel Drake snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 22570fb67e98SDaniel Drake switch (res >> 26) { 22580fb67e98SDaniel Drake case CONEXANT_HP_EVENT: 22590fb67e98SDaniel Drake cxt5066_hp_automute(codec); 22600fb67e98SDaniel Drake break; 22610fb67e98SDaniel Drake case CONEXANT_MIC_EVENT: 2262c4cfe66cSDaniel Drake /* ignore mic events in DC mode; we're always using the jack */ 2263c4cfe66cSDaniel Drake if (!spec->dc_enable) 226475f8991dSDaniel Drake cxt5066_olpc_automic(codec); 22650fb67e98SDaniel Drake break; 22660fb67e98SDaniel Drake } 22670fb67e98SDaniel Drake } 22680fb67e98SDaniel Drake 226995a618bdSEinar Rünkaru /* unsolicited event for jack sensing */ 227002b6b5b6SDavid Henningsson static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 227195a618bdSEinar Rünkaru { 227202b6b5b6SDavid Henningsson snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 227395a618bdSEinar Rünkaru switch (res >> 26) { 227495a618bdSEinar Rünkaru case CONEXANT_HP_EVENT: 227595a618bdSEinar Rünkaru cxt5066_hp_automute(codec); 227695a618bdSEinar Rünkaru break; 227795a618bdSEinar Rünkaru case CONEXANT_MIC_EVENT: 227802b6b5b6SDavid Henningsson cxt5066_automic(codec); 227995a618bdSEinar Rünkaru break; 228095a618bdSEinar Rünkaru } 228195a618bdSEinar Rünkaru } 228295a618bdSEinar Rünkaru 22837b2bfdbcSJens Taprogge 22840fb67e98SDaniel Drake static const struct hda_input_mux cxt5066_analog_mic_boost = { 22850fb67e98SDaniel Drake .num_items = 5, 22860fb67e98SDaniel Drake .items = { 22870fb67e98SDaniel Drake { "0dB", 0 }, 22880fb67e98SDaniel Drake { "10dB", 1 }, 22890fb67e98SDaniel Drake { "20dB", 2 }, 22900fb67e98SDaniel Drake { "30dB", 3 }, 22910fb67e98SDaniel Drake { "40dB", 4 }, 22920fb67e98SDaniel Drake }, 22930fb67e98SDaniel Drake }; 22940fb67e98SDaniel Drake 2295cfd3d8dcSGreg Alexander static void cxt5066_set_mic_boost(struct hda_codec *codec) 2296c4cfe66cSDaniel Drake { 2297c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2298cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x17, 0, 2299c4cfe66cSDaniel Drake AC_VERB_SET_AMP_GAIN_MUTE, 2300c4cfe66cSDaniel Drake AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2301c4cfe66cSDaniel Drake cxt5066_analog_mic_boost.items[spec->mic_boost].index); 23027b2bfdbcSJens Taprogge if (spec->ideapad || spec->thinkpad) { 2303cfd3d8dcSGreg Alexander /* adjust the internal mic as well...it is not through 0x17 */ 2304cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x23, 0, 2305cfd3d8dcSGreg Alexander AC_VERB_SET_AMP_GAIN_MUTE, 2306cfd3d8dcSGreg Alexander AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | 2307cfd3d8dcSGreg Alexander cxt5066_analog_mic_boost. 2308cfd3d8dcSGreg Alexander items[spec->mic_boost].index); 2309cfd3d8dcSGreg Alexander } 2310c4cfe66cSDaniel Drake } 2311c4cfe66cSDaniel Drake 23120fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 23130fb67e98SDaniel Drake struct snd_ctl_elem_info *uinfo) 23140fb67e98SDaniel Drake { 23150fb67e98SDaniel Drake return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); 23160fb67e98SDaniel Drake } 23170fb67e98SDaniel Drake 23180fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, 23190fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23200fb67e98SDaniel Drake { 23210fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2322c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2323c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->mic_boost; 23240fb67e98SDaniel Drake return 0; 23250fb67e98SDaniel Drake } 23260fb67e98SDaniel Drake 23270fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, 23280fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23290fb67e98SDaniel Drake { 23300fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2331c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 23320fb67e98SDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 23330fb67e98SDaniel Drake unsigned int idx; 23340fb67e98SDaniel Drake idx = ucontrol->value.enumerated.item[0]; 23350fb67e98SDaniel Drake if (idx >= imux->num_items) 23360fb67e98SDaniel Drake idx = imux->num_items - 1; 23370fb67e98SDaniel Drake 2338c4cfe66cSDaniel Drake spec->mic_boost = idx; 2339c4cfe66cSDaniel Drake if (!spec->dc_enable) 2340c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2341c4cfe66cSDaniel Drake return 1; 2342c4cfe66cSDaniel Drake } 23430fb67e98SDaniel Drake 2344c4cfe66cSDaniel Drake static void cxt5066_enable_dc(struct hda_codec *codec) 2345c4cfe66cSDaniel Drake { 2346c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2347c4cfe66cSDaniel Drake /* disable gain */ 2348c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2349c4cfe66cSDaniel Drake 2350c4cfe66cSDaniel Drake /* switch to DC input */ 2351c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_CONNECT_SEL, 3}, 2352c4cfe66cSDaniel Drake {} 2353c4cfe66cSDaniel Drake }; 2354c4cfe66cSDaniel Drake 2355c4cfe66cSDaniel Drake /* configure as input source */ 2356c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2357c4cfe66cSDaniel Drake cxt5066_olpc_select_mic(codec); /* also sets configured bias */ 2358c4cfe66cSDaniel Drake } 2359c4cfe66cSDaniel Drake 2360c4cfe66cSDaniel Drake static void cxt5066_disable_dc(struct hda_codec *codec) 2361c4cfe66cSDaniel Drake { 2362c4cfe66cSDaniel Drake /* reconfigure input source */ 2363c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2364c4cfe66cSDaniel Drake /* automic also selects the right mic if we're recording */ 2365c4cfe66cSDaniel Drake cxt5066_olpc_automic(codec); 2366c4cfe66cSDaniel Drake } 2367c4cfe66cSDaniel Drake 2368c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, 2369c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2370c4cfe66cSDaniel Drake { 2371c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2372c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2373c4cfe66cSDaniel Drake ucontrol->value.integer.value[0] = spec->dc_enable; 2374c4cfe66cSDaniel Drake return 0; 2375c4cfe66cSDaniel Drake } 2376c4cfe66cSDaniel Drake 2377c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, 2378c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2379c4cfe66cSDaniel Drake { 2380c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2381c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2382c4cfe66cSDaniel Drake int dc_enable = !!ucontrol->value.integer.value[0]; 2383c4cfe66cSDaniel Drake 2384c4cfe66cSDaniel Drake if (dc_enable == spec->dc_enable) 2385c4cfe66cSDaniel Drake return 0; 2386c4cfe66cSDaniel Drake 2387c4cfe66cSDaniel Drake spec->dc_enable = dc_enable; 2388c4cfe66cSDaniel Drake if (dc_enable) 2389c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2390c4cfe66cSDaniel Drake else 2391c4cfe66cSDaniel Drake cxt5066_disable_dc(codec); 2392c4cfe66cSDaniel Drake 2393c4cfe66cSDaniel Drake return 1; 2394c4cfe66cSDaniel Drake } 2395c4cfe66cSDaniel Drake 2396c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 2397c4cfe66cSDaniel Drake struct snd_ctl_elem_info *uinfo) 2398c4cfe66cSDaniel Drake { 2399c4cfe66cSDaniel Drake return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); 2400c4cfe66cSDaniel Drake } 2401c4cfe66cSDaniel Drake 2402c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 2403c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2404c4cfe66cSDaniel Drake { 2405c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2406c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2407c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 2408c4cfe66cSDaniel Drake return 0; 2409c4cfe66cSDaniel Drake } 2410c4cfe66cSDaniel Drake 2411c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 2412c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2413c4cfe66cSDaniel Drake { 2414c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2415c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2416c4cfe66cSDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2417c4cfe66cSDaniel Drake unsigned int idx; 2418c4cfe66cSDaniel Drake 2419c4cfe66cSDaniel Drake idx = ucontrol->value.enumerated.item[0]; 2420c4cfe66cSDaniel Drake if (idx >= imux->num_items) 2421c4cfe66cSDaniel Drake idx = imux->num_items - 1; 2422c4cfe66cSDaniel Drake 2423c4cfe66cSDaniel Drake spec->dc_input_bias = idx; 2424c4cfe66cSDaniel Drake if (spec->dc_enable) 2425c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 24260fb67e98SDaniel Drake return 1; 24270fb67e98SDaniel Drake } 24280fb67e98SDaniel Drake 242975f8991dSDaniel Drake static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) 243075f8991dSDaniel Drake { 243175f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 243275f8991dSDaniel Drake /* mark as recording and configure the microphone widget so that the 243375f8991dSDaniel Drake * recording LED comes on. */ 243475f8991dSDaniel Drake spec->recording = 1; 243575f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 243675f8991dSDaniel Drake } 243775f8991dSDaniel Drake 243875f8991dSDaniel Drake static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) 243975f8991dSDaniel Drake { 244075f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 244175f8991dSDaniel Drake const struct hda_verb disable_mics[] = { 244275f8991dSDaniel Drake /* disable external mic, port B */ 244375f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 244475f8991dSDaniel Drake 244575f8991dSDaniel Drake /* disble internal mic, port C */ 244675f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2447c4cfe66cSDaniel Drake 2448c4cfe66cSDaniel Drake /* disable DC capture, port F */ 2449c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 245075f8991dSDaniel Drake {}, 245175f8991dSDaniel Drake }; 245275f8991dSDaniel Drake 245375f8991dSDaniel Drake snd_hda_sequence_write(codec, disable_mics); 245475f8991dSDaniel Drake spec->recording = 0; 245575f8991dSDaniel Drake } 245675f8991dSDaniel Drake 2457f6a2491cSAndy Robinson static void conexant_check_dig_outs(struct hda_codec *codec, 245834cbe3a6STakashi Iwai const hda_nid_t *dig_pins, 2459f6a2491cSAndy Robinson int num_pins) 2460f6a2491cSAndy Robinson { 2461f6a2491cSAndy Robinson struct conexant_spec *spec = codec->spec; 2462f6a2491cSAndy Robinson hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; 2463f6a2491cSAndy Robinson int i; 2464f6a2491cSAndy Robinson 2465f6a2491cSAndy Robinson for (i = 0; i < num_pins; i++, dig_pins++) { 2466f6a2491cSAndy Robinson unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); 2467f6a2491cSAndy Robinson if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) 2468f6a2491cSAndy Robinson continue; 2469f6a2491cSAndy Robinson if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) 2470f6a2491cSAndy Robinson continue; 2471f6a2491cSAndy Robinson } 2472f6a2491cSAndy Robinson } 2473f6a2491cSAndy Robinson 247434cbe3a6STakashi Iwai static const struct hda_input_mux cxt5066_capture_source = { 24750fb67e98SDaniel Drake .num_items = 4, 24760fb67e98SDaniel Drake .items = { 24770fb67e98SDaniel Drake { "Mic B", 0 }, 24780fb67e98SDaniel Drake { "Mic C", 1 }, 24790fb67e98SDaniel Drake { "Mic E", 2 }, 24800fb67e98SDaniel Drake { "Mic F", 3 }, 24810fb67e98SDaniel Drake }, 24820fb67e98SDaniel Drake }; 24830fb67e98SDaniel Drake 248434cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { 24850fb67e98SDaniel Drake .ops = &snd_hda_bind_vol, 24860fb67e98SDaniel Drake .values = { 24870fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24880fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24890fb67e98SDaniel Drake 0 24900fb67e98SDaniel Drake }, 24910fb67e98SDaniel Drake }; 24920fb67e98SDaniel Drake 249334cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { 24940fb67e98SDaniel Drake .ops = &snd_hda_bind_sw, 24950fb67e98SDaniel Drake .values = { 24960fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24970fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24980fb67e98SDaniel Drake 0 24990fb67e98SDaniel Drake }, 25000fb67e98SDaniel Drake }; 25010fb67e98SDaniel Drake 250234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master[] = { 25030fb67e98SDaniel Drake HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 25040fb67e98SDaniel Drake {} 25050fb67e98SDaniel Drake }; 25060fb67e98SDaniel Drake 250734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { 25080fb67e98SDaniel Drake { 25090fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25100fb67e98SDaniel Drake .name = "Master Playback Volume", 25110fb67e98SDaniel Drake .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 25120fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_READ | 25130fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, 25145e26dfd0SJaroslav Kysela .subdevice = HDA_SUBDEV_AMP_FLAG, 25150fb67e98SDaniel Drake .info = snd_hda_mixer_amp_volume_info, 25160fb67e98SDaniel Drake .get = snd_hda_mixer_amp_volume_get, 25170fb67e98SDaniel Drake .put = snd_hda_mixer_amp_volume_put, 25180fb67e98SDaniel Drake .tlv = { .c = snd_hda_mixer_amp_tlv }, 25190fb67e98SDaniel Drake /* offset by 28 volume steps to limit minimum gain to -46dB */ 25200fb67e98SDaniel Drake .private_value = 25210fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), 25220fb67e98SDaniel Drake }, 25230fb67e98SDaniel Drake {} 25240fb67e98SDaniel Drake }; 25250fb67e98SDaniel Drake 252634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { 2527c4cfe66cSDaniel Drake { 2528c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2529c4cfe66cSDaniel Drake .name = "DC Mode Enable Switch", 2530c4cfe66cSDaniel Drake .info = snd_ctl_boolean_mono_info, 2531c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_get, 2532c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_put, 2533c4cfe66cSDaniel Drake }, 2534c4cfe66cSDaniel Drake { 2535c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2536c4cfe66cSDaniel Drake .name = "DC Input Bias Enum", 2537c4cfe66cSDaniel Drake .info = cxt5066_olpc_dc_bias_enum_info, 2538c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_bias_enum_get, 2539c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_bias_enum_put, 2540c4cfe66cSDaniel Drake }, 2541c4cfe66cSDaniel Drake {} 2542c4cfe66cSDaniel Drake }; 2543c4cfe66cSDaniel Drake 254434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixers[] = { 25450fb67e98SDaniel Drake { 25460fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25470fb67e98SDaniel Drake .name = "Master Playback Switch", 25480fb67e98SDaniel Drake .info = cxt_eapd_info, 25490fb67e98SDaniel Drake .get = cxt_eapd_get, 25500fb67e98SDaniel Drake .put = cxt5066_hp_master_sw_put, 25510fb67e98SDaniel Drake .private_value = 0x1d, 25520fb67e98SDaniel Drake }, 25530fb67e98SDaniel Drake 25540fb67e98SDaniel Drake { 25550fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2556c4cfe66cSDaniel Drake .name = "Analog Mic Boost Capture Enum", 25570fb67e98SDaniel Drake .info = cxt5066_mic_boost_mux_enum_info, 25580fb67e98SDaniel Drake .get = cxt5066_mic_boost_mux_enum_get, 25590fb67e98SDaniel Drake .put = cxt5066_mic_boost_mux_enum_put, 25600fb67e98SDaniel Drake }, 25610fb67e98SDaniel Drake 25620fb67e98SDaniel Drake HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), 25630fb67e98SDaniel Drake HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), 25640fb67e98SDaniel Drake {} 25650fb67e98SDaniel Drake }; 25660fb67e98SDaniel Drake 256734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { 2568254bba6aSEinar Rünkaru { 2569254bba6aSEinar Rünkaru .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 257028c4edb7SDavid Henningsson .name = "Internal Mic Boost Capture Enum", 2571254bba6aSEinar Rünkaru .info = cxt5066_mic_boost_mux_enum_info, 2572254bba6aSEinar Rünkaru .get = cxt5066_mic_boost_mux_enum_get, 2573254bba6aSEinar Rünkaru .put = cxt5066_mic_boost_mux_enum_put, 2574254bba6aSEinar Rünkaru .private_value = 0x23 | 0x100, 2575254bba6aSEinar Rünkaru }, 2576254bba6aSEinar Rünkaru {} 2577254bba6aSEinar Rünkaru }; 2578254bba6aSEinar Rünkaru 257934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs[] = { 25800fb67e98SDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 25810fb67e98SDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 25820fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 25830fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 25840fb67e98SDaniel Drake 25850fb67e98SDaniel Drake /* Speakers */ 25860fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 25870fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25880fb67e98SDaniel Drake 25890fb67e98SDaniel Drake /* HP, Amp */ 25900fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25910fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25920fb67e98SDaniel Drake 25930fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25940fb67e98SDaniel Drake {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25950fb67e98SDaniel Drake 25960fb67e98SDaniel Drake /* DAC1 */ 25970fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 25980fb67e98SDaniel Drake 25990fb67e98SDaniel Drake /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 26000fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26010fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26020fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 26030fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26040fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 26050fb67e98SDaniel Drake 26060fb67e98SDaniel Drake /* no digital microphone support yet */ 26070fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26080fb67e98SDaniel Drake 26090fb67e98SDaniel Drake /* Audio input selector */ 26100fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26110fb67e98SDaniel Drake 26120fb67e98SDaniel Drake /* SPDIF route: PCM */ 26130fb67e98SDaniel Drake {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 26140fb67e98SDaniel Drake {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 26150fb67e98SDaniel Drake 26160fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26170fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26180fb67e98SDaniel Drake 26190fb67e98SDaniel Drake /* EAPD */ 26200fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26210fb67e98SDaniel Drake 26220fb67e98SDaniel Drake /* not handling these yet */ 26230fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26240fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26250fb67e98SDaniel Drake {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26260fb67e98SDaniel Drake {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26270fb67e98SDaniel Drake {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26280fb67e98SDaniel Drake {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26290fb67e98SDaniel Drake {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26300fb67e98SDaniel Drake {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26310fb67e98SDaniel Drake { } /* end */ 26320fb67e98SDaniel Drake }; 26330fb67e98SDaniel Drake 263434cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_olpc[] = { 26350fb67e98SDaniel Drake /* Port A: headphones */ 26360fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 26370fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26380fb67e98SDaniel Drake 26390fb67e98SDaniel Drake /* Port B: external microphone */ 264075f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26410fb67e98SDaniel Drake 26420fb67e98SDaniel Drake /* Port C: internal microphone */ 264375f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26440fb67e98SDaniel Drake 26450fb67e98SDaniel Drake /* Port D: unused */ 26460fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26470fb67e98SDaniel Drake 26480fb67e98SDaniel Drake /* Port E: unused, but has primary EAPD */ 26490fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26500fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26510fb67e98SDaniel Drake 2652c4cfe66cSDaniel Drake /* Port F: external DC input through microphone port */ 26530fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26540fb67e98SDaniel Drake 26550fb67e98SDaniel Drake /* Port G: internal speakers */ 26560fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26570fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26580fb67e98SDaniel Drake 26590fb67e98SDaniel Drake /* DAC1 */ 26600fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 26610fb67e98SDaniel Drake 26620fb67e98SDaniel Drake /* DAC2: unused */ 26630fb67e98SDaniel Drake {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 26640fb67e98SDaniel Drake 26650fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26660fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26670fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26680fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26690fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26700fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26710fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26720fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26730fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26740fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26750fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26760fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26770fb67e98SDaniel Drake 26780fb67e98SDaniel Drake /* Disable digital microphone port */ 26790fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26800fb67e98SDaniel Drake 26810fb67e98SDaniel Drake /* Audio input selectors */ 26820fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26830fb67e98SDaniel Drake {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 26840fb67e98SDaniel Drake 26850fb67e98SDaniel Drake /* Disable SPDIF */ 26860fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26870fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26880fb67e98SDaniel Drake 26890fb67e98SDaniel Drake /* enable unsolicited events for Port A and B */ 26900fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 26910fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 26920fb67e98SDaniel Drake { } /* end */ 26930fb67e98SDaniel Drake }; 26940fb67e98SDaniel Drake 269534cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_vostro[] = { 269695a618bdSEinar Rünkaru /* Port A: headphones */ 269795a618bdSEinar Rünkaru {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 269895a618bdSEinar Rünkaru {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 269995a618bdSEinar Rünkaru 270095a618bdSEinar Rünkaru /* Port B: external microphone */ 270195a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270295a618bdSEinar Rünkaru 270395a618bdSEinar Rünkaru /* Port C: unused */ 270495a618bdSEinar Rünkaru {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270595a618bdSEinar Rünkaru 270695a618bdSEinar Rünkaru /* Port D: unused */ 270795a618bdSEinar Rünkaru {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270895a618bdSEinar Rünkaru 270995a618bdSEinar Rünkaru /* Port E: unused, but has primary EAPD */ 271095a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271195a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 271295a618bdSEinar Rünkaru 271395a618bdSEinar Rünkaru /* Port F: unused */ 271495a618bdSEinar Rünkaru {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271595a618bdSEinar Rünkaru 271695a618bdSEinar Rünkaru /* Port G: internal speakers */ 271795a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 271895a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 271995a618bdSEinar Rünkaru 272095a618bdSEinar Rünkaru /* DAC1 */ 272195a618bdSEinar Rünkaru {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 272295a618bdSEinar Rünkaru 272395a618bdSEinar Rünkaru /* DAC2: unused */ 272495a618bdSEinar Rünkaru {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 272595a618bdSEinar Rünkaru 272695a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 272795a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 272895a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 272995a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273095a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273195a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273295a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273395a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273495a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273595a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273695a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273795a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273895a618bdSEinar Rünkaru 273995a618bdSEinar Rünkaru /* Digital microphone port */ 274095a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 274195a618bdSEinar Rünkaru 274295a618bdSEinar Rünkaru /* Audio input selectors */ 274395a618bdSEinar Rünkaru {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 274495a618bdSEinar Rünkaru {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 274595a618bdSEinar Rünkaru 274695a618bdSEinar Rünkaru /* Disable SPDIF */ 274795a618bdSEinar Rünkaru {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274895a618bdSEinar Rünkaru {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274995a618bdSEinar Rünkaru 275095a618bdSEinar Rünkaru /* enable unsolicited events for Port A and B */ 275195a618bdSEinar Rünkaru {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 275295a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 275395a618bdSEinar Rünkaru { } /* end */ 275495a618bdSEinar Rünkaru }; 275595a618bdSEinar Rünkaru 275634cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_ideapad[] = { 2757cfd3d8dcSGreg Alexander {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 2758cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 2759cfd3d8dcSGreg Alexander {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 2760cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 2761cfd3d8dcSGreg Alexander 2762cfd3d8dcSGreg Alexander /* Speakers */ 2763cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2764cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2765cfd3d8dcSGreg Alexander 2766cfd3d8dcSGreg Alexander /* HP, Amp */ 2767cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2768cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2769cfd3d8dcSGreg Alexander 2770cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2771cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2772cfd3d8dcSGreg Alexander 2773cfd3d8dcSGreg Alexander /* DAC1 */ 2774cfd3d8dcSGreg Alexander {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2775cfd3d8dcSGreg Alexander 2776cfd3d8dcSGreg Alexander /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 2777cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 2778cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2779cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 2780cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2781cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2782cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 2783cfd3d8dcSGreg Alexander 2784cfd3d8dcSGreg Alexander /* Audio input selector */ 2785cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 2786cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 2787cfd3d8dcSGreg Alexander 2788cfd3d8dcSGreg Alexander /* SPDIF route: PCM */ 2789cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 2790cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 2791cfd3d8dcSGreg Alexander 2792cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2793cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2794cfd3d8dcSGreg Alexander 2795cfd3d8dcSGreg Alexander /* internal microphone */ 279628c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 2797cfd3d8dcSGreg Alexander 2798cfd3d8dcSGreg Alexander /* EAPD */ 2799cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2800cfd3d8dcSGreg Alexander 2801cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2802cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2803cfd3d8dcSGreg Alexander { } /* end */ 2804cfd3d8dcSGreg Alexander }; 2805cfd3d8dcSGreg Alexander 280634cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { 28077b2bfdbcSJens Taprogge {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 28087b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 28097b2bfdbcSJens Taprogge 28107b2bfdbcSJens Taprogge /* Port G: internal speakers */ 28117b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28127b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28137b2bfdbcSJens Taprogge 28147b2bfdbcSJens Taprogge /* Port A: HP, Amp */ 28157b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28167b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28177b2bfdbcSJens Taprogge 28187b2bfdbcSJens Taprogge /* Port B: Mic Dock */ 28197b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28207b2bfdbcSJens Taprogge 28217b2bfdbcSJens Taprogge /* Port C: Mic */ 28227b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28237b2bfdbcSJens Taprogge 28247b2bfdbcSJens Taprogge /* Port D: HP Dock, Amp */ 28257b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28267b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28277b2bfdbcSJens Taprogge 28287b2bfdbcSJens Taprogge /* DAC1 */ 28297b2bfdbcSJens Taprogge {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 28307b2bfdbcSJens Taprogge 28317b2bfdbcSJens Taprogge /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 28327b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 28337b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 28347b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 28357b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 28367b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 28377b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 28387b2bfdbcSJens Taprogge 28397b2bfdbcSJens Taprogge /* Audio input selector */ 28407b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 28417b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 28427b2bfdbcSJens Taprogge 28437b2bfdbcSJens Taprogge /* SPDIF route: PCM */ 28447b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 28457b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 28467b2bfdbcSJens Taprogge 28477b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28487b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28497b2bfdbcSJens Taprogge 28507b2bfdbcSJens Taprogge /* internal microphone */ 285128c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 28527b2bfdbcSJens Taprogge 28537b2bfdbcSJens Taprogge /* EAPD */ 28547b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 28557b2bfdbcSJens Taprogge 28567b2bfdbcSJens Taprogge /* enable unsolicited events for Port A, B, C and D */ 28577b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28587b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28597b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28607b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28617b2bfdbcSJens Taprogge { } /* end */ 28627b2bfdbcSJens Taprogge }; 28637b2bfdbcSJens Taprogge 286434cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { 28650fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28660fb67e98SDaniel Drake { } /* end */ 28670fb67e98SDaniel Drake }; 28680fb67e98SDaniel Drake 2869048e78a5SDavid Henningsson 287034cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { 2871048e78a5SDavid Henningsson {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, 2872048e78a5SDavid Henningsson {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2873048e78a5SDavid Henningsson {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2874048e78a5SDavid Henningsson { } /* end */ 2875048e78a5SDavid Henningsson }; 2876048e78a5SDavid Henningsson 28770fb67e98SDaniel Drake /* initialize jack-sensing, too */ 28780fb67e98SDaniel Drake static int cxt5066_init(struct hda_codec *codec) 28790fb67e98SDaniel Drake { 28800fb67e98SDaniel Drake snd_printdd("CXT5066: init\n"); 28810fb67e98SDaniel Drake conexant_init(codec); 28820fb67e98SDaniel Drake if (codec->patch_ops.unsol_event) { 28830fb67e98SDaniel Drake cxt5066_hp_automute(codec); 288402b6b5b6SDavid Henningsson cxt5066_automic(codec); 28850fb67e98SDaniel Drake } 2886c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 28870fb67e98SDaniel Drake return 0; 28880fb67e98SDaniel Drake } 28890fb67e98SDaniel Drake 289075f8991dSDaniel Drake static int cxt5066_olpc_init(struct hda_codec *codec) 289175f8991dSDaniel Drake { 2892c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 289375f8991dSDaniel Drake snd_printdd("CXT5066: init\n"); 289475f8991dSDaniel Drake conexant_init(codec); 289575f8991dSDaniel Drake cxt5066_hp_automute(codec); 2896c4cfe66cSDaniel Drake if (!spec->dc_enable) { 2897c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 289875f8991dSDaniel Drake cxt5066_olpc_automic(codec); 2899c4cfe66cSDaniel Drake } else { 2900c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2901c4cfe66cSDaniel Drake } 290275f8991dSDaniel Drake return 0; 290375f8991dSDaniel Drake } 290475f8991dSDaniel Drake 29050fb67e98SDaniel Drake enum { 29060fb67e98SDaniel Drake CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 29070fb67e98SDaniel Drake CXT5066_DELL_LAPTOP, /* Dell Laptop */ 29080fb67e98SDaniel Drake CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ 29091feba3b7SDavid Henningsson CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2910cfd3d8dcSGreg Alexander CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 29117b2bfdbcSJens Taprogge CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2912a1d6906eSDavid Henningsson CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ 2913048e78a5SDavid Henningsson CXT5066_HP_LAPTOP, /* HP Laptop */ 2914fea4a4f9STakashi Iwai CXT5066_AUTO, /* BIOS auto-parser */ 29150fb67e98SDaniel Drake CXT5066_MODELS 29160fb67e98SDaniel Drake }; 29170fb67e98SDaniel Drake 2918ea734963STakashi Iwai static const char * const cxt5066_models[CXT5066_MODELS] = { 29190fb67e98SDaniel Drake [CXT5066_LAPTOP] = "laptop", 29200fb67e98SDaniel Drake [CXT5066_DELL_LAPTOP] = "dell-laptop", 29210fb67e98SDaniel Drake [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", 29221feba3b7SDavid Henningsson [CXT5066_DELL_VOSTRO] = "dell-vostro", 2923cfd3d8dcSGreg Alexander [CXT5066_IDEAPAD] = "ideapad", 29247b2bfdbcSJens Taprogge [CXT5066_THINKPAD] = "thinkpad", 2925a1d6906eSDavid Henningsson [CXT5066_ASUS] = "asus", 2926048e78a5SDavid Henningsson [CXT5066_HP_LAPTOP] = "hp-laptop", 2927fea4a4f9STakashi Iwai [CXT5066_AUTO] = "auto", 29280fb67e98SDaniel Drake }; 29290fb67e98SDaniel Drake 293034cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { 293100cd0bb7STakashi Iwai SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 29321feba3b7SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 29338a96b1e0SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), 2934ca6cd851SDaniel T Chen SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2935231f50bcSAnisse Astier SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2936ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2937ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), 2938048e78a5SDavid Henningsson SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2939f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2940a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2941f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 29422ca9cac9SAnisse Astier SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 2943c5366681SDaniel T Chen SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 29445637edb2SDavid Henningsson SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 29455637edb2SDavid Henningsson CXT5066_LAPTOP), 29465637edb2SDavid Henningsson SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 29474d155641STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2948ef61d4e6SManoj Iyer SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 294919593875SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 2950b2cb1292SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), 2951d2859fd4SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), 2952a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), 29530fb67e98SDaniel Drake {} 29540fb67e98SDaniel Drake }; 29550fb67e98SDaniel Drake 29560fb67e98SDaniel Drake static int patch_cxt5066(struct hda_codec *codec) 29570fb67e98SDaniel Drake { 29580fb67e98SDaniel Drake struct conexant_spec *spec; 29590fb67e98SDaniel Drake int board_config; 29600fb67e98SDaniel Drake 2961fea4a4f9STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, 2962fea4a4f9STakashi Iwai cxt5066_models, cxt5066_cfg_tbl); 2963fea4a4f9STakashi Iwai if (board_config < 0) 2964c82693dbSTakashi Iwai board_config = CXT5066_AUTO; /* model=auto as default */ 2965fea4a4f9STakashi Iwai if (board_config == CXT5066_AUTO) 2966fea4a4f9STakashi Iwai return patch_conexant_auto(codec); 2967fea4a4f9STakashi Iwai 29680fb67e98SDaniel Drake spec = kzalloc(sizeof(*spec), GFP_KERNEL); 29690fb67e98SDaniel Drake if (!spec) 29700fb67e98SDaniel Drake return -ENOMEM; 29710fb67e98SDaniel Drake codec->spec = spec; 29720fb67e98SDaniel Drake 29730fb67e98SDaniel Drake codec->patch_ops = conexant_patch_ops; 297475f8991dSDaniel Drake codec->patch_ops.init = conexant_init; 29750fb67e98SDaniel Drake 29760fb67e98SDaniel Drake spec->dell_automute = 0; 29770fb67e98SDaniel Drake spec->multiout.max_channels = 2; 29780fb67e98SDaniel Drake spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); 29790fb67e98SDaniel Drake spec->multiout.dac_nids = cxt5066_dac_nids; 2980f6a2491cSAndy Robinson conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, 2981f6a2491cSAndy Robinson ARRAY_SIZE(cxt5066_digout_pin_nids)); 29820fb67e98SDaniel Drake spec->num_adc_nids = 1; 29830fb67e98SDaniel Drake spec->adc_nids = cxt5066_adc_nids; 29840fb67e98SDaniel Drake spec->capsrc_nids = cxt5066_capsrc_nids; 29850fb67e98SDaniel Drake spec->input_mux = &cxt5066_capture_source; 29860fb67e98SDaniel Drake 29870fb67e98SDaniel Drake spec->port_d_mode = PIN_HP; 29880fb67e98SDaniel Drake 29890fb67e98SDaniel Drake spec->num_init_verbs = 1; 29900fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs; 29910fb67e98SDaniel Drake spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); 29920fb67e98SDaniel Drake spec->channel_mode = cxt5066_modes; 29930fb67e98SDaniel Drake spec->cur_adc = 0; 29940fb67e98SDaniel Drake spec->cur_adc_idx = 0; 29950fb67e98SDaniel Drake 29963507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 29973507e2a8STakashi Iwai 29980fb67e98SDaniel Drake switch (board_config) { 29990fb67e98SDaniel Drake default: 30000fb67e98SDaniel Drake case CXT5066_LAPTOP: 30010fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30020fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30030fb67e98SDaniel Drake break; 30040fb67e98SDaniel Drake case CXT5066_DELL_LAPTOP: 30050fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30060fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30070fb67e98SDaniel Drake 30080fb67e98SDaniel Drake spec->port_d_mode = PIN_OUT; 30090fb67e98SDaniel Drake spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; 30100fb67e98SDaniel Drake spec->num_init_verbs++; 30110fb67e98SDaniel Drake spec->dell_automute = 1; 30120fb67e98SDaniel Drake break; 3013a1d6906eSDavid Henningsson case CXT5066_ASUS: 3014048e78a5SDavid Henningsson case CXT5066_HP_LAPTOP: 3015048e78a5SDavid Henningsson codec->patch_ops.init = cxt5066_init; 301602b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3017048e78a5SDavid Henningsson spec->init_verbs[spec->num_init_verbs] = 3018048e78a5SDavid Henningsson cxt5066_init_verbs_hp_laptop; 3019048e78a5SDavid Henningsson spec->num_init_verbs++; 3020a1d6906eSDavid Henningsson spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; 3021a1d6906eSDavid Henningsson spec->asus = board_config == CXT5066_ASUS; 3022048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3023048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3024048e78a5SDavid Henningsson /* no S/PDIF out */ 3025f6a2491cSAndy Robinson if (board_config == CXT5066_HP_LAPTOP) 3026048e78a5SDavid Henningsson spec->multiout.dig_out_nid = 0; 3027048e78a5SDavid Henningsson /* input source automatically selected */ 3028048e78a5SDavid Henningsson spec->input_mux = NULL; 3029048e78a5SDavid Henningsson spec->port_d_mode = 0; 3030048e78a5SDavid Henningsson spec->mic_boost = 3; /* default 30dB gain */ 3031048e78a5SDavid Henningsson break; 3032048e78a5SDavid Henningsson 30330fb67e98SDaniel Drake case CXT5066_OLPC_XO_1_5: 303475f8991dSDaniel Drake codec->patch_ops.init = cxt5066_olpc_init; 303575f8991dSDaniel Drake codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; 30360fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs_olpc; 30370fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 3038c4cfe66cSDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; 30390fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30400fb67e98SDaniel Drake spec->port_d_mode = 0; 3041c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 30420fb67e98SDaniel Drake 30430fb67e98SDaniel Drake /* no S/PDIF out */ 30440fb67e98SDaniel Drake spec->multiout.dig_out_nid = 0; 30450fb67e98SDaniel Drake 30460fb67e98SDaniel Drake /* input source automatically selected */ 30470fb67e98SDaniel Drake spec->input_mux = NULL; 304875f8991dSDaniel Drake 304975f8991dSDaniel Drake /* our capture hooks which allow us to turn on the microphone LED 305075f8991dSDaniel Drake * at the right time */ 305175f8991dSDaniel Drake spec->capture_prepare = cxt5066_olpc_capture_prepare; 305275f8991dSDaniel Drake spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 30530fb67e98SDaniel Drake break; 30541feba3b7SDavid Henningsson case CXT5066_DELL_VOSTRO: 305575f8991dSDaniel Drake codec->patch_ops.init = cxt5066_init; 305602b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 305795a618bdSEinar Rünkaru spec->init_verbs[0] = cxt5066_init_verbs_vostro; 305895a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 305995a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3060254bba6aSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 306195a618bdSEinar Rünkaru spec->port_d_mode = 0; 3062254bba6aSEinar Rünkaru spec->dell_vostro = 1; 3063c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 306495a618bdSEinar Rünkaru 306595a618bdSEinar Rünkaru /* no S/PDIF out */ 306695a618bdSEinar Rünkaru spec->multiout.dig_out_nid = 0; 306795a618bdSEinar Rünkaru 306895a618bdSEinar Rünkaru /* input source automatically selected */ 306995a618bdSEinar Rünkaru spec->input_mux = NULL; 307095a618bdSEinar Rünkaru break; 3071cfd3d8dcSGreg Alexander case CXT5066_IDEAPAD: 3072cfd3d8dcSGreg Alexander codec->patch_ops.init = cxt5066_init; 307302b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3074cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3075cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3076cfd3d8dcSGreg Alexander spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 3077cfd3d8dcSGreg Alexander spec->port_d_mode = 0; 3078cfd3d8dcSGreg Alexander spec->ideapad = 1; 3079cfd3d8dcSGreg Alexander spec->mic_boost = 2; /* default 20dB gain */ 3080cfd3d8dcSGreg Alexander 3081cfd3d8dcSGreg Alexander /* no S/PDIF out */ 3082cfd3d8dcSGreg Alexander spec->multiout.dig_out_nid = 0; 3083cfd3d8dcSGreg Alexander 3084cfd3d8dcSGreg Alexander /* input source automatically selected */ 3085cfd3d8dcSGreg Alexander spec->input_mux = NULL; 3086cfd3d8dcSGreg Alexander break; 30877b2bfdbcSJens Taprogge case CXT5066_THINKPAD: 30887b2bfdbcSJens Taprogge codec->patch_ops.init = cxt5066_init; 308902b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 30907b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30917b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30927b2bfdbcSJens Taprogge spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 30937b2bfdbcSJens Taprogge spec->thinkpad = 1; 30947b2bfdbcSJens Taprogge spec->port_d_mode = PIN_OUT; 30957b2bfdbcSJens Taprogge spec->mic_boost = 2; /* default 20dB gain */ 30967b2bfdbcSJens Taprogge 30977b2bfdbcSJens Taprogge /* no S/PDIF out */ 30987b2bfdbcSJens Taprogge spec->multiout.dig_out_nid = 0; 30997b2bfdbcSJens Taprogge 31007b2bfdbcSJens Taprogge /* input source automatically selected */ 31017b2bfdbcSJens Taprogge spec->input_mux = NULL; 31027b2bfdbcSJens Taprogge break; 31030fb67e98SDaniel Drake } 31040fb67e98SDaniel Drake 31053507e2a8STakashi Iwai if (spec->beep_amp) 3106a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 31073507e2a8STakashi Iwai 31080fb67e98SDaniel Drake return 0; 31090fb67e98SDaniel Drake } 3110461e2c78STakashi Iwai 3111bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 3112bf92d1d5STakashi Iwai 3113bf92d1d5STakashi Iwai 3114461e2c78STakashi Iwai /* 3115f2e5731dSTakashi Iwai * Automatic parser for CX20641 & co 3116f2e5731dSTakashi Iwai */ 3117f2e5731dSTakashi Iwai 3118f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 3119f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec) 3120f2e5731dSTakashi Iwai { 3121f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 3122f2e5731dSTakashi Iwai hda_nid_t nid, end_nid; 3123f2e5731dSTakashi Iwai 3124f2e5731dSTakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 3125f2e5731dSTakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) 3126f2e5731dSTakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 3127f2e5731dSTakashi Iwai set_beep_amp(spec, nid, 0, HDA_OUTPUT); 3128f2e5731dSTakashi Iwai break; 3129f2e5731dSTakashi Iwai } 3130f2e5731dSTakashi Iwai } 3131f2e5731dSTakashi Iwai #else 3132f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec) 3133f2e5731dSTakashi Iwai #endif 3134f2e5731dSTakashi Iwai 3135254f2968STakashi Iwai /* parse EAPDs */ 313619110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 313719110595STakashi Iwai { 313819110595STakashi Iwai struct conexant_spec *spec = codec->spec; 313919110595STakashi Iwai hda_nid_t nid, end_nid; 314019110595STakashi Iwai 314119110595STakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 314219110595STakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) { 314319110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 314419110595STakashi Iwai continue; 314519110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 314619110595STakashi Iwai continue; 314719110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 314819110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 314919110595STakashi Iwai break; 315019110595STakashi Iwai } 3151254f2968STakashi Iwai 3152254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 3153254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 3154254f2968STakashi Iwai * pins, and we can control EAPD per pin. 3155254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 3156254f2968STakashi Iwai * thus it might control over all pins. 3157254f2968STakashi Iwai */ 3158aed523f1STakashi Iwai if (spec->num_eapds > 2) 3159*ff359b14STakashi Iwai spec->dynamic_eapd = 1; 3160f2e5731dSTakashi Iwai } 3161f2e5731dSTakashi Iwai 3162da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 3163da339866STakashi Iwai hda_nid_t *pins, bool on) 3164f2e5731dSTakashi Iwai { 3165f2e5731dSTakashi Iwai int i; 3166f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 3167f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 3168f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 3169da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 3170da339866STakashi Iwai on ? 0x02 : 0); 3171f2e5731dSTakashi Iwai } 3172f2e5731dSTakashi Iwai } 3173f2e5731dSTakashi Iwai 3174527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 3175527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 3176527c73baSTakashi Iwai { 3177527c73baSTakashi Iwai struct hda_codec *codec = private_data; 3178527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 3179527c73baSTakashi Iwai 3180527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 3181527c73baSTakashi Iwai } 3182527c73baSTakashi Iwai 3183f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec) 3184f2e5731dSTakashi Iwai { 3185f2e5731dSTakashi Iwai int err; 3186f2e5731dSTakashi Iwai 3187aed523f1STakashi Iwai err = snd_hda_gen_build_controls(codec); 3188f2e5731dSTakashi Iwai if (err < 0) 3189f2e5731dSTakashi Iwai return err; 3190f2e5731dSTakashi Iwai 3191aed523f1STakashi Iwai err = add_beep_ctls(codec); 3192aed523f1STakashi Iwai if (err < 0) 3193aed523f1STakashi Iwai return err; 319422ce5f74STakashi Iwai 319522ce5f74STakashi Iwai return 0; 319622ce5f74STakashi Iwai } 319722ce5f74STakashi Iwai 3198*ff359b14STakashi Iwai static int cx_auto_init(struct hda_codec *codec) 3199*ff359b14STakashi Iwai { 3200*ff359b14STakashi Iwai struct conexant_spec *spec = codec->spec; 3201*ff359b14STakashi Iwai snd_hda_gen_init(codec); 3202*ff359b14STakashi Iwai if (!spec->dynamic_eapd) 3203*ff359b14STakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); 3204*ff359b14STakashi Iwai return 0; 3205*ff359b14STakashi Iwai } 3206*ff359b14STakashi Iwai 320734cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 3208f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 3209aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 3210*ff359b14STakashi Iwai .init = cx_auto_init, 32117504b6cdSTakashi Iwai .free = snd_hda_gen_free, 321229adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 3213164a7adaSTakashi Iwai #ifdef CONFIG_PM 3214164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 3215164a7adaSTakashi Iwai #endif 3216f2e5731dSTakashi Iwai }; 3217f2e5731dSTakashi Iwai 3218e92d4b08STakashi Iwai /* 3219e92d4b08STakashi Iwai * pin fix-up 3220e92d4b08STakashi Iwai */ 322118dcd304SDavid Henningsson enum { 322218dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 3223d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 3224239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 3225239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 322618dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 3227239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 322818dcd304SDavid Henningsson }; 322918dcd304SDavid Henningsson 323023d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 323123d30f28STakashi Iwai const struct hda_fixup *fix, int action) 3232e92d4b08STakashi Iwai { 323318dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 3234aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 3235e92d4b08STakashi Iwai } 3236e92d4b08STakashi Iwai 3237239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 3238239fb862SHuacai Chen const struct hda_fixup *fix, int action) 3239239fb862SHuacai Chen { 3240239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 3241239fb862SHuacai Chen return; 3242239fb862SHuacai Chen 3243239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 3244239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 3245239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3246239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3247239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 3248239fb862SHuacai Chen } 3249239fb862SHuacai Chen 3250d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 325123d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3252e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3253e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3254e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 32553e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3256e92d4b08STakashi Iwai {} 3257e92d4b08STakashi Iwai }; 3258e92d4b08STakashi Iwai 3259d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 326023d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3261d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3262d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3263d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3264d70f3632STakashi Iwai {} 3265e92d4b08STakashi Iwai }; 3266e92d4b08STakashi Iwai 3267239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3268239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3269239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3270239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3271239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3272239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3273239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3274239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3275239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3276239fb862SHuacai Chen {} 3277239fb862SHuacai Chen }; 3278239fb862SHuacai Chen 327923d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 328023d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 328123d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 328223d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 328323d30f28STakashi Iwai }, 328423d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 328523d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 328623d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 328723d30f28STakashi Iwai }, 3288239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3289239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3290239fb862SHuacai Chen .chained = true, 3291239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3292239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3293239fb862SHuacai Chen }, 3294239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3295239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3296239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3297239fb862SHuacai Chen }, 329823d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 329923d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 330023d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 330123d30f28STakashi Iwai }, 3302239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3303239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3304239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3305239fb862SHuacai Chen }, 3306e92d4b08STakashi Iwai }; 3307e92d4b08STakashi Iwai 3308d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3309e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3310e92d4b08STakashi Iwai {} 3311e92d4b08STakashi Iwai }; 3312e92d4b08STakashi Iwai 3313d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 331463a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 3315d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3316d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3317d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3318d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3319d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 3320a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 332118dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3322e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3323b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 3324239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3325239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3326f2e5731dSTakashi Iwai {} 3327f2e5731dSTakashi Iwai }; 3328f2e5731dSTakashi Iwai 33293868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 33303868137eSTakashi Iwai * can be created (bko#42825) 33313868137eSTakashi Iwai */ 33323868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 33333868137eSTakashi Iwai { 33343868137eSTakashi Iwai static hda_nid_t out_nids[] = { 33353868137eSTakashi Iwai 0x10, 0x11, 0 33363868137eSTakashi Iwai }; 33373868137eSTakashi Iwai hda_nid_t *p; 33383868137eSTakashi Iwai 33393868137eSTakashi Iwai for (p = out_nids; *p; p++) 33403868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 33413868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 33423868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 33433868137eSTakashi Iwai } 33443868137eSTakashi Iwai 3345f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3346f2e5731dSTakashi Iwai { 3347f2e5731dSTakashi Iwai struct conexant_spec *spec; 3348f2e5731dSTakashi Iwai int err; 3349f2e5731dSTakashi Iwai 33501f8458a2STakashi Iwai printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 33511f8458a2STakashi Iwai codec->chip_name); 33521f8458a2STakashi Iwai 3353f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3354f2e5731dSTakashi Iwai if (!spec) 3355f2e5731dSTakashi Iwai return -ENOMEM; 3356aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3357f2e5731dSTakashi Iwai codec->spec = spec; 3358e92d4b08STakashi Iwai 3359aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3360aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3361*ff359b14STakashi Iwai spec->gen.own_eapd_ctl = 1; 3362*ff359b14STakashi Iwai if (spec->dynamic_eapd) 3363aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3364e92d4b08STakashi Iwai 33656b452142STakashi Iwai switch (codec->vendor_id) { 33666b452142STakashi Iwai case 0x14f15045: 33674f32456eSMichael Karcher codec->single_adc_amp = 1; 33686b452142STakashi Iwai break; 3369164a7adaSTakashi Iwai case 0x14f15047: 3370164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 3371164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 3372164a7adaSTakashi Iwai break; 33733868137eSTakashi Iwai case 0x14f15051: 33743868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 337551969d62SMichael Karcher codec->pin_amp_workaround = 1; 337623d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); 33773868137eSTakashi Iwai break; 337851969d62SMichael Karcher default: 337951969d62SMichael Karcher codec->pin_amp_workaround = 1; 338023d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); 338123d30f28STakashi Iwai break; 33826b452142STakashi Iwai } 33836b452142STakashi Iwai 3384f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3385f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3386f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3387f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3388f29735cbSTakashi Iwai * not good to expose it blindly. 3389527c73baSTakashi Iwai */ 3390f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3391f29735cbSTakashi Iwai case 0x103c: 3392aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3393f29735cbSTakashi Iwai break; 3394f29735cbSTakashi Iwai } 3395527c73baSTakashi Iwai 3396aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3397aed523f1STakashi Iwai 3398aed523f1STakashi Iwai err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); 339922ce5f74STakashi Iwai if (err < 0) 3400aed523f1STakashi Iwai goto error; 3401aed523f1STakashi Iwai 3402aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3403aed523f1STakashi Iwai if (err < 0) 3404aed523f1STakashi Iwai goto error; 3405aed523f1STakashi Iwai 3406f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 34074f2864a4STakashi Iwai 34084f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 34094f2864a4STakashi Iwai * which falls into the single-cmd mode. 34104f2864a4STakashi Iwai * Better to make reset, then. 34114f2864a4STakashi Iwai */ 34124f2864a4STakashi Iwai if (!codec->bus->sync_write) { 34134f2864a4STakashi Iwai snd_printd("hda_codec: " 34144f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 34154f2864a4STakashi Iwai codec->bus->sync_write = 1; 34164f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 34174f2864a4STakashi Iwai } 34184f2864a4STakashi Iwai 3419f2e5731dSTakashi Iwai return 0; 3420aed523f1STakashi Iwai 3421aed523f1STakashi Iwai error: 3422aed523f1STakashi Iwai snd_hda_gen_free(codec); 3423aed523f1STakashi Iwai return err; 3424f2e5731dSTakashi Iwai } 3425f2e5731dSTakashi Iwai 3426bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3427bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3428bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3429bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3430bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3431bf92d1d5STakashi Iwai #endif 3432bf92d1d5STakashi Iwai 3433f2e5731dSTakashi Iwai /* 3434461e2c78STakashi Iwai */ 3435461e2c78STakashi Iwai 343634cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 343782f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 343882f30040STobin Davis .patch = patch_cxt5045 }, 343982f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 344082f30040STobin Davis .patch = patch_cxt5047 }, 3441461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3442461e2c78STakashi Iwai .patch = patch_cxt5051 }, 34430fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 34440fb67e98SDaniel Drake .patch = patch_cxt5066 }, 344595a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 344695a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3447850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3448850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 34497b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 34507b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3451f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3452f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 34536da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 34546da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3455f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3456f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3457f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3458f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3459f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3460f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3461f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3462f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3463f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3464f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3465f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3466f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3467f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3468f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3469f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3470f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 34712d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 34722d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34732d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 34742d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34752d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 34762d825fd8STakashi Iwai .patch = patch_conexant_auto }, 347742c364acSTakashi Iwai { .id = 0x14f15113, .name = "CX20755", 347842c364acSTakashi Iwai .patch = patch_conexant_auto }, 347942c364acSTakashi Iwai { .id = 0x14f15114, .name = "CX20756", 348042c364acSTakashi Iwai .patch = patch_conexant_auto }, 348142c364acSTakashi Iwai { .id = 0x14f15115, .name = "CX20757", 348242c364acSTakashi Iwai .patch = patch_conexant_auto }, 3483c9b443d4STobin Davis {} /* terminator */ 3484c9b443d4STobin Davis }; 34851289e9e8STakashi Iwai 34861289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 34871289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 34881289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 34890fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 349095a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3491850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 34927b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3493f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 34946da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3495f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3496f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3497f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3498f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3499f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3500f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3501f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3502f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 35032d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 35042d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 35052d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 350642c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113"); 350742c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114"); 350842c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115"); 35091289e9e8STakashi Iwai 35101289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 35111289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 35121289e9e8STakashi Iwai 35131289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 35141289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 35151289e9e8STakashi Iwai .owner = THIS_MODULE, 35161289e9e8STakashi Iwai }; 35171289e9e8STakashi Iwai 35181289e9e8STakashi Iwai static int __init patch_conexant_init(void) 35191289e9e8STakashi Iwai { 35201289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 35211289e9e8STakashi Iwai } 35221289e9e8STakashi Iwai 35231289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 35241289e9e8STakashi Iwai { 35251289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 35261289e9e8STakashi Iwai } 35271289e9e8STakashi Iwai 35281289e9e8STakashi Iwai module_init(patch_conexant_init) 35291289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3530