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]; 67bf92d1d5STakashi Iwai 68bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 6934cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 70c9b443d4STobin Davis int num_mixers; 71dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 72c9b443d4STobin Davis 73c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 74c9b443d4STobin Davis * don't forget NULL 75c9b443d4STobin Davis * termination! 76c9b443d4STobin Davis */ 77c9b443d4STobin Davis unsigned int num_init_verbs; 78c9b443d4STobin Davis 79c9b443d4STobin Davis /* playback */ 80c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 81c9b443d4STobin Davis * max_channels, dacs must be set 82c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 83c9b443d4STobin Davis */ 84c9b443d4STobin Davis unsigned int cur_eapd; 8582f30040STobin Davis unsigned int hp_present; 8603697e2aSTakashi Iwai unsigned int line_present; 87faddaa5dSTakashi Iwai unsigned int auto_mic; 88c9b443d4STobin Davis 89c9b443d4STobin Davis /* capture */ 90c9b443d4STobin Davis unsigned int num_adc_nids; 9134cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 92c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 93c9b443d4STobin Davis 94461e2c78STakashi Iwai unsigned int cur_adc_idx; 95461e2c78STakashi Iwai hda_nid_t cur_adc; 96461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 97461e2c78STakashi Iwai unsigned int cur_adc_format; 98461e2c78STakashi Iwai 996764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1006764bcefSTakashi Iwai 101c9b443d4STobin Davis /* capture source */ 102c9b443d4STobin Davis const struct hda_input_mux *input_mux; 10334cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 104c9b443d4STobin Davis unsigned int cur_mux[3]; 105c9b443d4STobin Davis 106c9b443d4STobin Davis /* channel model */ 107c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 108c9b443d4STobin Davis int num_channel_mode; 109c9b443d4STobin Davis 110c9b443d4STobin Davis /* PCM information */ 111c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 112c9b443d4STobin Davis 113c9b443d4STobin Davis unsigned int spdif_route; 114c9b443d4STobin Davis 1150fb67e98SDaniel Drake unsigned int port_d_mode; 116f2e5731dSTakashi Iwai unsigned int dell_automute:1; 117cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 118cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1197b2bfdbcSJens Taprogge unsigned int thinkpad:1; 120048e78a5SDavid Henningsson unsigned int hp_laptop:1; 121a1d6906eSDavid Henningsson unsigned int asus:1; 1226764bcefSTakashi Iwai 12375f8991dSDaniel Drake unsigned int ext_mic_present; 12475f8991dSDaniel Drake unsigned int recording; 12575f8991dSDaniel Drake void (*capture_prepare)(struct hda_codec *codec); 12675f8991dSDaniel Drake void (*capture_cleanup)(struct hda_codec *codec); 127c4cfe66cSDaniel Drake 128c4cfe66cSDaniel Drake /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 129c4cfe66cSDaniel Drake * through the microphone jack. 130c4cfe66cSDaniel Drake * When the user enables this through a mixer switch, both internal and 131c4cfe66cSDaniel Drake * external microphones are disabled. Gain is fixed at 0dB. In this mode, 132c4cfe66cSDaniel Drake * we also allow the bias to be configured through a separate mixer 133c4cfe66cSDaniel Drake * control. */ 134c4cfe66cSDaniel Drake unsigned int dc_enable; 135c4cfe66cSDaniel Drake unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ 136c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 137bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 138c9b443d4STobin Davis }; 139c9b443d4STobin Davis 140bf92d1d5STakashi Iwai 141bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 1427504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 1437504b6cdSTakashi Iwai int idx, int dir) 1447504b6cdSTakashi Iwai { 1457504b6cdSTakashi Iwai spec->gen.beep_nid = nid; 1467504b6cdSTakashi Iwai spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 1477504b6cdSTakashi Iwai } 148bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 149bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 150bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 151bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 152bf92d1d5STakashi Iwai { } /* end */ 153bf92d1d5STakashi Iwai }; 154bf92d1d5STakashi Iwai 155bf92d1d5STakashi Iwai /* create beep controls if needed */ 156bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 157bf92d1d5STakashi Iwai { 158bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 159bf92d1d5STakashi Iwai int err; 160bf92d1d5STakashi Iwai 161bf92d1d5STakashi Iwai if (spec->beep_amp) { 162bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 163bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 164bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 165bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 166bf92d1d5STakashi Iwai if (!kctl) 167bf92d1d5STakashi Iwai return -ENOMEM; 168bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 169bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 170bf92d1d5STakashi Iwai if (err < 0) 171bf92d1d5STakashi Iwai return err; 172bf92d1d5STakashi Iwai } 173bf92d1d5STakashi Iwai } 174bf92d1d5STakashi Iwai return 0; 175bf92d1d5STakashi Iwai } 176bf92d1d5STakashi Iwai #else 177bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 178bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 179bf92d1d5STakashi Iwai #endif 180bf92d1d5STakashi Iwai 181bf92d1d5STakashi Iwai 182bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 183c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 184c9b443d4STobin Davis struct hda_codec *codec, 185c9b443d4STobin Davis struct snd_pcm_substream *substream) 186c9b443d4STobin Davis { 187c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1889a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1899a08160bSTakashi Iwai hinfo); 190c9b443d4STobin Davis } 191c9b443d4STobin Davis 192c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 193c9b443d4STobin Davis struct hda_codec *codec, 194c9b443d4STobin Davis unsigned int stream_tag, 195c9b443d4STobin Davis unsigned int format, 196c9b443d4STobin Davis struct snd_pcm_substream *substream) 197c9b443d4STobin Davis { 198c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 199c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 200c9b443d4STobin Davis stream_tag, 201c9b443d4STobin Davis format, substream); 202c9b443d4STobin Davis } 203c9b443d4STobin Davis 204c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 205c9b443d4STobin Davis struct hda_codec *codec, 206c9b443d4STobin Davis struct snd_pcm_substream *substream) 207c9b443d4STobin Davis { 208c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 209c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 210c9b443d4STobin Davis } 211c9b443d4STobin Davis 212c9b443d4STobin Davis /* 213c9b443d4STobin Davis * Digital out 214c9b443d4STobin Davis */ 215c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 216c9b443d4STobin Davis struct hda_codec *codec, 217c9b443d4STobin Davis struct snd_pcm_substream *substream) 218c9b443d4STobin Davis { 219c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 220c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 221c9b443d4STobin Davis } 222c9b443d4STobin Davis 223c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 224c9b443d4STobin Davis struct hda_codec *codec, 225c9b443d4STobin Davis struct snd_pcm_substream *substream) 226c9b443d4STobin Davis { 227c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 228c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 229c9b443d4STobin Davis } 230c9b443d4STobin Davis 2316b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2326b97eb45STakashi Iwai struct hda_codec *codec, 2336b97eb45STakashi Iwai unsigned int stream_tag, 2346b97eb45STakashi Iwai unsigned int format, 2356b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2366b97eb45STakashi Iwai { 2376b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2386b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2396b97eb45STakashi Iwai stream_tag, 2406b97eb45STakashi Iwai format, substream); 2416b97eb45STakashi Iwai } 2426b97eb45STakashi Iwai 243c9b443d4STobin Davis /* 244c9b443d4STobin Davis * Analog capture 245c9b443d4STobin Davis */ 246c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 247c9b443d4STobin Davis struct hda_codec *codec, 248c9b443d4STobin Davis unsigned int stream_tag, 249c9b443d4STobin Davis unsigned int format, 250c9b443d4STobin Davis struct snd_pcm_substream *substream) 251c9b443d4STobin Davis { 252c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 25375f8991dSDaniel Drake if (spec->capture_prepare) 25475f8991dSDaniel Drake spec->capture_prepare(codec); 255c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 256c9b443d4STobin Davis stream_tag, 0, format); 257c9b443d4STobin Davis return 0; 258c9b443d4STobin Davis } 259c9b443d4STobin Davis 260c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 261c9b443d4STobin Davis struct hda_codec *codec, 262c9b443d4STobin Davis struct snd_pcm_substream *substream) 263c9b443d4STobin Davis { 264c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 265888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 26675f8991dSDaniel Drake if (spec->capture_cleanup) 26775f8991dSDaniel Drake spec->capture_cleanup(codec); 268c9b443d4STobin Davis return 0; 269c9b443d4STobin Davis } 270c9b443d4STobin Davis 271c9b443d4STobin Davis 272c9b443d4STobin Davis 27334cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 274c9b443d4STobin Davis .substreams = 1, 275c9b443d4STobin Davis .channels_min = 2, 276c9b443d4STobin Davis .channels_max = 2, 277c9b443d4STobin Davis .nid = 0, /* fill later */ 278c9b443d4STobin Davis .ops = { 279c9b443d4STobin Davis .open = conexant_playback_pcm_open, 280c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 281c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 282c9b443d4STobin Davis }, 283c9b443d4STobin Davis }; 284c9b443d4STobin Davis 28534cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 286c9b443d4STobin Davis .substreams = 1, 287c9b443d4STobin Davis .channels_min = 2, 288c9b443d4STobin Davis .channels_max = 2, 289c9b443d4STobin Davis .nid = 0, /* fill later */ 290c9b443d4STobin Davis .ops = { 291c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 292c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 293c9b443d4STobin Davis }, 294c9b443d4STobin Davis }; 295c9b443d4STobin Davis 296c9b443d4STobin Davis 29734cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 298c9b443d4STobin Davis .substreams = 1, 299c9b443d4STobin Davis .channels_min = 2, 300c9b443d4STobin Davis .channels_max = 2, 301c9b443d4STobin Davis .nid = 0, /* fill later */ 302c9b443d4STobin Davis .ops = { 303c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 3046b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 3056b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 306c9b443d4STobin Davis }, 307c9b443d4STobin Davis }; 308c9b443d4STobin Davis 30934cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 310c9b443d4STobin Davis .substreams = 1, 311c9b443d4STobin Davis .channels_min = 2, 312c9b443d4STobin Davis .channels_max = 2, 313c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 314c9b443d4STobin Davis }; 315c9b443d4STobin Davis 316461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 317461e2c78STakashi Iwai struct hda_codec *codec, 318461e2c78STakashi Iwai unsigned int stream_tag, 319461e2c78STakashi Iwai unsigned int format, 320461e2c78STakashi Iwai struct snd_pcm_substream *substream) 321461e2c78STakashi Iwai { 322461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 323461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 324461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 325461e2c78STakashi Iwai spec->cur_adc_format = format; 326461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 327461e2c78STakashi Iwai return 0; 328461e2c78STakashi Iwai } 329461e2c78STakashi Iwai 330461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 331461e2c78STakashi Iwai struct hda_codec *codec, 332461e2c78STakashi Iwai struct snd_pcm_substream *substream) 333461e2c78STakashi Iwai { 334461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 335888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 336461e2c78STakashi Iwai spec->cur_adc = 0; 337461e2c78STakashi Iwai return 0; 338461e2c78STakashi Iwai } 339461e2c78STakashi Iwai 34034cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 341461e2c78STakashi Iwai .substreams = 1, 342461e2c78STakashi Iwai .channels_min = 2, 343461e2c78STakashi Iwai .channels_max = 2, 344461e2c78STakashi Iwai .nid = 0, /* fill later */ 345461e2c78STakashi Iwai .ops = { 346461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 347461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 348461e2c78STakashi Iwai }, 349461e2c78STakashi Iwai }; 350461e2c78STakashi Iwai 351c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 352c9b443d4STobin Davis { 353c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 354c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 355c9b443d4STobin Davis 356c9b443d4STobin Davis codec->num_pcms = 1; 357c9b443d4STobin Davis codec->pcm_info = info; 358c9b443d4STobin Davis 359c9b443d4STobin Davis info->name = "CONEXANT Analog"; 360c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 361c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 362c9b443d4STobin Davis spec->multiout.max_channels; 363c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 364c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3656764bcefSTakashi Iwai if (spec->capture_stream) 3666764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3676764bcefSTakashi Iwai else { 368461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 369461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 370461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3716764bcefSTakashi Iwai else { 372461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 373461e2c78STakashi Iwai conexant_pcm_analog_capture; 3746764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3756764bcefSTakashi Iwai spec->num_adc_nids; 3766764bcefSTakashi Iwai } 3776764bcefSTakashi Iwai } 378c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 379c9b443d4STobin Davis 380c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 381c9b443d4STobin Davis info++; 382c9b443d4STobin Davis codec->num_pcms++; 383c9b443d4STobin Davis info->name = "Conexant Digital"; 3847ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 385c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 386c9b443d4STobin Davis conexant_pcm_digital_playback; 387c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 388c9b443d4STobin Davis spec->multiout.dig_out_nid; 389c9b443d4STobin Davis if (spec->dig_in_nid) { 390c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 391c9b443d4STobin Davis conexant_pcm_digital_capture; 392c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 393c9b443d4STobin Davis spec->dig_in_nid; 394c9b443d4STobin Davis } 395c9b443d4STobin Davis } 396c9b443d4STobin Davis 397c9b443d4STobin Davis return 0; 398c9b443d4STobin Davis } 399c9b443d4STobin Davis 400c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 401c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 402c9b443d4STobin Davis { 403c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 404c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 405c9b443d4STobin Davis 406c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 407c9b443d4STobin Davis } 408c9b443d4STobin Davis 409c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 410c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 411c9b443d4STobin Davis { 412c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 413c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 414c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 415c9b443d4STobin Davis 416c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 417c9b443d4STobin Davis return 0; 418c9b443d4STobin Davis } 419c9b443d4STobin Davis 420c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 421c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 422c9b443d4STobin Davis { 423c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 424c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 425c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 426c9b443d4STobin Davis 427c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 428c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 429c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 430c9b443d4STobin Davis } 431c9b443d4STobin Davis 4324d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4334d7fbdbcSTakashi Iwai unsigned int power_state) 4344d7fbdbcSTakashi Iwai { 4354d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4364d7fbdbcSTakashi Iwai msleep(100); 4374d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4384d7fbdbcSTakashi Iwai power_state); 4394d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4404d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4414d7fbdbcSTakashi Iwai msleep(10); 4429419ab6bSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state); 4434d7fbdbcSTakashi Iwai } 4444d7fbdbcSTakashi Iwai 445c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 446c9b443d4STobin Davis { 447c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 448c9b443d4STobin Davis int i; 449c9b443d4STobin Davis 450c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 451c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 452c9b443d4STobin Davis return 0; 453c9b443d4STobin Davis } 454c9b443d4STobin Davis 455c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 456c9b443d4STobin Davis { 457ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 458c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 459ee48df57STakashi Iwai kfree(spec); 460c9b443d4STobin Davis } 461c9b443d4STobin Davis 46234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 463b880c74aSTakashi Iwai { 464b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 465b880c74aSTakashi Iwai .name = "Capture Source", 466b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 467b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 468b880c74aSTakashi Iwai .put = conexant_mux_enum_put 469b880c74aSTakashi Iwai }, 470b880c74aSTakashi Iwai {} 471b880c74aSTakashi Iwai }; 472b880c74aSTakashi Iwai 4739322ca54STakashi Iwai static const char * const slave_pfxs[] = { 474f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 475dd5746a8STakashi Iwai NULL 476dd5746a8STakashi Iwai }; 477dd5746a8STakashi Iwai 478c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 479c9b443d4STobin Davis { 480c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 481c9b443d4STobin Davis unsigned int i; 482c9b443d4STobin Davis int err; 483c9b443d4STobin Davis 484c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 485c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 486c9b443d4STobin Davis if (err < 0) 487c9b443d4STobin Davis return err; 488c9b443d4STobin Davis } 489c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 490c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 49174b654c9SStephen Warren spec->multiout.dig_out_nid, 492c9b443d4STobin Davis spec->multiout.dig_out_nid); 493c9b443d4STobin Davis if (err < 0) 494c9b443d4STobin Davis return err; 4959a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4969a08160bSTakashi Iwai &spec->multiout); 4979a08160bSTakashi Iwai if (err < 0) 4989a08160bSTakashi Iwai return err; 4999a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 500c9b443d4STobin Davis } 501c9b443d4STobin Davis if (spec->dig_in_nid) { 502c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 503c9b443d4STobin Davis if (err < 0) 504c9b443d4STobin Davis return err; 505c9b443d4STobin Davis } 506dd5746a8STakashi Iwai 507dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 508dd5746a8STakashi Iwai if (spec->vmaster_nid && 509dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 510dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 511dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 512dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 513dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5149322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5159322ca54STakashi Iwai "Playback Volume"); 516dd5746a8STakashi Iwai if (err < 0) 517dd5746a8STakashi Iwai return err; 518dd5746a8STakashi Iwai } 519dd5746a8STakashi Iwai if (spec->vmaster_nid && 520dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 521aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5229322ca54STakashi Iwai NULL, slave_pfxs, 523aed523f1STakashi Iwai "Playback Switch"); 524dd5746a8STakashi Iwai if (err < 0) 525dd5746a8STakashi Iwai return err; 526dd5746a8STakashi Iwai } 527dd5746a8STakashi Iwai 528b880c74aSTakashi Iwai if (spec->input_mux) { 529b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 530b880c74aSTakashi Iwai if (err < 0) 531b880c74aSTakashi Iwai return err; 532b880c74aSTakashi Iwai } 533b880c74aSTakashi Iwai 534aed523f1STakashi Iwai err = add_beep_ctls(codec); 5353507e2a8STakashi Iwai if (err < 0) 5363507e2a8STakashi Iwai return err; 5373507e2a8STakashi Iwai 538c9b443d4STobin Davis return 0; 539c9b443d4STobin Davis } 540c9b443d4STobin Davis 54134cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 542c9b443d4STobin Davis .build_controls = conexant_build_controls, 543c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 544c9b443d4STobin Davis .init = conexant_init, 545c9b443d4STobin Davis .free = conexant_free, 5464d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 547c9b443d4STobin Davis }; 548c9b443d4STobin Davis 5496764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 550c9b443d4STobin Davis /* 551c9b443d4STobin Davis * EAPD control 552c9b443d4STobin Davis * the private value = nid | (invert << 8) 553c9b443d4STobin Davis */ 554c9b443d4STobin Davis 555a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 556c9b443d4STobin Davis 55782f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 558c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 559c9b443d4STobin Davis { 560c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 561c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 562c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 563c9b443d4STobin Davis if (invert) 564c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 565c9b443d4STobin Davis else 566c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 567c9b443d4STobin Davis return 0; 56882f30040STobin Davis 569c9b443d4STobin Davis } 570c9b443d4STobin Davis 57182f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 572c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 573c9b443d4STobin Davis { 574c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 575c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 576c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 577c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 578c9b443d4STobin Davis unsigned int eapd; 57982f30040STobin Davis 58068ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 581c9b443d4STobin Davis if (invert) 582c9b443d4STobin Davis eapd = !eapd; 58382beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 584c9b443d4STobin Davis return 0; 58582f30040STobin Davis 586c9b443d4STobin Davis spec->cur_eapd = eapd; 58782beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 588c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 589c9b443d4STobin Davis eapd ? 0x02 : 0x00); 590c9b443d4STobin Davis return 1; 591c9b443d4STobin Davis } 592c9b443d4STobin Davis 59386d72bdfSTakashi Iwai /* controls for test mode */ 59486d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 59586d72bdfSTakashi Iwai 59682f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 59782f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 59882f30040STobin Davis .info = cxt_eapd_info, \ 59982f30040STobin Davis .get = cxt_eapd_get, \ 60082f30040STobin Davis .put = cxt_eapd_put, \ 60182f30040STobin Davis .private_value = nid | (mask<<16) } 60282f30040STobin Davis 60382f30040STobin Davis 60482f30040STobin Davis 605c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 606c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 607c9b443d4STobin Davis { 608c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 609c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 610c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 611c9b443d4STobin Davis spec->num_channel_mode); 612c9b443d4STobin Davis } 613c9b443d4STobin Davis 614c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 615c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 616c9b443d4STobin Davis { 617c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 618c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 619c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 620c9b443d4STobin Davis spec->num_channel_mode, 621c9b443d4STobin Davis spec->multiout.max_channels); 622c9b443d4STobin Davis } 623c9b443d4STobin Davis 624c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 625c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 626c9b443d4STobin Davis { 627c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 628c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 629c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 630c9b443d4STobin Davis spec->num_channel_mode, 631c9b443d4STobin Davis &spec->multiout.max_channels); 632c9b443d4STobin Davis return err; 633c9b443d4STobin Davis } 634c9b443d4STobin Davis 635c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 636c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 637c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 638c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 639c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 640c9b443d4STobin Davis .private_value = nid | (dir<<16) } 641c9b443d4STobin Davis 64286d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 64386d72bdfSTakashi Iwai 644c9b443d4STobin Davis /* Conexant 5045 specific */ 645c9b443d4STobin Davis 64634cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 64734cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 64834cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 649cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 650c9b443d4STobin Davis 65134cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6525cd57529STobin Davis { 2, NULL }, 6535cd57529STobin Davis }; 654c9b443d4STobin Davis 65534cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 656c9b443d4STobin Davis .num_items = 2, 657c9b443d4STobin Davis .items = { 6583edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6593edbbb9eSMichael Karcher { "Mic", 0x2 }, 660c9b443d4STobin Davis } 661c9b443d4STobin Davis }; 662c9b443d4STobin Davis 66334cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 664e6e03daeSMichael Karcher .num_items = 4, 6655218c892SJiang Zhe .items = { 6663edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6673edbbb9eSMichael Karcher { "Mic", 0x2 }, 6683edbbb9eSMichael Karcher { "Line", 0x3 }, 66922e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6705218c892SJiang Zhe } 6715218c892SJiang Zhe }; 6725218c892SJiang Zhe 67334cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_hp530 = { 6742de3c232SJiang zhe .num_items = 2, 6752de3c232SJiang zhe .items = { 6763edbbb9eSMichael Karcher { "Mic", 0x1 }, 6773edbbb9eSMichael Karcher { "Internal Mic", 0x2 }, 6782de3c232SJiang zhe } 6792de3c232SJiang zhe }; 6802de3c232SJiang zhe 681c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 682c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 683c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 684c9b443d4STobin Davis { 685c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 686c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 68782f30040STobin Davis unsigned int bits; 688c9b443d4STobin Davis 68982f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 690c9b443d4STobin Davis return 0; 691c9b443d4STobin Davis 69282f30040STobin Davis /* toggle internal speakers mute depending of presence of 69382f30040STobin Davis * the headphone jack 69482f30040STobin Davis */ 69547fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 69647fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 69747fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 6987f29673bSTobin Davis 69947fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 70047fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 70147fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 702c9b443d4STobin Davis return 1; 703c9b443d4STobin Davis } 704c9b443d4STobin Davis 705c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 70634cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 707cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 708cca3b371STakashi Iwai .values = { 709cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 710cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 711cca3b371STakashi Iwai 0 712cca3b371STakashi Iwai }, 713cca3b371STakashi Iwai }; 714c9b443d4STobin Davis 7157f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 7167f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7177f29673bSTobin Davis { 71834cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7197f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7207f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7217f29673bSTobin Davis {} 7227f29673bSTobin Davis }; 72334cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7247f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7257f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7267f29673bSTobin Davis {} 7277f29673bSTobin Davis }; 7287f29673bSTobin Davis unsigned int present; 7297f29673bSTobin Davis 730d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7317f29673bSTobin Davis if (present) 7327f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7337f29673bSTobin Davis else 7347f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7357f29673bSTobin Davis } 7367f29673bSTobin Davis 737c9b443d4STobin Davis 738c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 739c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 740c9b443d4STobin Davis { 74182f30040STobin Davis struct conexant_spec *spec = codec->spec; 742dd87da1cSTobin Davis unsigned int bits; 743c9b443d4STobin Davis 744d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 745dd87da1cSTobin Davis 74647fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 74747fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 74847fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 749c9b443d4STobin Davis } 750c9b443d4STobin Davis 751c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 752c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 753c9b443d4STobin Davis unsigned int res) 754c9b443d4STobin Davis { 755c9b443d4STobin Davis res >>= 26; 756c9b443d4STobin Davis switch (res) { 757c9b443d4STobin Davis case CONEXANT_HP_EVENT: 758c9b443d4STobin Davis cxt5045_hp_automute(codec); 759c9b443d4STobin Davis break; 7607f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7617f29673bSTobin Davis cxt5045_hp_automic(codec); 7627f29673bSTobin Davis break; 7637f29673bSTobin Davis 764c9b443d4STobin Davis } 765c9b443d4STobin Davis } 766c9b443d4STobin Davis 76734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 768cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 769cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 770c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 771c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 77228c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 77328c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7748607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7758607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 776cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 777c9b443d4STobin Davis { 778c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 779c9b443d4STobin Davis .name = "Master Playback Switch", 78082f30040STobin Davis .info = cxt_eapd_info, 78182f30040STobin Davis .get = cxt_eapd_get, 782c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 78382f30040STobin Davis .private_value = 0x10, 784c9b443d4STobin Davis }, 785c9b443d4STobin Davis 786c9b443d4STobin Davis {} 787c9b443d4STobin Davis }; 788c9b443d4STobin Davis 78934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7903edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7913edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 79222e14130SLukasz Marcinowski 7935218c892SJiang Zhe {} 7945218c892SJiang Zhe }; 7955218c892SJiang Zhe 79634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 797cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 798cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 7992de3c232SJiang zhe HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 8002de3c232SJiang zhe HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 80128c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 80228c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 8038607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 8048607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 8052de3c232SJiang zhe HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 8062de3c232SJiang zhe { 8072de3c232SJiang zhe .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8082de3c232SJiang zhe .name = "Master Playback Switch", 8092de3c232SJiang zhe .info = cxt_eapd_info, 8102de3c232SJiang zhe .get = cxt_eapd_get, 8112de3c232SJiang zhe .put = cxt5045_hp_master_sw_put, 8122de3c232SJiang zhe .private_value = 0x10, 8132de3c232SJiang zhe }, 8142de3c232SJiang zhe 8152de3c232SJiang zhe {} 8162de3c232SJiang zhe }; 8172de3c232SJiang zhe 81834cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 819c9b443d4STobin Davis /* Line in, Mic */ 8204090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8217f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 822c9b443d4STobin Davis /* HP, Amp */ 823c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 824c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 82582f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 826c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 827c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 828c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 829c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 830c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 831c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 83228c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8337f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 83482f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 835c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 836c9b443d4STobin Davis /* SPDIF route: PCM */ 837cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 838c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 839c9b443d4STobin Davis /* EAPD */ 84082f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 841c9b443d4STobin Davis { } /* end */ 842c9b443d4STobin Davis }; 843c9b443d4STobin Davis 84434cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 84528c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8465218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8475218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8485218c892SJiang Zhe /* Line In,HP, Amp */ 8495218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8505218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8515218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8525218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8535218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8545218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8555218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8565218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8575218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 85828c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8595218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8605218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8615218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8625218c892SJiang Zhe /* SPDIF route: PCM */ 863cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8645218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8655218c892SJiang Zhe /* EAPD */ 8665218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8675218c892SJiang Zhe { } /* end */ 8685218c892SJiang Zhe }; 8697f29673bSTobin Davis 87034cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8717f29673bSTobin Davis /* pin sensing on HP jack */ 8727f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 873d3091fadSTakashi Iwai { } /* end */ 8747f29673bSTobin Davis }; 8757f29673bSTobin Davis 87634cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8777f29673bSTobin Davis /* pin sensing on HP jack */ 8787f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 879d3091fadSTakashi Iwai { } /* end */ 8807f29673bSTobin Davis }; 8817f29673bSTobin Davis 882c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 883c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 884c9b443d4STobin Davis * configuration. 885c9b443d4STobin Davis */ 88634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 887c9b443d4STobin Davis .num_items = 5, 888c9b443d4STobin Davis .items = { 889c9b443d4STobin Davis { "MIXER", 0x0 }, 890c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 891c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 892c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 893c9b443d4STobin Davis { "CD pin", 0x4 }, 894c9b443d4STobin Davis }, 895c9b443d4STobin Davis }; 896c9b443d4STobin Davis 89734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 898c9b443d4STobin Davis 899c9b443d4STobin Davis /* Output controls */ 900c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 901c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 902250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 903250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 904250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 905250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 906c9b443d4STobin Davis 907c9b443d4STobin Davis /* Modes for retasking pin widgets */ 908c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 909c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 910c9b443d4STobin Davis 91182f30040STobin Davis /* EAPD Switch Control */ 91282f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 91382f30040STobin Davis 914c9b443d4STobin Davis /* Loopback mixer controls */ 915c9b443d4STobin Davis 916250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 917250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 918250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 919250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 920250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 921250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 922250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 923250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 924250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 925250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 926c9b443d4STobin Davis { 927c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 928c9b443d4STobin Davis .name = "Input Source", 929c9b443d4STobin Davis .info = conexant_mux_enum_info, 930c9b443d4STobin Davis .get = conexant_mux_enum_get, 931c9b443d4STobin Davis .put = conexant_mux_enum_put, 932c9b443d4STobin Davis }, 933fb3409e7STobin Davis /* Audio input controls */ 934cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 935cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 936c9b443d4STobin Davis { } /* end */ 937c9b443d4STobin Davis }; 938c9b443d4STobin Davis 93934cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9407f29673bSTobin Davis /* Set connections */ 9417f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9427f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9437f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 944c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 945c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9467f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 947c9b443d4STobin Davis 948c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 949c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 950c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 951c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 952c9b443d4STobin Davis * control. 953c9b443d4STobin Davis */ 954cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 955cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 956c9b443d4STobin Davis 957c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 958c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 959c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 960c9b443d4STobin Davis * input/output buffers as needed. 961c9b443d4STobin Davis */ 962c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 963c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 964c9b443d4STobin Davis 965c9b443d4STobin Davis /* Mute capture amp left and right */ 966c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 967c9b443d4STobin Davis 968c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 969c9b443d4STobin Davis * pin) 970c9b443d4STobin Davis */ 971250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 972250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 973c9b443d4STobin Davis 974c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 975250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 976c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 977c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 978c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 979c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 980c9b443d4STobin Davis 981c9b443d4STobin Davis { } 982c9b443d4STobin Davis }; 983c9b443d4STobin Davis #endif 984c9b443d4STobin Davis 985c9b443d4STobin Davis 986c9b443d4STobin Davis /* initialize jack-sensing, too */ 987c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 988c9b443d4STobin Davis { 989c9b443d4STobin Davis conexant_init(codec); 990c9b443d4STobin Davis cxt5045_hp_automute(codec); 991c9b443d4STobin Davis return 0; 992c9b443d4STobin Davis } 993c9b443d4STobin Davis 994c9b443d4STobin Davis 995c9b443d4STobin Davis enum { 99615908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 99715908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 99815908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 9995218c892SJiang Zhe CXT5045_BENQ, 10002de3c232SJiang zhe CXT5045_LAPTOP_HP530, 1001c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1002c9b443d4STobin Davis CXT5045_TEST, 1003c9b443d4STobin Davis #endif 10041f8458a2STakashi Iwai CXT5045_AUTO, 1005f5fcc13cSTakashi Iwai CXT5045_MODELS 1006c9b443d4STobin Davis }; 1007c9b443d4STobin Davis 1008ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 100915908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 101015908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 101115908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 10125218c892SJiang Zhe [CXT5045_BENQ] = "benq", 10132de3c232SJiang zhe [CXT5045_LAPTOP_HP530] = "laptop-hp530", 1014c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1015f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 1016c9b443d4STobin Davis #endif 10171f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 1018f5fcc13cSTakashi Iwai }; 1019c9b443d4STobin Davis 102034cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 10212de3c232SJiang zhe SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 10226a9dccd6STakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 10235218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 102415908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 102515908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 10269e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 10279e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 102815908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 102915908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 103015908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1031dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 1032dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 103315908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1034c9b443d4STobin Davis {} 1035c9b443d4STobin Davis }; 1036c9b443d4STobin Davis 1037c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 1038c9b443d4STobin Davis { 1039c9b443d4STobin Davis struct conexant_spec *spec; 1040c9b443d4STobin Davis int board_config; 1041c9b443d4STobin Davis 10421f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10431f8458a2STakashi Iwai cxt5045_models, 10441f8458a2STakashi Iwai cxt5045_cfg_tbl); 10451f8458a2STakashi Iwai if (board_config < 0) 1046c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10471f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10481f8458a2STakashi Iwai return patch_conexant_auto(codec); 10491f8458a2STakashi Iwai 1050c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1051c9b443d4STobin Davis if (!spec) 1052c9b443d4STobin Davis return -ENOMEM; 1053c9b443d4STobin Davis codec->spec = spec; 10544f32456eSMichael Karcher codec->single_adc_amp = 1; 1055c9b443d4STobin Davis 1056c9b443d4STobin Davis spec->multiout.max_channels = 2; 1057c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1058c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1059c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1060c9b443d4STobin Davis spec->num_adc_nids = 1; 1061c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1062c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1063c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1064c9b443d4STobin Davis spec->num_mixers = 1; 1065c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1066c9b443d4STobin Davis spec->num_init_verbs = 1; 1067c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1068c9b443d4STobin Davis spec->spdif_route = 0; 10693507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10703507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10715cd57529STobin Davis 10723507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1073c9b443d4STobin Davis 1074c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1075c9b443d4STobin Davis 1076c9b443d4STobin Davis switch (board_config) { 107715908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10787f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1079c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1080c9b443d4STobin Davis spec->num_init_verbs = 2; 10817f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10827f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10837f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10847f29673bSTobin Davis break; 108515908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 108686376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10877f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10887f29673bSTobin Davis spec->num_init_verbs = 2; 10897f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1090c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1091c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1092c9b443d4STobin Davis break; 109315908c36SMarc Boucher default: 109415908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 109515908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 109615908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 109715908c36SMarc Boucher spec->num_init_verbs = 3; 109815908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 109915908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 110015908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 110115908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 110215908c36SMarc Boucher break; 11035218c892SJiang Zhe case CXT5045_BENQ: 11045218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11055218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 11065218c892SJiang Zhe spec->num_init_verbs = 1; 11075218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 11085218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 11095218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 11105218c892SJiang Zhe spec->num_mixers = 2; 11115218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 11125218c892SJiang Zhe break; 11132de3c232SJiang zhe case CXT5045_LAPTOP_HP530: 11142de3c232SJiang zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 11152de3c232SJiang zhe spec->input_mux = &cxt5045_capture_source_hp530; 11162de3c232SJiang zhe spec->num_init_verbs = 2; 11172de3c232SJiang zhe spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 11182de3c232SJiang zhe spec->mixers[0] = cxt5045_mixers_hp530; 11192de3c232SJiang zhe codec->patch_ops.init = cxt5045_init; 11202de3c232SJiang zhe break; 1121c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1122c9b443d4STobin Davis case CXT5045_TEST: 1123c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1124c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1125c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 112615908c36SMarc Boucher break; 112715908c36SMarc Boucher 1128c9b443d4STobin Davis #endif 1129c9b443d4STobin Davis } 113048ecb7e8STakashi Iwai 1131031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1132031005f7STakashi Iwai case 0x103c: 11338f0f5ff6SDaniel T Chen case 0x1631: 11340b587fc4SDaniel T Chen case 0x1734: 11350ebf9e36SDaniel T Chen case 0x17aa: 11360ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 11370ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 11380ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 113948ecb7e8STakashi Iwai */ 114048ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 114148ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 114248ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 114348ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 114448ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1145031005f7STakashi Iwai break; 1146031005f7STakashi Iwai } 114748ecb7e8STakashi Iwai 11483507e2a8STakashi Iwai if (spec->beep_amp) 1149a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 11503507e2a8STakashi Iwai 1151c9b443d4STobin Davis return 0; 1152c9b443d4STobin Davis } 1153c9b443d4STobin Davis 1154c9b443d4STobin Davis 1155c9b443d4STobin Davis /* Conexant 5047 specific */ 115682f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1157c9b443d4STobin Davis 115834cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 115934cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 116034cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1161c9b443d4STobin Davis 116234cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11635cd57529STobin Davis { 2, NULL }, 11645cd57529STobin Davis }; 1165c9b443d4STobin Davis 116634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 116782f30040STobin Davis .num_items = 2, 116882f30040STobin Davis .items = { 116982f30040STobin Davis { "ExtMic", 0x2 }, 117082f30040STobin Davis { "Line-In", 0x1 }, 1171c9b443d4STobin Davis } 1172c9b443d4STobin Davis }; 1173c9b443d4STobin Davis 1174c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1175c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1176c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1177c9b443d4STobin Davis { 1178c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1179c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 118082f30040STobin Davis unsigned int bits; 1181c9b443d4STobin Davis 118282f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1183c9b443d4STobin Davis return 0; 1184c9b443d4STobin Davis 118582f30040STobin Davis /* toggle internal speakers mute depending of presence of 118682f30040STobin Davis * the headphone jack 118782f30040STobin Davis */ 118847fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11893b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11903b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11913b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11923b7523fcSTakashi Iwai */ 11935d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 119447fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 119547fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 119647fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 119747fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1198c9b443d4STobin Davis return 1; 1199c9b443d4STobin Davis } 1200c9b443d4STobin Davis 1201c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1202c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1203c9b443d4STobin Davis { 120482f30040STobin Davis struct conexant_spec *spec = codec->spec; 1205dd87da1cSTobin Davis unsigned int bits; 1206c9b443d4STobin Davis 1207d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1208dd87da1cSTobin Davis 120947fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 12103b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12115d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 121247fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1213c9b443d4STobin Davis } 1214c9b443d4STobin Davis 1215c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1216c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1217c9b443d4STobin Davis { 121834cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 12199f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12209f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1221c9b443d4STobin Davis {} 1222c9b443d4STobin Davis }; 122334cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 12249f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 12259f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1226c9b443d4STobin Davis {} 1227c9b443d4STobin Davis }; 1228c9b443d4STobin Davis unsigned int present; 1229c9b443d4STobin Davis 1230d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1231c9b443d4STobin Davis if (present) 1232c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1233c9b443d4STobin Davis else 1234c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1235c9b443d4STobin Davis } 1236c9b443d4STobin Davis 1237c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1238c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1239c9b443d4STobin Davis unsigned int res) 1240c9b443d4STobin Davis { 12419f113e0eSMarc Boucher switch (res >> 26) { 1242c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1243c9b443d4STobin Davis cxt5047_hp_automute(codec); 1244c9b443d4STobin Davis break; 1245c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1246c9b443d4STobin Davis cxt5047_hp_automic(codec); 1247c9b443d4STobin Davis break; 1248c9b443d4STobin Davis } 1249c9b443d4STobin Davis } 1250c9b443d4STobin Davis 125134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1252df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1253df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12545f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1255c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1256c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1257c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1258c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 125982f30040STobin Davis { 126082f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 126182f30040STobin Davis .name = "Master Playback Switch", 126282f30040STobin Davis .info = cxt_eapd_info, 126382f30040STobin Davis .get = cxt_eapd_get, 1264c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1265c9b443d4STobin Davis .private_value = 0x13, 1266c9b443d4STobin Davis }, 1267c9b443d4STobin Davis 1268c9b443d4STobin Davis {} 1269c9b443d4STobin Davis }; 1270c9b443d4STobin Davis 127134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12723b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12735d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1274df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1275df481e41STakashi Iwai {} 1276df481e41STakashi Iwai }; 1277df481e41STakashi Iwai 127834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1279c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1280c9b443d4STobin Davis { } /* end */ 1281c9b443d4STobin Davis }; 1282c9b443d4STobin Davis 128334cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1284c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1285c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1286c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1287c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12887f29673bSTobin Davis /* HP, Speaker */ 1289b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12905b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12915b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12927f29673bSTobin Davis /* Record selector: Mic */ 12937f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12947f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12957f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12967f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1297c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1298c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1299c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1300c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1301c9b443d4STobin Davis /* SPDIF route: PCM */ 1302c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 130382f30040STobin Davis /* Enable unsolicited events */ 130482f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 130582f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1306c9b443d4STobin Davis { } /* end */ 1307c9b443d4STobin Davis }; 1308c9b443d4STobin Davis 1309c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 131034cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 13113b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1312c9b443d4STobin Davis {} 1313c9b443d4STobin Davis }; 1314c9b443d4STobin Davis 1315c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1316c9b443d4STobin Davis * configuration. 1317c9b443d4STobin Davis */ 1318c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 131934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 132082f30040STobin Davis .num_items = 4, 1321c9b443d4STobin Davis .items = { 132282f30040STobin Davis { "LINE1 pin", 0x0 }, 132382f30040STobin Davis { "MIC1 pin", 0x1 }, 132482f30040STobin Davis { "MIC2 pin", 0x2 }, 132582f30040STobin Davis { "CD pin", 0x3 }, 1326c9b443d4STobin Davis }, 1327c9b443d4STobin Davis }; 1328c9b443d4STobin Davis 132934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1330c9b443d4STobin Davis 1331c9b443d4STobin Davis /* Output only controls */ 133282f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 133382f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 133482f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 133582f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1336c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1337c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1338c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1339c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 134082f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 134182f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 134282f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 134382f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1344c9b443d4STobin Davis 1345c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1346c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1347c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1348c9b443d4STobin Davis 134982f30040STobin Davis /* EAPD Switch Control */ 135082f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 135182f30040STobin Davis 1352c9b443d4STobin Davis /* Loopback mixer controls */ 135382f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 135482f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 135582f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 135682f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 135782f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 135882f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 135982f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 136082f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1361c9b443d4STobin Davis 136282f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 136382f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 136482f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 136582f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 136682f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 136782f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 136882f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 136982f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1370c9b443d4STobin Davis { 1371c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1372c9b443d4STobin Davis .name = "Input Source", 1373c9b443d4STobin Davis .info = conexant_mux_enum_info, 1374c9b443d4STobin Davis .get = conexant_mux_enum_get, 1375c9b443d4STobin Davis .put = conexant_mux_enum_put, 1376c9b443d4STobin Davis }, 1377854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13789f113e0eSMarc Boucher 1379c9b443d4STobin Davis { } /* end */ 1380c9b443d4STobin Davis }; 1381c9b443d4STobin Davis 138234cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1383c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1384c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1385c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1386c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1387c9b443d4STobin Davis 1388c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1389c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1390c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1391c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1392c9b443d4STobin Davis * control. 1393c9b443d4STobin Davis */ 1394c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1395c9b443d4STobin Davis 1396c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1397c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1398c9b443d4STobin Davis */ 1399c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1400c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1401c9b443d4STobin Davis 1402c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1403c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1404c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1405c9b443d4STobin Davis 1406c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1407c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1408c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1409c9b443d4STobin Davis * input/output buffers as needed. 1410c9b443d4STobin Davis */ 1411c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1412c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1413c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1414c9b443d4STobin Davis 1415c9b443d4STobin Davis /* Mute capture amp left and right */ 1416c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1417c9b443d4STobin Davis 1418c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1419c9b443d4STobin Davis * pin) 1420c9b443d4STobin Davis */ 1421c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1422c9b443d4STobin Davis 1423c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1424c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1425c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1426c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1427c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1428c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1429c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1430c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1431c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1432c9b443d4STobin Davis 1433c9b443d4STobin Davis { } 1434c9b443d4STobin Davis }; 1435c9b443d4STobin Davis #endif 1436c9b443d4STobin Davis 1437c9b443d4STobin Davis 1438c9b443d4STobin Davis /* initialize jack-sensing, too */ 1439c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1440c9b443d4STobin Davis { 1441c9b443d4STobin Davis conexant_init(codec); 1442c9b443d4STobin Davis cxt5047_hp_automute(codec); 1443c9b443d4STobin Davis return 0; 1444c9b443d4STobin Davis } 1445c9b443d4STobin Davis 1446c9b443d4STobin Davis 1447c9b443d4STobin Davis enum { 1448f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1449f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1450f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1451c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1452c9b443d4STobin Davis CXT5047_TEST, 1453c9b443d4STobin Davis #endif 1454fa5dadcbSTakashi Iwai CXT5047_AUTO, 1455f5fcc13cSTakashi Iwai CXT5047_MODELS 1456c9b443d4STobin Davis }; 1457c9b443d4STobin Davis 1458ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1459f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1460f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1461f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1462c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1463f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1464c9b443d4STobin Davis #endif 1465fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1466f5fcc13cSTakashi Iwai }; 1467c9b443d4STobin Davis 146834cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1469ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1470dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1471dea0a509STakashi Iwai CXT5047_LAPTOP), 1472f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1473c9b443d4STobin Davis {} 1474c9b443d4STobin Davis }; 1475c9b443d4STobin Davis 1476c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1477c9b443d4STobin Davis { 1478c9b443d4STobin Davis struct conexant_spec *spec; 1479c9b443d4STobin Davis int board_config; 1480c9b443d4STobin Davis 1481fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1482fa5dadcbSTakashi Iwai cxt5047_models, 1483fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1484fa5dadcbSTakashi Iwai if (board_config < 0) 1485c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1486fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1487fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1488fa5dadcbSTakashi Iwai 1489c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1490c9b443d4STobin Davis if (!spec) 1491c9b443d4STobin Davis return -ENOMEM; 1492c9b443d4STobin Davis codec->spec = spec; 14939421f954STakashi Iwai codec->pin_amp_workaround = 1; 1494c9b443d4STobin Davis 1495c9b443d4STobin Davis spec->multiout.max_channels = 2; 1496c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1497c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1498c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1499c9b443d4STobin Davis spec->num_adc_nids = 1; 1500c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1501c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1502c9b443d4STobin Davis spec->num_mixers = 1; 1503df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1504c9b443d4STobin Davis spec->num_init_verbs = 1; 1505c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1506c9b443d4STobin Davis spec->spdif_route = 0; 15075cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 15085cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1509c9b443d4STobin Davis 1510c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1511c9b443d4STobin Davis 1512c9b443d4STobin Davis switch (board_config) { 1513c9b443d4STobin Davis case CXT5047_LAPTOP: 1514df481e41STakashi Iwai spec->num_mixers = 2; 1515df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1516df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1517c9b443d4STobin Davis break; 1518c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1519df481e41STakashi Iwai spec->num_mixers = 2; 1520df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1521fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1522c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1523c9b443d4STobin Davis break; 1524c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 152582f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1526df481e41STakashi Iwai spec->num_mixers = 2; 1527df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1528c9b443d4STobin Davis spec->num_init_verbs = 2; 1529c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1530fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1531c9b443d4STobin Davis break; 1532c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1533c9b443d4STobin Davis case CXT5047_TEST: 1534c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1535c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1536c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1537fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1538c9b443d4STobin Davis #endif 1539c9b443d4STobin Davis } 1540dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1541025f206cSDaniel T Chen 1542025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1543025f206cSDaniel T Chen case 0x103c: 1544025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1545025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1546025f206cSDaniel T Chen * with 0 dB offset 0x17) 1547025f206cSDaniel T Chen */ 1548025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1549025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1550025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1551025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1552025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1553025f206cSDaniel T Chen break; 1554025f206cSDaniel T Chen } 1555025f206cSDaniel T Chen 1556c9b443d4STobin Davis return 0; 1557c9b443d4STobin Davis } 1558c9b443d4STobin Davis 1559461e2c78STakashi Iwai /* Conexant 5051 specific */ 156034cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 156134cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1562461e2c78STakashi Iwai 156334cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1564461e2c78STakashi Iwai { 2, NULL }, 1565461e2c78STakashi Iwai }; 1566461e2c78STakashi Iwai 1567461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1568461e2c78STakashi Iwai { 1569461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1570461e2c78STakashi Iwai unsigned int pinctl; 157123d2df5bSTakashi Iwai /* headphone pin */ 157223d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1573cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 157423d2df5bSTakashi Iwai /* speaker pin */ 1575461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1576cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1577a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1578f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1579cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1580461e2c78STakashi Iwai } 1581461e2c78STakashi Iwai 1582461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1583461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1584461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1585461e2c78STakashi Iwai { 1586461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1587461e2c78STakashi Iwai 1588461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1589461e2c78STakashi Iwai return 0; 1590461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1591461e2c78STakashi Iwai return 1; 1592461e2c78STakashi Iwai } 1593461e2c78STakashi Iwai 1594461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1595461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1596461e2c78STakashi Iwai { 159779d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1598461e2c78STakashi Iwai unsigned int present; 1599461e2c78STakashi Iwai 1600faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 160179d7d533STakashi Iwai return; 1602d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1603461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1604461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1605461e2c78STakashi Iwai present ? 0x01 : 0x00); 1606461e2c78STakashi Iwai } 1607461e2c78STakashi Iwai 1608461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1609461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1610461e2c78STakashi Iwai { 1611461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1612461e2c78STakashi Iwai unsigned int present; 1613461e2c78STakashi Iwai hda_nid_t new_adc; 1614461e2c78STakashi Iwai 1615faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 161679d7d533STakashi Iwai return; 1617d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1618461e2c78STakashi Iwai if (present) 1619461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1620461e2c78STakashi Iwai else 1621461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1622461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1623461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1624461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1625f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1626461e2c78STakashi Iwai spec->cur_adc = new_adc; 1627461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1628461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1629461e2c78STakashi Iwai spec->cur_adc_format); 1630461e2c78STakashi Iwai } 1631461e2c78STakashi Iwai } 1632461e2c78STakashi Iwai 1633461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1634461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1635461e2c78STakashi Iwai { 1636461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1637461e2c78STakashi Iwai 1638d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1639461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1640461e2c78STakashi Iwai } 1641461e2c78STakashi Iwai 1642461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1643461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1644461e2c78STakashi Iwai unsigned int res) 1645461e2c78STakashi Iwai { 1646461e2c78STakashi Iwai switch (res >> 26) { 1647461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1648461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1649461e2c78STakashi Iwai break; 1650461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1651461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1652461e2c78STakashi Iwai break; 1653461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1654461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1655461e2c78STakashi Iwai break; 1656461e2c78STakashi Iwai } 1657461e2c78STakashi Iwai } 1658461e2c78STakashi Iwai 165934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1660461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1661461e2c78STakashi Iwai { 1662461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1663461e2c78STakashi Iwai .name = "Master Playback Switch", 1664461e2c78STakashi Iwai .info = cxt_eapd_info, 1665461e2c78STakashi Iwai .get = cxt_eapd_get, 1666461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1667461e2c78STakashi Iwai .private_value = 0x1a, 1668461e2c78STakashi Iwai }, 16692c7a3fb3STakashi Iwai {} 16702c7a3fb3STakashi Iwai }; 1671461e2c78STakashi Iwai 167234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16732c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16742c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16758607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16768607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1677c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1678c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1679461e2c78STakashi Iwai {} 1680461e2c78STakashi Iwai }; 1681461e2c78STakashi Iwai 168234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1683461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1684461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16858607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16868607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1687461e2c78STakashi Iwai {} 1688461e2c78STakashi Iwai }; 1689461e2c78STakashi Iwai 169034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16914e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16924e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 169379d7d533STakashi Iwai {} 169479d7d533STakashi Iwai }; 169579d7d533STakashi Iwai 169634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 16975f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 16985f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1699cd9d95a5SKen Prox {} 1700cd9d95a5SKen Prox }; 1701cd9d95a5SKen Prox 170234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1703faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1704faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 17058607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 17068607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1707faddaa5dSTakashi Iwai {} 1708faddaa5dSTakashi Iwai }; 1709faddaa5dSTakashi Iwai 171034cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1711461e2c78STakashi Iwai /* Line in, Mic */ 1712461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1713461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1714461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1715461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1716461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1717461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1718461e2c78STakashi Iwai /* SPK */ 1719461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1720461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1721461e2c78STakashi Iwai /* HP, Amp */ 1722461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1723461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1724461e2c78STakashi Iwai /* DAC1 */ 1725461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172628c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1727461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1728461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1729461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1730461e2c78STakashi Iwai /* SPDIF route: PCM */ 17311965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1732461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1733461e2c78STakashi Iwai /* EAPD */ 1734461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1735461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1736461e2c78STakashi Iwai { } /* end */ 1737461e2c78STakashi Iwai }; 1738461e2c78STakashi Iwai 173934cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 174079d7d533STakashi Iwai /* Line in, Mic */ 174179d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 174279d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 174379d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174479d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 174579d7d533STakashi Iwai /* SPK */ 174679d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 174779d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 174879d7d533STakashi Iwai /* HP, Amp */ 174979d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 175079d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 175179d7d533STakashi Iwai /* DAC1 */ 175279d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 175328c4edb7SDavid Henningsson /* Record selector: Internal mic */ 175479d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 175579d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 175679d7d533STakashi Iwai /* SPDIF route: PCM */ 175779d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 175879d7d533STakashi Iwai /* EAPD */ 175979d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 176079d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 176179d7d533STakashi Iwai { } /* end */ 176279d7d533STakashi Iwai }; 176379d7d533STakashi Iwai 176434cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1765cd9d95a5SKen Prox /* Line in, Mic */ 176630ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1767cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1768cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1769cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1770cd9d95a5SKen Prox /* SPK */ 1771cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1772cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1773cd9d95a5SKen Prox /* HP, Amp */ 1774cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1775cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1776cd9d95a5SKen Prox /* DAC1 */ 1777cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 177828c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1779cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1780cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1781cd9d95a5SKen Prox /* SPDIF route: PCM */ 1782cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1783cd9d95a5SKen Prox /* EAPD */ 1784cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1785cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1786cd9d95a5SKen Prox { } /* end */ 1787cd9d95a5SKen Prox }; 1788cd9d95a5SKen Prox 17896953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17906953e552STakashi Iwai unsigned int event) 17916953e552STakashi Iwai { 17926953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17936953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17946953e552STakashi Iwai AC_USRSP_EN | event); 17956953e552STakashi Iwai } 17966953e552STakashi Iwai 179734cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1798f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1799f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1800f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1801f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1802f7154de2SHerton Ronaldo Krzesinski }; 1803f7154de2SHerton Ronaldo Krzesinski 1804461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1805461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1806461e2c78STakashi Iwai { 18076953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 18086953e552STakashi Iwai 1809461e2c78STakashi Iwai conexant_init(codec); 18106953e552STakashi Iwai 18116953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 18126953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 18136953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 18146953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 18156953e552STakashi Iwai 1816461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1817461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1818461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1819461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1820461e2c78STakashi Iwai } 1821461e2c78STakashi Iwai return 0; 1822461e2c78STakashi Iwai } 1823461e2c78STakashi Iwai 1824461e2c78STakashi Iwai 1825461e2c78STakashi Iwai enum { 1826461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1827461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 182879d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1829cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1830faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1831f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 18326764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1833461e2c78STakashi Iwai CXT5051_MODELS 1834461e2c78STakashi Iwai }; 1835461e2c78STakashi Iwai 1836ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1837461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1838461e2c78STakashi Iwai [CXT5051_HP] = "hp", 183979d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 18405f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1841faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1842f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 18436764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1844461e2c78STakashi Iwai }; 1845461e2c78STakashi Iwai 184634cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 184779d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 18481812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 18495f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1850faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1851461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1852461e2c78STakashi Iwai CXT5051_LAPTOP), 1853461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1854f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1855461e2c78STakashi Iwai {} 1856461e2c78STakashi Iwai }; 1857461e2c78STakashi Iwai 1858461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1859461e2c78STakashi Iwai { 1860461e2c78STakashi Iwai struct conexant_spec *spec; 1861461e2c78STakashi Iwai int board_config; 1862461e2c78STakashi Iwai 18636764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18646764bcefSTakashi Iwai cxt5051_models, 18656764bcefSTakashi Iwai cxt5051_cfg_tbl); 18666764bcefSTakashi Iwai if (board_config < 0) 1867c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18681f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18696764bcefSTakashi Iwai return patch_conexant_auto(codec); 18706764bcefSTakashi Iwai 1871461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1872461e2c78STakashi Iwai if (!spec) 1873461e2c78STakashi Iwai return -ENOMEM; 1874461e2c78STakashi Iwai codec->spec = spec; 18759421f954STakashi Iwai codec->pin_amp_workaround = 1; 1876461e2c78STakashi Iwai 1877461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1878461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1879461e2c78STakashi Iwai 1880461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1881461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1882461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1883461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1884461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1885461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18862c7a3fb3STakashi Iwai spec->num_mixers = 2; 18872c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18882c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1889461e2c78STakashi Iwai spec->num_init_verbs = 1; 1890461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1891461e2c78STakashi Iwai spec->spdif_route = 0; 1892461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1893461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1894461e2c78STakashi Iwai spec->cur_adc = 0; 1895461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1896461e2c78STakashi Iwai 18973507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 18983507e2a8STakashi Iwai 189979d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 190079d7d533STakashi Iwai 1901faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1902461e2c78STakashi Iwai switch (board_config) { 1903461e2c78STakashi Iwai case CXT5051_HP: 1904461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1905461e2c78STakashi Iwai break; 190679d7d533STakashi Iwai case CXT5051_HP_DV6736: 190779d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 190879d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1909faddaa5dSTakashi Iwai spec->auto_mic = 0; 191079d7d533STakashi Iwai break; 1911cd9d95a5SKen Prox case CXT5051_F700: 1912cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1913cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1914faddaa5dSTakashi Iwai spec->auto_mic = 0; 1915faddaa5dSTakashi Iwai break; 1916faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1917faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1918faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1919cd9d95a5SKen Prox break; 1920f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1921f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1922f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1923f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1924f7154de2SHerton Ronaldo Krzesinski break; 1925461e2c78STakashi Iwai } 1926461e2c78STakashi Iwai 19273507e2a8STakashi Iwai if (spec->beep_amp) 1928a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 19293507e2a8STakashi Iwai 1930461e2c78STakashi Iwai return 0; 1931461e2c78STakashi Iwai } 1932461e2c78STakashi Iwai 19330fb67e98SDaniel Drake /* Conexant 5066 specific */ 19340fb67e98SDaniel Drake 193534cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 193634cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 193734cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 193834cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 19390fb67e98SDaniel Drake 1940dbaccc0cSDaniel Drake /* OLPC's microphone port is DC coupled for use with external sensors, 1941dbaccc0cSDaniel Drake * therefore we use a 50% mic bias in order to center the input signal with 1942dbaccc0cSDaniel Drake * the DC input range of the codec. */ 1943dbaccc0cSDaniel Drake #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50 1944dbaccc0cSDaniel Drake 194534cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 19460fb67e98SDaniel Drake { 2, NULL }, 19470fb67e98SDaniel Drake }; 19480fb67e98SDaniel Drake 1949a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1950a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1951a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1952a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1953a3de8ab8STakashi Iwai 19540fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 19550fb67e98SDaniel Drake { 19560fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19570fb67e98SDaniel Drake unsigned int pinctl; 19580fb67e98SDaniel Drake 19593a253445SJohn Baboval snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 19603a253445SJohn Baboval spec->hp_present, spec->cur_eapd); 19610fb67e98SDaniel Drake 19620fb67e98SDaniel Drake /* Port A (HP) */ 1963a3de8ab8STakashi Iwai pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; 1964cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x19, pinctl); 19650fb67e98SDaniel Drake 19660fb67e98SDaniel Drake /* Port D (HP/LO) */ 1967a3de8ab8STakashi Iwai pinctl = spec->cur_eapd ? spec->port_d_mode : 0; 1968a3de8ab8STakashi Iwai if (spec->dell_automute || spec->thinkpad) { 1969a3de8ab8STakashi Iwai /* Mute if Port A is connected */ 1970a3de8ab8STakashi Iwai if (hp_port_a_present(spec)) 19713a253445SJohn Baboval pinctl = 0; 19723a253445SJohn Baboval } else { 1973a3de8ab8STakashi Iwai /* Thinkpad/Dell doesn't give pin-D status */ 1974a3de8ab8STakashi Iwai if (!hp_port_d_present(spec)) 1975a3de8ab8STakashi Iwai pinctl = 0; 19763a253445SJohn Baboval } 1977cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1c, pinctl); 19780fb67e98SDaniel Drake 19790fb67e98SDaniel Drake /* CLASS_D AMP */ 19800fb67e98SDaniel Drake pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1981cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1f, pinctl); 19820fb67e98SDaniel Drake } 19830fb67e98SDaniel Drake 19840fb67e98SDaniel Drake /* turn on/off EAPD (+ mute HP) as a master switch */ 19850fb67e98SDaniel Drake static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, 19860fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 19870fb67e98SDaniel Drake { 19880fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 19890fb67e98SDaniel Drake 19900fb67e98SDaniel Drake if (!cxt_eapd_put(kcontrol, ucontrol)) 19910fb67e98SDaniel Drake return 0; 19920fb67e98SDaniel Drake 19930fb67e98SDaniel Drake cxt5066_update_speaker(codec); 19940fb67e98SDaniel Drake return 1; 19950fb67e98SDaniel Drake } 19960fb67e98SDaniel Drake 1997c4cfe66cSDaniel Drake static const struct hda_input_mux cxt5066_olpc_dc_bias = { 1998c4cfe66cSDaniel Drake .num_items = 3, 1999c4cfe66cSDaniel Drake .items = { 2000c4cfe66cSDaniel Drake { "Off", PIN_IN }, 2001c4cfe66cSDaniel Drake { "50%", PIN_VREF50 }, 2002c4cfe66cSDaniel Drake { "80%", PIN_VREF80 }, 2003c4cfe66cSDaniel Drake }, 2004c4cfe66cSDaniel Drake }; 2005c4cfe66cSDaniel Drake 2006c4cfe66cSDaniel Drake static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) 2007c4cfe66cSDaniel Drake { 2008c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2009c4cfe66cSDaniel Drake /* Even though port F is the DC input, the bias is controlled on port B. 2010c4cfe66cSDaniel Drake * we also leave that port as an active input (but unselected) in DC mode 2011c4cfe66cSDaniel Drake * just in case that is necessary to make the bias setting take effect. */ 2012cdd03cedSTakashi Iwai return snd_hda_set_pin_ctl_cache(codec, 0x1a, 2013c4cfe66cSDaniel Drake cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); 2014c4cfe66cSDaniel Drake } 2015c4cfe66cSDaniel Drake 201675f8991dSDaniel Drake /* OLPC defers mic widget control until when capture is started because the 201775f8991dSDaniel Drake * microphone LED comes on as soon as these settings are put in place. if we 201875f8991dSDaniel Drake * did this before recording, it would give the false indication that recording 201975f8991dSDaniel Drake * is happening when it is not. */ 202075f8991dSDaniel Drake static void cxt5066_olpc_select_mic(struct hda_codec *codec) 20210fb67e98SDaniel Drake { 2022dbaccc0cSDaniel Drake struct conexant_spec *spec = codec->spec; 202375f8991dSDaniel Drake if (!spec->recording) 202475f8991dSDaniel Drake return; 20250fb67e98SDaniel Drake 2026c4cfe66cSDaniel Drake if (spec->dc_enable) { 2027c4cfe66cSDaniel Drake /* in DC mode we ignore presence detection and just use the jack 2028c4cfe66cSDaniel Drake * through our special DC port */ 2029c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2030c4cfe66cSDaniel Drake /* disble internal mic, port C */ 2031c4cfe66cSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2032c4cfe66cSDaniel Drake 2033c4cfe66cSDaniel Drake /* enable DC capture, port F */ 2034c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2035c4cfe66cSDaniel Drake {}, 2036c4cfe66cSDaniel Drake }; 2037c4cfe66cSDaniel Drake 2038c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2039c4cfe66cSDaniel Drake /* port B input disabled (and bias set) through the following call */ 2040c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 2041c4cfe66cSDaniel Drake return; 2042c4cfe66cSDaniel Drake } 2043c4cfe66cSDaniel Drake 2044c4cfe66cSDaniel Drake /* disable DC (port F) */ 2045cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1e, 0); 2046c4cfe66cSDaniel Drake 204775f8991dSDaniel Drake /* external mic, port B */ 2048cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, 204975f8991dSDaniel Drake spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); 20500fb67e98SDaniel Drake 205175f8991dSDaniel Drake /* internal mic, port C */ 2052cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, 205375f8991dSDaniel Drake spec->ext_mic_present ? 0 : PIN_VREF80); 205475f8991dSDaniel Drake } 20550fb67e98SDaniel Drake 205675f8991dSDaniel Drake /* toggle input of built-in and mic jack appropriately */ 205775f8991dSDaniel Drake static void cxt5066_olpc_automic(struct hda_codec *codec) 205875f8991dSDaniel Drake { 205975f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 20600fb67e98SDaniel Drake unsigned int present; 20610fb67e98SDaniel Drake 2062c4cfe66cSDaniel Drake if (spec->dc_enable) /* don't do presence detection in DC mode */ 2063c4cfe66cSDaniel Drake return; 2064c4cfe66cSDaniel Drake 206575f8991dSDaniel Drake present = snd_hda_codec_read(codec, 0x1a, 0, 206675f8991dSDaniel Drake AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 206775f8991dSDaniel Drake if (present) 20680fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone detected\n"); 206975f8991dSDaniel Drake else 20700fb67e98SDaniel Drake snd_printdd("CXT5066: external microphone absent\n"); 207175f8991dSDaniel Drake 207275f8991dSDaniel Drake snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 207375f8991dSDaniel Drake present ? 0 : 1); 207475f8991dSDaniel Drake spec->ext_mic_present = !!present; 207575f8991dSDaniel Drake 207675f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 20770fb67e98SDaniel Drake } 20780fb67e98SDaniel Drake 207995a618bdSEinar Rünkaru /* toggle input of built-in digital mic and mic jack appropriately */ 208095a618bdSEinar Rünkaru static void cxt5066_vostro_automic(struct hda_codec *codec) 208195a618bdSEinar Rünkaru { 208295a618bdSEinar Rünkaru unsigned int present; 208395a618bdSEinar Rünkaru 208495a618bdSEinar Rünkaru struct hda_verb ext_mic_present[] = { 208595a618bdSEinar Rünkaru /* enable external mic, port B */ 208675f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 208795a618bdSEinar Rünkaru 208895a618bdSEinar Rünkaru /* switch to external mic input */ 208995a618bdSEinar Rünkaru {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 209095a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 209195a618bdSEinar Rünkaru 209295a618bdSEinar Rünkaru /* disable internal digital mic */ 209395a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 209495a618bdSEinar Rünkaru {} 209595a618bdSEinar Rünkaru }; 209634cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 209795a618bdSEinar Rünkaru /* enable internal mic, port C */ 209895a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 209995a618bdSEinar Rünkaru 210095a618bdSEinar Rünkaru /* switch to internal mic input */ 210195a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 210295a618bdSEinar Rünkaru 210395a618bdSEinar Rünkaru /* disable external mic, port B */ 210495a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 210595a618bdSEinar Rünkaru {} 210695a618bdSEinar Rünkaru }; 210795a618bdSEinar Rünkaru 210895a618bdSEinar Rünkaru present = snd_hda_jack_detect(codec, 0x1a); 210995a618bdSEinar Rünkaru if (present) { 211095a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone detected\n"); 211195a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 211295a618bdSEinar Rünkaru } else { 211395a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone absent\n"); 211495a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_absent); 211595a618bdSEinar Rünkaru } 211695a618bdSEinar Rünkaru } 211795a618bdSEinar Rünkaru 2118cfd3d8dcSGreg Alexander /* toggle input of built-in digital mic and mic jack appropriately */ 2119cfd3d8dcSGreg Alexander static void cxt5066_ideapad_automic(struct hda_codec *codec) 2120cfd3d8dcSGreg Alexander { 2121cfd3d8dcSGreg Alexander unsigned int present; 2122cfd3d8dcSGreg Alexander 2123cfd3d8dcSGreg Alexander struct hda_verb ext_mic_present[] = { 2124cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 2125cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2126cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2127cfd3d8dcSGreg Alexander {} 2128cfd3d8dcSGreg Alexander }; 212934cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 2130cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 2131cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2132cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2133cfd3d8dcSGreg Alexander {} 2134cfd3d8dcSGreg Alexander }; 2135cfd3d8dcSGreg Alexander 2136cfd3d8dcSGreg Alexander present = snd_hda_jack_detect(codec, 0x1b); 2137cfd3d8dcSGreg Alexander if (present) { 2138cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone detected\n"); 2139cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2140cfd3d8dcSGreg Alexander } else { 2141cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone absent\n"); 2142cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_absent); 2143cfd3d8dcSGreg Alexander } 2144cfd3d8dcSGreg Alexander } 2145cfd3d8dcSGreg Alexander 2146a1d6906eSDavid Henningsson 2147a1d6906eSDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2148a1d6906eSDavid Henningsson static void cxt5066_asus_automic(struct hda_codec *codec) 2149a1d6906eSDavid Henningsson { 2150a1d6906eSDavid Henningsson unsigned int present; 2151a1d6906eSDavid Henningsson 2152a1d6906eSDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2153a1d6906eSDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2154a1d6906eSDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2155a1d6906eSDavid Henningsson present ? 1 : 0); 2156a1d6906eSDavid Henningsson } 2157a1d6906eSDavid Henningsson 2158a1d6906eSDavid Henningsson 2159048e78a5SDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2160048e78a5SDavid Henningsson static void cxt5066_hp_laptop_automic(struct hda_codec *codec) 2161048e78a5SDavid Henningsson { 2162048e78a5SDavid Henningsson unsigned int present; 2163048e78a5SDavid Henningsson 2164048e78a5SDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2165048e78a5SDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2166048e78a5SDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2167048e78a5SDavid Henningsson present ? 1 : 3); 2168048e78a5SDavid Henningsson } 2169048e78a5SDavid Henningsson 2170048e78a5SDavid Henningsson 21717b2bfdbcSJens Taprogge /* toggle input of built-in digital mic and mic jack appropriately 21727b2bfdbcSJens Taprogge order is: external mic -> dock mic -> interal mic */ 21737b2bfdbcSJens Taprogge static void cxt5066_thinkpad_automic(struct hda_codec *codec) 21747b2bfdbcSJens Taprogge { 21757b2bfdbcSJens Taprogge unsigned int ext_present, dock_present; 21767b2bfdbcSJens Taprogge 217734cbe3a6STakashi Iwai static const struct hda_verb ext_mic_present[] = { 21787b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21797b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 21807b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21817b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21827b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21837b2bfdbcSJens Taprogge {} 21847b2bfdbcSJens Taprogge }; 218534cbe3a6STakashi Iwai static const struct hda_verb dock_mic_present[] = { 21867b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 21877b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 21887b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 21897b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21907b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21917b2bfdbcSJens Taprogge {} 21927b2bfdbcSJens Taprogge }; 219334cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 21947b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 21957b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 21967b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21977b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 21987b2bfdbcSJens Taprogge {} 21997b2bfdbcSJens Taprogge }; 22007b2bfdbcSJens Taprogge 22017b2bfdbcSJens Taprogge ext_present = snd_hda_jack_detect(codec, 0x1b); 22027b2bfdbcSJens Taprogge dock_present = snd_hda_jack_detect(codec, 0x1a); 22037b2bfdbcSJens Taprogge if (ext_present) { 22047b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone detected\n"); 22057b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 22067b2bfdbcSJens Taprogge } else if (dock_present) { 22077b2bfdbcSJens Taprogge snd_printdd("CXT5066: dock microphone detected\n"); 22087b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 22097b2bfdbcSJens Taprogge } else { 22107b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone absent\n"); 22117b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_absent); 22127b2bfdbcSJens Taprogge } 22137b2bfdbcSJens Taprogge } 22147b2bfdbcSJens Taprogge 22150fb67e98SDaniel Drake /* mute internal speaker if HP is plugged */ 22160fb67e98SDaniel Drake static void cxt5066_hp_automute(struct hda_codec *codec) 22170fb67e98SDaniel Drake { 22180fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 22190fb67e98SDaniel Drake unsigned int portA, portD; 22200fb67e98SDaniel Drake 22210fb67e98SDaniel Drake /* Port A */ 2222d56757abSTakashi Iwai portA = snd_hda_jack_detect(codec, 0x19); 22230fb67e98SDaniel Drake 22240fb67e98SDaniel Drake /* Port D */ 2225d56757abSTakashi Iwai portD = snd_hda_jack_detect(codec, 0x1c); 22260fb67e98SDaniel Drake 2227a3de8ab8STakashi Iwai spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2228a3de8ab8STakashi Iwai spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 22290fb67e98SDaniel Drake snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 22300fb67e98SDaniel Drake portA, portD, spec->hp_present); 22310fb67e98SDaniel Drake cxt5066_update_speaker(codec); 22320fb67e98SDaniel Drake } 22330fb67e98SDaniel Drake 223402b6b5b6SDavid Henningsson /* Dispatch the right mic autoswitch function */ 223502b6b5b6SDavid Henningsson static void cxt5066_automic(struct hda_codec *codec) 223602b6b5b6SDavid Henningsson { 223702b6b5b6SDavid Henningsson struct conexant_spec *spec = codec->spec; 223802b6b5b6SDavid Henningsson 223902b6b5b6SDavid Henningsson if (spec->dell_vostro) 224002b6b5b6SDavid Henningsson cxt5066_vostro_automic(codec); 224102b6b5b6SDavid Henningsson else if (spec->ideapad) 224202b6b5b6SDavid Henningsson cxt5066_ideapad_automic(codec); 224302b6b5b6SDavid Henningsson else if (spec->thinkpad) 224402b6b5b6SDavid Henningsson cxt5066_thinkpad_automic(codec); 224502b6b5b6SDavid Henningsson else if (spec->hp_laptop) 224602b6b5b6SDavid Henningsson cxt5066_hp_laptop_automic(codec); 2247a1d6906eSDavid Henningsson else if (spec->asus) 2248a1d6906eSDavid Henningsson cxt5066_asus_automic(codec); 224902b6b5b6SDavid Henningsson } 225002b6b5b6SDavid Henningsson 22510fb67e98SDaniel Drake /* unsolicited event for jack sensing */ 225275f8991dSDaniel Drake static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 22530fb67e98SDaniel Drake { 2254c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 22550fb67e98SDaniel Drake snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 22560fb67e98SDaniel Drake switch (res >> 26) { 22570fb67e98SDaniel Drake case CONEXANT_HP_EVENT: 22580fb67e98SDaniel Drake cxt5066_hp_automute(codec); 22590fb67e98SDaniel Drake break; 22600fb67e98SDaniel Drake case CONEXANT_MIC_EVENT: 2261c4cfe66cSDaniel Drake /* ignore mic events in DC mode; we're always using the jack */ 2262c4cfe66cSDaniel Drake if (!spec->dc_enable) 226375f8991dSDaniel Drake cxt5066_olpc_automic(codec); 22640fb67e98SDaniel Drake break; 22650fb67e98SDaniel Drake } 22660fb67e98SDaniel Drake } 22670fb67e98SDaniel Drake 226895a618bdSEinar Rünkaru /* unsolicited event for jack sensing */ 226902b6b5b6SDavid Henningsson static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 227095a618bdSEinar Rünkaru { 227102b6b5b6SDavid Henningsson snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 227295a618bdSEinar Rünkaru switch (res >> 26) { 227395a618bdSEinar Rünkaru case CONEXANT_HP_EVENT: 227495a618bdSEinar Rünkaru cxt5066_hp_automute(codec); 227595a618bdSEinar Rünkaru break; 227695a618bdSEinar Rünkaru case CONEXANT_MIC_EVENT: 227702b6b5b6SDavid Henningsson cxt5066_automic(codec); 227895a618bdSEinar Rünkaru break; 227995a618bdSEinar Rünkaru } 228095a618bdSEinar Rünkaru } 228195a618bdSEinar Rünkaru 22827b2bfdbcSJens Taprogge 22830fb67e98SDaniel Drake static const struct hda_input_mux cxt5066_analog_mic_boost = { 22840fb67e98SDaniel Drake .num_items = 5, 22850fb67e98SDaniel Drake .items = { 22860fb67e98SDaniel Drake { "0dB", 0 }, 22870fb67e98SDaniel Drake { "10dB", 1 }, 22880fb67e98SDaniel Drake { "20dB", 2 }, 22890fb67e98SDaniel Drake { "30dB", 3 }, 22900fb67e98SDaniel Drake { "40dB", 4 }, 22910fb67e98SDaniel Drake }, 22920fb67e98SDaniel Drake }; 22930fb67e98SDaniel Drake 2294cfd3d8dcSGreg Alexander static void cxt5066_set_mic_boost(struct hda_codec *codec) 2295c4cfe66cSDaniel Drake { 2296c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2297cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x17, 0, 2298c4cfe66cSDaniel Drake AC_VERB_SET_AMP_GAIN_MUTE, 2299c4cfe66cSDaniel Drake AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2300c4cfe66cSDaniel Drake cxt5066_analog_mic_boost.items[spec->mic_boost].index); 23017b2bfdbcSJens Taprogge if (spec->ideapad || spec->thinkpad) { 2302cfd3d8dcSGreg Alexander /* adjust the internal mic as well...it is not through 0x17 */ 2303cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x23, 0, 2304cfd3d8dcSGreg Alexander AC_VERB_SET_AMP_GAIN_MUTE, 2305cfd3d8dcSGreg Alexander AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | 2306cfd3d8dcSGreg Alexander cxt5066_analog_mic_boost. 2307cfd3d8dcSGreg Alexander items[spec->mic_boost].index); 2308cfd3d8dcSGreg Alexander } 2309c4cfe66cSDaniel Drake } 2310c4cfe66cSDaniel Drake 23110fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 23120fb67e98SDaniel Drake struct snd_ctl_elem_info *uinfo) 23130fb67e98SDaniel Drake { 23140fb67e98SDaniel Drake return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); 23150fb67e98SDaniel Drake } 23160fb67e98SDaniel Drake 23170fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, 23180fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23190fb67e98SDaniel Drake { 23200fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2321c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2322c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->mic_boost; 23230fb67e98SDaniel Drake return 0; 23240fb67e98SDaniel Drake } 23250fb67e98SDaniel Drake 23260fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, 23270fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 23280fb67e98SDaniel Drake { 23290fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2330c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 23310fb67e98SDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 23320fb67e98SDaniel Drake unsigned int idx; 23330fb67e98SDaniel Drake idx = ucontrol->value.enumerated.item[0]; 23340fb67e98SDaniel Drake if (idx >= imux->num_items) 23350fb67e98SDaniel Drake idx = imux->num_items - 1; 23360fb67e98SDaniel Drake 2337c4cfe66cSDaniel Drake spec->mic_boost = idx; 2338c4cfe66cSDaniel Drake if (!spec->dc_enable) 2339c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2340c4cfe66cSDaniel Drake return 1; 2341c4cfe66cSDaniel Drake } 23420fb67e98SDaniel Drake 2343c4cfe66cSDaniel Drake static void cxt5066_enable_dc(struct hda_codec *codec) 2344c4cfe66cSDaniel Drake { 2345c4cfe66cSDaniel Drake const struct hda_verb enable_dc_mode[] = { 2346c4cfe66cSDaniel Drake /* disable gain */ 2347c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2348c4cfe66cSDaniel Drake 2349c4cfe66cSDaniel Drake /* switch to DC input */ 2350c4cfe66cSDaniel Drake {0x17, AC_VERB_SET_CONNECT_SEL, 3}, 2351c4cfe66cSDaniel Drake {} 2352c4cfe66cSDaniel Drake }; 2353c4cfe66cSDaniel Drake 2354c4cfe66cSDaniel Drake /* configure as input source */ 2355c4cfe66cSDaniel Drake snd_hda_sequence_write(codec, enable_dc_mode); 2356c4cfe66cSDaniel Drake cxt5066_olpc_select_mic(codec); /* also sets configured bias */ 2357c4cfe66cSDaniel Drake } 2358c4cfe66cSDaniel Drake 2359c4cfe66cSDaniel Drake static void cxt5066_disable_dc(struct hda_codec *codec) 2360c4cfe66cSDaniel Drake { 2361c4cfe66cSDaniel Drake /* reconfigure input source */ 2362c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2363c4cfe66cSDaniel Drake /* automic also selects the right mic if we're recording */ 2364c4cfe66cSDaniel Drake cxt5066_olpc_automic(codec); 2365c4cfe66cSDaniel Drake } 2366c4cfe66cSDaniel Drake 2367c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, 2368c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2369c4cfe66cSDaniel Drake { 2370c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2371c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2372c4cfe66cSDaniel Drake ucontrol->value.integer.value[0] = spec->dc_enable; 2373c4cfe66cSDaniel Drake return 0; 2374c4cfe66cSDaniel Drake } 2375c4cfe66cSDaniel Drake 2376c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, 2377c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2378c4cfe66cSDaniel Drake { 2379c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2380c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2381c4cfe66cSDaniel Drake int dc_enable = !!ucontrol->value.integer.value[0]; 2382c4cfe66cSDaniel Drake 2383c4cfe66cSDaniel Drake if (dc_enable == spec->dc_enable) 2384c4cfe66cSDaniel Drake return 0; 2385c4cfe66cSDaniel Drake 2386c4cfe66cSDaniel Drake spec->dc_enable = dc_enable; 2387c4cfe66cSDaniel Drake if (dc_enable) 2388c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2389c4cfe66cSDaniel Drake else 2390c4cfe66cSDaniel Drake cxt5066_disable_dc(codec); 2391c4cfe66cSDaniel Drake 2392c4cfe66cSDaniel Drake return 1; 2393c4cfe66cSDaniel Drake } 2394c4cfe66cSDaniel Drake 2395c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 2396c4cfe66cSDaniel Drake struct snd_ctl_elem_info *uinfo) 2397c4cfe66cSDaniel Drake { 2398c4cfe66cSDaniel Drake return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); 2399c4cfe66cSDaniel Drake } 2400c4cfe66cSDaniel Drake 2401c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 2402c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2403c4cfe66cSDaniel Drake { 2404c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2405c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2406c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 2407c4cfe66cSDaniel Drake return 0; 2408c4cfe66cSDaniel Drake } 2409c4cfe66cSDaniel Drake 2410c4cfe66cSDaniel Drake static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 2411c4cfe66cSDaniel Drake struct snd_ctl_elem_value *ucontrol) 2412c4cfe66cSDaniel Drake { 2413c4cfe66cSDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2414c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2415c4cfe66cSDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2416c4cfe66cSDaniel Drake unsigned int idx; 2417c4cfe66cSDaniel Drake 2418c4cfe66cSDaniel Drake idx = ucontrol->value.enumerated.item[0]; 2419c4cfe66cSDaniel Drake if (idx >= imux->num_items) 2420c4cfe66cSDaniel Drake idx = imux->num_items - 1; 2421c4cfe66cSDaniel Drake 2422c4cfe66cSDaniel Drake spec->dc_input_bias = idx; 2423c4cfe66cSDaniel Drake if (spec->dc_enable) 2424c4cfe66cSDaniel Drake cxt5066_set_olpc_dc_bias(codec); 24250fb67e98SDaniel Drake return 1; 24260fb67e98SDaniel Drake } 24270fb67e98SDaniel Drake 242875f8991dSDaniel Drake static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) 242975f8991dSDaniel Drake { 243075f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 243175f8991dSDaniel Drake /* mark as recording and configure the microphone widget so that the 243275f8991dSDaniel Drake * recording LED comes on. */ 243375f8991dSDaniel Drake spec->recording = 1; 243475f8991dSDaniel Drake cxt5066_olpc_select_mic(codec); 243575f8991dSDaniel Drake } 243675f8991dSDaniel Drake 243775f8991dSDaniel Drake static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) 243875f8991dSDaniel Drake { 243975f8991dSDaniel Drake struct conexant_spec *spec = codec->spec; 244075f8991dSDaniel Drake const struct hda_verb disable_mics[] = { 244175f8991dSDaniel Drake /* disable external mic, port B */ 244275f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 244375f8991dSDaniel Drake 244475f8991dSDaniel Drake /* disble internal mic, port C */ 244575f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2446c4cfe66cSDaniel Drake 2447c4cfe66cSDaniel Drake /* disable DC capture, port F */ 2448c4cfe66cSDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 244975f8991dSDaniel Drake {}, 245075f8991dSDaniel Drake }; 245175f8991dSDaniel Drake 245275f8991dSDaniel Drake snd_hda_sequence_write(codec, disable_mics); 245375f8991dSDaniel Drake spec->recording = 0; 245475f8991dSDaniel Drake } 245575f8991dSDaniel Drake 2456f6a2491cSAndy Robinson static void conexant_check_dig_outs(struct hda_codec *codec, 245734cbe3a6STakashi Iwai const hda_nid_t *dig_pins, 2458f6a2491cSAndy Robinson int num_pins) 2459f6a2491cSAndy Robinson { 2460f6a2491cSAndy Robinson struct conexant_spec *spec = codec->spec; 2461f6a2491cSAndy Robinson hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; 2462f6a2491cSAndy Robinson int i; 2463f6a2491cSAndy Robinson 2464f6a2491cSAndy Robinson for (i = 0; i < num_pins; i++, dig_pins++) { 2465f6a2491cSAndy Robinson unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); 2466f6a2491cSAndy Robinson if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) 2467f6a2491cSAndy Robinson continue; 2468f6a2491cSAndy Robinson if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) 2469f6a2491cSAndy Robinson continue; 2470f6a2491cSAndy Robinson } 2471f6a2491cSAndy Robinson } 2472f6a2491cSAndy Robinson 247334cbe3a6STakashi Iwai static const struct hda_input_mux cxt5066_capture_source = { 24740fb67e98SDaniel Drake .num_items = 4, 24750fb67e98SDaniel Drake .items = { 24760fb67e98SDaniel Drake { "Mic B", 0 }, 24770fb67e98SDaniel Drake { "Mic C", 1 }, 24780fb67e98SDaniel Drake { "Mic E", 2 }, 24790fb67e98SDaniel Drake { "Mic F", 3 }, 24800fb67e98SDaniel Drake }, 24810fb67e98SDaniel Drake }; 24820fb67e98SDaniel Drake 248334cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { 24840fb67e98SDaniel Drake .ops = &snd_hda_bind_vol, 24850fb67e98SDaniel Drake .values = { 24860fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24870fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24880fb67e98SDaniel Drake 0 24890fb67e98SDaniel Drake }, 24900fb67e98SDaniel Drake }; 24910fb67e98SDaniel Drake 249234cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { 24930fb67e98SDaniel Drake .ops = &snd_hda_bind_sw, 24940fb67e98SDaniel Drake .values = { 24950fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 24960fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 24970fb67e98SDaniel Drake 0 24980fb67e98SDaniel Drake }, 24990fb67e98SDaniel Drake }; 25000fb67e98SDaniel Drake 250134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master[] = { 25020fb67e98SDaniel Drake HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 25030fb67e98SDaniel Drake {} 25040fb67e98SDaniel Drake }; 25050fb67e98SDaniel Drake 250634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { 25070fb67e98SDaniel Drake { 25080fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25090fb67e98SDaniel Drake .name = "Master Playback Volume", 25100fb67e98SDaniel Drake .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 25110fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_READ | 25120fb67e98SDaniel Drake SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, 25135e26dfd0SJaroslav Kysela .subdevice = HDA_SUBDEV_AMP_FLAG, 25140fb67e98SDaniel Drake .info = snd_hda_mixer_amp_volume_info, 25150fb67e98SDaniel Drake .get = snd_hda_mixer_amp_volume_get, 25160fb67e98SDaniel Drake .put = snd_hda_mixer_amp_volume_put, 25170fb67e98SDaniel Drake .tlv = { .c = snd_hda_mixer_amp_tlv }, 25180fb67e98SDaniel Drake /* offset by 28 volume steps to limit minimum gain to -46dB */ 25190fb67e98SDaniel Drake .private_value = 25200fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), 25210fb67e98SDaniel Drake }, 25220fb67e98SDaniel Drake {} 25230fb67e98SDaniel Drake }; 25240fb67e98SDaniel Drake 252534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { 2526c4cfe66cSDaniel Drake { 2527c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2528c4cfe66cSDaniel Drake .name = "DC Mode Enable Switch", 2529c4cfe66cSDaniel Drake .info = snd_ctl_boolean_mono_info, 2530c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_get, 2531c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_put, 2532c4cfe66cSDaniel Drake }, 2533c4cfe66cSDaniel Drake { 2534c4cfe66cSDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2535c4cfe66cSDaniel Drake .name = "DC Input Bias Enum", 2536c4cfe66cSDaniel Drake .info = cxt5066_olpc_dc_bias_enum_info, 2537c4cfe66cSDaniel Drake .get = cxt5066_olpc_dc_bias_enum_get, 2538c4cfe66cSDaniel Drake .put = cxt5066_olpc_dc_bias_enum_put, 2539c4cfe66cSDaniel Drake }, 2540c4cfe66cSDaniel Drake {} 2541c4cfe66cSDaniel Drake }; 2542c4cfe66cSDaniel Drake 254334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixers[] = { 25440fb67e98SDaniel Drake { 25450fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 25460fb67e98SDaniel Drake .name = "Master Playback Switch", 25470fb67e98SDaniel Drake .info = cxt_eapd_info, 25480fb67e98SDaniel Drake .get = cxt_eapd_get, 25490fb67e98SDaniel Drake .put = cxt5066_hp_master_sw_put, 25500fb67e98SDaniel Drake .private_value = 0x1d, 25510fb67e98SDaniel Drake }, 25520fb67e98SDaniel Drake 25530fb67e98SDaniel Drake { 25540fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2555c4cfe66cSDaniel Drake .name = "Analog Mic Boost Capture Enum", 25560fb67e98SDaniel Drake .info = cxt5066_mic_boost_mux_enum_info, 25570fb67e98SDaniel Drake .get = cxt5066_mic_boost_mux_enum_get, 25580fb67e98SDaniel Drake .put = cxt5066_mic_boost_mux_enum_put, 25590fb67e98SDaniel Drake }, 25600fb67e98SDaniel Drake 25610fb67e98SDaniel Drake HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), 25620fb67e98SDaniel Drake HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), 25630fb67e98SDaniel Drake {} 25640fb67e98SDaniel Drake }; 25650fb67e98SDaniel Drake 256634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { 2567254bba6aSEinar Rünkaru { 2568254bba6aSEinar Rünkaru .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 256928c4edb7SDavid Henningsson .name = "Internal Mic Boost Capture Enum", 2570254bba6aSEinar Rünkaru .info = cxt5066_mic_boost_mux_enum_info, 2571254bba6aSEinar Rünkaru .get = cxt5066_mic_boost_mux_enum_get, 2572254bba6aSEinar Rünkaru .put = cxt5066_mic_boost_mux_enum_put, 2573254bba6aSEinar Rünkaru .private_value = 0x23 | 0x100, 2574254bba6aSEinar Rünkaru }, 2575254bba6aSEinar Rünkaru {} 2576254bba6aSEinar Rünkaru }; 2577254bba6aSEinar Rünkaru 257834cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs[] = { 25790fb67e98SDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 25800fb67e98SDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 25810fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 25820fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 25830fb67e98SDaniel Drake 25840fb67e98SDaniel Drake /* Speakers */ 25850fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 25860fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25870fb67e98SDaniel Drake 25880fb67e98SDaniel Drake /* HP, Amp */ 25890fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25900fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25910fb67e98SDaniel Drake 25920fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 25930fb67e98SDaniel Drake {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 25940fb67e98SDaniel Drake 25950fb67e98SDaniel Drake /* DAC1 */ 25960fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 25970fb67e98SDaniel Drake 25980fb67e98SDaniel Drake /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 25990fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26000fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26010fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 26020fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26030fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 26040fb67e98SDaniel Drake 26050fb67e98SDaniel Drake /* no digital microphone support yet */ 26060fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26070fb67e98SDaniel Drake 26080fb67e98SDaniel Drake /* Audio input selector */ 26090fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26100fb67e98SDaniel Drake 26110fb67e98SDaniel Drake /* SPDIF route: PCM */ 26120fb67e98SDaniel Drake {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 26130fb67e98SDaniel Drake {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 26140fb67e98SDaniel Drake 26150fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26160fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26170fb67e98SDaniel Drake 26180fb67e98SDaniel Drake /* EAPD */ 26190fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26200fb67e98SDaniel Drake 26210fb67e98SDaniel Drake /* not handling these yet */ 26220fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26230fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26240fb67e98SDaniel Drake {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26250fb67e98SDaniel Drake {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26260fb67e98SDaniel Drake {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26270fb67e98SDaniel Drake {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26280fb67e98SDaniel Drake {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26290fb67e98SDaniel Drake {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 26300fb67e98SDaniel Drake { } /* end */ 26310fb67e98SDaniel Drake }; 26320fb67e98SDaniel Drake 263334cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_olpc[] = { 26340fb67e98SDaniel Drake /* Port A: headphones */ 26350fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 26360fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26370fb67e98SDaniel Drake 26380fb67e98SDaniel Drake /* Port B: external microphone */ 263975f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26400fb67e98SDaniel Drake 26410fb67e98SDaniel Drake /* Port C: internal microphone */ 264275f8991dSDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26430fb67e98SDaniel Drake 26440fb67e98SDaniel Drake /* Port D: unused */ 26450fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26460fb67e98SDaniel Drake 26470fb67e98SDaniel Drake /* Port E: unused, but has primary EAPD */ 26480fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26490fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 26500fb67e98SDaniel Drake 2651c4cfe66cSDaniel Drake /* Port F: external DC input through microphone port */ 26520fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26530fb67e98SDaniel Drake 26540fb67e98SDaniel Drake /* Port G: internal speakers */ 26550fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 26560fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 26570fb67e98SDaniel Drake 26580fb67e98SDaniel Drake /* DAC1 */ 26590fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 26600fb67e98SDaniel Drake 26610fb67e98SDaniel Drake /* DAC2: unused */ 26620fb67e98SDaniel Drake {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 26630fb67e98SDaniel Drake 26640fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 26650fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26660fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26670fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26680fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26690fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26700fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26710fb67e98SDaniel Drake {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26720fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 26730fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 26740fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 26750fb67e98SDaniel Drake {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 26760fb67e98SDaniel Drake 26770fb67e98SDaniel Drake /* Disable digital microphone port */ 26780fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26790fb67e98SDaniel Drake 26800fb67e98SDaniel Drake /* Audio input selectors */ 26810fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 26820fb67e98SDaniel Drake {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 26830fb67e98SDaniel Drake 26840fb67e98SDaniel Drake /* Disable SPDIF */ 26850fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26860fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 26870fb67e98SDaniel Drake 26880fb67e98SDaniel Drake /* enable unsolicited events for Port A and B */ 26890fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 26900fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 26910fb67e98SDaniel Drake { } /* end */ 26920fb67e98SDaniel Drake }; 26930fb67e98SDaniel Drake 269434cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_vostro[] = { 269595a618bdSEinar Rünkaru /* Port A: headphones */ 269695a618bdSEinar Rünkaru {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 269795a618bdSEinar Rünkaru {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 269895a618bdSEinar Rünkaru 269995a618bdSEinar Rünkaru /* Port B: external microphone */ 270095a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270195a618bdSEinar Rünkaru 270295a618bdSEinar Rünkaru /* Port C: unused */ 270395a618bdSEinar Rünkaru {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270495a618bdSEinar Rünkaru 270595a618bdSEinar Rünkaru /* Port D: unused */ 270695a618bdSEinar Rünkaru {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 270795a618bdSEinar Rünkaru 270895a618bdSEinar Rünkaru /* Port E: unused, but has primary EAPD */ 270995a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271095a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 271195a618bdSEinar Rünkaru 271295a618bdSEinar Rünkaru /* Port F: unused */ 271395a618bdSEinar Rünkaru {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 271495a618bdSEinar Rünkaru 271595a618bdSEinar Rünkaru /* Port G: internal speakers */ 271695a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 271795a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 271895a618bdSEinar Rünkaru 271995a618bdSEinar Rünkaru /* DAC1 */ 272095a618bdSEinar Rünkaru {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 272195a618bdSEinar Rünkaru 272295a618bdSEinar Rünkaru /* DAC2: unused */ 272395a618bdSEinar Rünkaru {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 272495a618bdSEinar Rünkaru 272595a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 272695a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 272795a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 272895a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 272995a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273095a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273195a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273295a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273395a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 273495a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 273595a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 273695a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 273795a618bdSEinar Rünkaru 273895a618bdSEinar Rünkaru /* Digital microphone port */ 273995a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 274095a618bdSEinar Rünkaru 274195a618bdSEinar Rünkaru /* Audio input selectors */ 274295a618bdSEinar Rünkaru {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 274395a618bdSEinar Rünkaru {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 274495a618bdSEinar Rünkaru 274595a618bdSEinar Rünkaru /* Disable SPDIF */ 274695a618bdSEinar Rünkaru {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274795a618bdSEinar Rünkaru {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 274895a618bdSEinar Rünkaru 274995a618bdSEinar Rünkaru /* enable unsolicited events for Port A and B */ 275095a618bdSEinar Rünkaru {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 275195a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 275295a618bdSEinar Rünkaru { } /* end */ 275395a618bdSEinar Rünkaru }; 275495a618bdSEinar Rünkaru 275534cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_ideapad[] = { 2756cfd3d8dcSGreg Alexander {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 2757cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 2758cfd3d8dcSGreg Alexander {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 2759cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 2760cfd3d8dcSGreg Alexander 2761cfd3d8dcSGreg Alexander /* Speakers */ 2762cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2763cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2764cfd3d8dcSGreg Alexander 2765cfd3d8dcSGreg Alexander /* HP, Amp */ 2766cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2767cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2768cfd3d8dcSGreg Alexander 2769cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2770cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2771cfd3d8dcSGreg Alexander 2772cfd3d8dcSGreg Alexander /* DAC1 */ 2773cfd3d8dcSGreg Alexander {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2774cfd3d8dcSGreg Alexander 2775cfd3d8dcSGreg Alexander /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 2776cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 2777cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2778cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 2779cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2780cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2781cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 2782cfd3d8dcSGreg Alexander 2783cfd3d8dcSGreg Alexander /* Audio input selector */ 2784cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 2785cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 2786cfd3d8dcSGreg Alexander 2787cfd3d8dcSGreg Alexander /* SPDIF route: PCM */ 2788cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 2789cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 2790cfd3d8dcSGreg Alexander 2791cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2792cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2793cfd3d8dcSGreg Alexander 2794cfd3d8dcSGreg Alexander /* internal microphone */ 279528c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 2796cfd3d8dcSGreg Alexander 2797cfd3d8dcSGreg Alexander /* EAPD */ 2798cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2799cfd3d8dcSGreg Alexander 2800cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2801cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2802cfd3d8dcSGreg Alexander { } /* end */ 2803cfd3d8dcSGreg Alexander }; 2804cfd3d8dcSGreg Alexander 280534cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { 28067b2bfdbcSJens Taprogge {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 28077b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 28087b2bfdbcSJens Taprogge 28097b2bfdbcSJens Taprogge /* Port G: internal speakers */ 28107b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28117b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28127b2bfdbcSJens Taprogge 28137b2bfdbcSJens Taprogge /* Port A: HP, Amp */ 28147b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28157b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28167b2bfdbcSJens Taprogge 28177b2bfdbcSJens Taprogge /* Port B: Mic Dock */ 28187b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28197b2bfdbcSJens Taprogge 28207b2bfdbcSJens Taprogge /* Port C: Mic */ 28217b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28227b2bfdbcSJens Taprogge 28237b2bfdbcSJens Taprogge /* Port D: HP Dock, Amp */ 28247b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 28257b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 28267b2bfdbcSJens Taprogge 28277b2bfdbcSJens Taprogge /* DAC1 */ 28287b2bfdbcSJens Taprogge {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 28297b2bfdbcSJens Taprogge 28307b2bfdbcSJens Taprogge /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 28317b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 28327b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 28337b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 28347b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 28357b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 28367b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 28377b2bfdbcSJens Taprogge 28387b2bfdbcSJens Taprogge /* Audio input selector */ 28397b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 28407b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 28417b2bfdbcSJens Taprogge 28427b2bfdbcSJens Taprogge /* SPDIF route: PCM */ 28437b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 28447b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 28457b2bfdbcSJens Taprogge 28467b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28477b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28487b2bfdbcSJens Taprogge 28497b2bfdbcSJens Taprogge /* internal microphone */ 285028c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 28517b2bfdbcSJens Taprogge 28527b2bfdbcSJens Taprogge /* EAPD */ 28537b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 28547b2bfdbcSJens Taprogge 28557b2bfdbcSJens Taprogge /* enable unsolicited events for Port A, B, C and D */ 28567b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28577b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 28587b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28597b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 28607b2bfdbcSJens Taprogge { } /* end */ 28617b2bfdbcSJens Taprogge }; 28627b2bfdbcSJens Taprogge 286334cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { 28640fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 28650fb67e98SDaniel Drake { } /* end */ 28660fb67e98SDaniel Drake }; 28670fb67e98SDaniel Drake 2868048e78a5SDavid Henningsson 286934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { 2870048e78a5SDavid Henningsson {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, 2871048e78a5SDavid Henningsson {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2872048e78a5SDavid Henningsson {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2873048e78a5SDavid Henningsson { } /* end */ 2874048e78a5SDavid Henningsson }; 2875048e78a5SDavid Henningsson 28760fb67e98SDaniel Drake /* initialize jack-sensing, too */ 28770fb67e98SDaniel Drake static int cxt5066_init(struct hda_codec *codec) 28780fb67e98SDaniel Drake { 28790fb67e98SDaniel Drake snd_printdd("CXT5066: init\n"); 28800fb67e98SDaniel Drake conexant_init(codec); 28810fb67e98SDaniel Drake if (codec->patch_ops.unsol_event) { 28820fb67e98SDaniel Drake cxt5066_hp_automute(codec); 288302b6b5b6SDavid Henningsson cxt5066_automic(codec); 28840fb67e98SDaniel Drake } 2885c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 28860fb67e98SDaniel Drake return 0; 28870fb67e98SDaniel Drake } 28880fb67e98SDaniel Drake 288975f8991dSDaniel Drake static int cxt5066_olpc_init(struct hda_codec *codec) 289075f8991dSDaniel Drake { 2891c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 289275f8991dSDaniel Drake snd_printdd("CXT5066: init\n"); 289375f8991dSDaniel Drake conexant_init(codec); 289475f8991dSDaniel Drake cxt5066_hp_automute(codec); 2895c4cfe66cSDaniel Drake if (!spec->dc_enable) { 2896c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 289775f8991dSDaniel Drake cxt5066_olpc_automic(codec); 2898c4cfe66cSDaniel Drake } else { 2899c4cfe66cSDaniel Drake cxt5066_enable_dc(codec); 2900c4cfe66cSDaniel Drake } 290175f8991dSDaniel Drake return 0; 290275f8991dSDaniel Drake } 290375f8991dSDaniel Drake 29040fb67e98SDaniel Drake enum { 29050fb67e98SDaniel Drake CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 29060fb67e98SDaniel Drake CXT5066_DELL_LAPTOP, /* Dell Laptop */ 29070fb67e98SDaniel Drake CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ 29081feba3b7SDavid Henningsson CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2909cfd3d8dcSGreg Alexander CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 29107b2bfdbcSJens Taprogge CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2911a1d6906eSDavid Henningsson CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ 2912048e78a5SDavid Henningsson CXT5066_HP_LAPTOP, /* HP Laptop */ 2913fea4a4f9STakashi Iwai CXT5066_AUTO, /* BIOS auto-parser */ 29140fb67e98SDaniel Drake CXT5066_MODELS 29150fb67e98SDaniel Drake }; 29160fb67e98SDaniel Drake 2917ea734963STakashi Iwai static const char * const cxt5066_models[CXT5066_MODELS] = { 29180fb67e98SDaniel Drake [CXT5066_LAPTOP] = "laptop", 29190fb67e98SDaniel Drake [CXT5066_DELL_LAPTOP] = "dell-laptop", 29200fb67e98SDaniel Drake [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", 29211feba3b7SDavid Henningsson [CXT5066_DELL_VOSTRO] = "dell-vostro", 2922cfd3d8dcSGreg Alexander [CXT5066_IDEAPAD] = "ideapad", 29237b2bfdbcSJens Taprogge [CXT5066_THINKPAD] = "thinkpad", 2924a1d6906eSDavid Henningsson [CXT5066_ASUS] = "asus", 2925048e78a5SDavid Henningsson [CXT5066_HP_LAPTOP] = "hp-laptop", 2926fea4a4f9STakashi Iwai [CXT5066_AUTO] = "auto", 29270fb67e98SDaniel Drake }; 29280fb67e98SDaniel Drake 292934cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { 293000cd0bb7STakashi Iwai SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 29311feba3b7SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 29328a96b1e0SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), 2933ca6cd851SDaniel T Chen SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2934231f50bcSAnisse Astier SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2935ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2936ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD), 2937048e78a5SDavid Henningsson SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2938f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2939a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2940f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 29412ca9cac9SAnisse Astier SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 2942c5366681SDaniel T Chen SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 29435637edb2SDavid Henningsson SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 29445637edb2SDavid Henningsson CXT5066_LAPTOP), 29455637edb2SDavid Henningsson SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 29464d155641STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2947ef61d4e6SManoj Iyer SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 294819593875SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 2949b2cb1292SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD), 2950d2859fd4SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), 2951a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), 29520fb67e98SDaniel Drake {} 29530fb67e98SDaniel Drake }; 29540fb67e98SDaniel Drake 29550fb67e98SDaniel Drake static int patch_cxt5066(struct hda_codec *codec) 29560fb67e98SDaniel Drake { 29570fb67e98SDaniel Drake struct conexant_spec *spec; 29580fb67e98SDaniel Drake int board_config; 29590fb67e98SDaniel Drake 2960fea4a4f9STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, 2961fea4a4f9STakashi Iwai cxt5066_models, cxt5066_cfg_tbl); 2962fea4a4f9STakashi Iwai if (board_config < 0) 2963c82693dbSTakashi Iwai board_config = CXT5066_AUTO; /* model=auto as default */ 2964fea4a4f9STakashi Iwai if (board_config == CXT5066_AUTO) 2965fea4a4f9STakashi Iwai return patch_conexant_auto(codec); 2966fea4a4f9STakashi Iwai 29670fb67e98SDaniel Drake spec = kzalloc(sizeof(*spec), GFP_KERNEL); 29680fb67e98SDaniel Drake if (!spec) 29690fb67e98SDaniel Drake return -ENOMEM; 29700fb67e98SDaniel Drake codec->spec = spec; 29710fb67e98SDaniel Drake 29720fb67e98SDaniel Drake codec->patch_ops = conexant_patch_ops; 297375f8991dSDaniel Drake codec->patch_ops.init = conexant_init; 29740fb67e98SDaniel Drake 29750fb67e98SDaniel Drake spec->dell_automute = 0; 29760fb67e98SDaniel Drake spec->multiout.max_channels = 2; 29770fb67e98SDaniel Drake spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); 29780fb67e98SDaniel Drake spec->multiout.dac_nids = cxt5066_dac_nids; 2979f6a2491cSAndy Robinson conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, 2980f6a2491cSAndy Robinson ARRAY_SIZE(cxt5066_digout_pin_nids)); 29810fb67e98SDaniel Drake spec->num_adc_nids = 1; 29820fb67e98SDaniel Drake spec->adc_nids = cxt5066_adc_nids; 29830fb67e98SDaniel Drake spec->capsrc_nids = cxt5066_capsrc_nids; 29840fb67e98SDaniel Drake spec->input_mux = &cxt5066_capture_source; 29850fb67e98SDaniel Drake 29860fb67e98SDaniel Drake spec->port_d_mode = PIN_HP; 29870fb67e98SDaniel Drake 29880fb67e98SDaniel Drake spec->num_init_verbs = 1; 29890fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs; 29900fb67e98SDaniel Drake spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); 29910fb67e98SDaniel Drake spec->channel_mode = cxt5066_modes; 29920fb67e98SDaniel Drake spec->cur_adc = 0; 29930fb67e98SDaniel Drake spec->cur_adc_idx = 0; 29940fb67e98SDaniel Drake 29953507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 29963507e2a8STakashi Iwai 29970fb67e98SDaniel Drake switch (board_config) { 29980fb67e98SDaniel Drake default: 29990fb67e98SDaniel Drake case CXT5066_LAPTOP: 30000fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30010fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30020fb67e98SDaniel Drake break; 30030fb67e98SDaniel Drake case CXT5066_DELL_LAPTOP: 30040fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30050fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30060fb67e98SDaniel Drake 30070fb67e98SDaniel Drake spec->port_d_mode = PIN_OUT; 30080fb67e98SDaniel Drake spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; 30090fb67e98SDaniel Drake spec->num_init_verbs++; 30100fb67e98SDaniel Drake spec->dell_automute = 1; 30110fb67e98SDaniel Drake break; 3012a1d6906eSDavid Henningsson case CXT5066_ASUS: 3013048e78a5SDavid Henningsson case CXT5066_HP_LAPTOP: 3014048e78a5SDavid Henningsson codec->patch_ops.init = cxt5066_init; 301502b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3016048e78a5SDavid Henningsson spec->init_verbs[spec->num_init_verbs] = 3017048e78a5SDavid Henningsson cxt5066_init_verbs_hp_laptop; 3018048e78a5SDavid Henningsson spec->num_init_verbs++; 3019a1d6906eSDavid Henningsson spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; 3020a1d6906eSDavid Henningsson spec->asus = board_config == CXT5066_ASUS; 3021048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3022048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3023048e78a5SDavid Henningsson /* no S/PDIF out */ 3024f6a2491cSAndy Robinson if (board_config == CXT5066_HP_LAPTOP) 3025048e78a5SDavid Henningsson spec->multiout.dig_out_nid = 0; 3026048e78a5SDavid Henningsson /* input source automatically selected */ 3027048e78a5SDavid Henningsson spec->input_mux = NULL; 3028048e78a5SDavid Henningsson spec->port_d_mode = 0; 3029048e78a5SDavid Henningsson spec->mic_boost = 3; /* default 30dB gain */ 3030048e78a5SDavid Henningsson break; 3031048e78a5SDavid Henningsson 30320fb67e98SDaniel Drake case CXT5066_OLPC_XO_1_5: 303375f8991dSDaniel Drake codec->patch_ops.init = cxt5066_olpc_init; 303475f8991dSDaniel Drake codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; 30350fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs_olpc; 30360fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 3037c4cfe66cSDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; 30380fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30390fb67e98SDaniel Drake spec->port_d_mode = 0; 3040c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 30410fb67e98SDaniel Drake 30420fb67e98SDaniel Drake /* no S/PDIF out */ 30430fb67e98SDaniel Drake spec->multiout.dig_out_nid = 0; 30440fb67e98SDaniel Drake 30450fb67e98SDaniel Drake /* input source automatically selected */ 30460fb67e98SDaniel Drake spec->input_mux = NULL; 304775f8991dSDaniel Drake 304875f8991dSDaniel Drake /* our capture hooks which allow us to turn on the microphone LED 304975f8991dSDaniel Drake * at the right time */ 305075f8991dSDaniel Drake spec->capture_prepare = cxt5066_olpc_capture_prepare; 305175f8991dSDaniel Drake spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 30520fb67e98SDaniel Drake break; 30531feba3b7SDavid Henningsson case CXT5066_DELL_VOSTRO: 305475f8991dSDaniel Drake codec->patch_ops.init = cxt5066_init; 305502b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 305695a618bdSEinar Rünkaru spec->init_verbs[0] = cxt5066_init_verbs_vostro; 305795a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 305895a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3059254bba6aSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 306095a618bdSEinar Rünkaru spec->port_d_mode = 0; 3061254bba6aSEinar Rünkaru spec->dell_vostro = 1; 3062c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 306395a618bdSEinar Rünkaru 306495a618bdSEinar Rünkaru /* no S/PDIF out */ 306595a618bdSEinar Rünkaru spec->multiout.dig_out_nid = 0; 306695a618bdSEinar Rünkaru 306795a618bdSEinar Rünkaru /* input source automatically selected */ 306895a618bdSEinar Rünkaru spec->input_mux = NULL; 306995a618bdSEinar Rünkaru break; 3070cfd3d8dcSGreg Alexander case CXT5066_IDEAPAD: 3071cfd3d8dcSGreg Alexander codec->patch_ops.init = cxt5066_init; 307202b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 3073cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3074cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3075cfd3d8dcSGreg Alexander spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 3076cfd3d8dcSGreg Alexander spec->port_d_mode = 0; 3077cfd3d8dcSGreg Alexander spec->ideapad = 1; 3078cfd3d8dcSGreg Alexander spec->mic_boost = 2; /* default 20dB gain */ 3079cfd3d8dcSGreg Alexander 3080cfd3d8dcSGreg Alexander /* no S/PDIF out */ 3081cfd3d8dcSGreg Alexander spec->multiout.dig_out_nid = 0; 3082cfd3d8dcSGreg Alexander 3083cfd3d8dcSGreg Alexander /* input source automatically selected */ 3084cfd3d8dcSGreg Alexander spec->input_mux = NULL; 3085cfd3d8dcSGreg Alexander break; 30867b2bfdbcSJens Taprogge case CXT5066_THINKPAD: 30877b2bfdbcSJens Taprogge codec->patch_ops.init = cxt5066_init; 308802b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 30897b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 30907b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixers; 30917b2bfdbcSJens Taprogge spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 30927b2bfdbcSJens Taprogge spec->thinkpad = 1; 30937b2bfdbcSJens Taprogge spec->port_d_mode = PIN_OUT; 30947b2bfdbcSJens Taprogge spec->mic_boost = 2; /* default 20dB gain */ 30957b2bfdbcSJens Taprogge 30967b2bfdbcSJens Taprogge /* no S/PDIF out */ 30977b2bfdbcSJens Taprogge spec->multiout.dig_out_nid = 0; 30987b2bfdbcSJens Taprogge 30997b2bfdbcSJens Taprogge /* input source automatically selected */ 31007b2bfdbcSJens Taprogge spec->input_mux = NULL; 31017b2bfdbcSJens Taprogge break; 31020fb67e98SDaniel Drake } 31030fb67e98SDaniel Drake 31043507e2a8STakashi Iwai if (spec->beep_amp) 3105a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 31063507e2a8STakashi Iwai 31070fb67e98SDaniel Drake return 0; 31080fb67e98SDaniel Drake } 3109461e2c78STakashi Iwai 3110bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 3111bf92d1d5STakashi Iwai 3112bf92d1d5STakashi Iwai 3113461e2c78STakashi Iwai /* 3114f2e5731dSTakashi Iwai * Automatic parser for CX20641 & co 3115f2e5731dSTakashi Iwai */ 3116f2e5731dSTakashi Iwai 3117f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 3118f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec) 3119f2e5731dSTakashi Iwai { 3120f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 3121f2e5731dSTakashi Iwai hda_nid_t nid, end_nid; 3122f2e5731dSTakashi Iwai 3123f2e5731dSTakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 3124f2e5731dSTakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) 3125f2e5731dSTakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 3126f2e5731dSTakashi Iwai set_beep_amp(spec, nid, 0, HDA_OUTPUT); 3127f2e5731dSTakashi Iwai break; 3128f2e5731dSTakashi Iwai } 3129f2e5731dSTakashi Iwai } 3130f2e5731dSTakashi Iwai #else 3131f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec) 3132f2e5731dSTakashi Iwai #endif 3133f2e5731dSTakashi Iwai 3134254f2968STakashi Iwai /* parse EAPDs */ 313519110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 313619110595STakashi Iwai { 313719110595STakashi Iwai struct conexant_spec *spec = codec->spec; 313819110595STakashi Iwai hda_nid_t nid, end_nid; 313919110595STakashi Iwai 314019110595STakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 314119110595STakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) { 314219110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 314319110595STakashi Iwai continue; 314419110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 314519110595STakashi Iwai continue; 314619110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 314719110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 314819110595STakashi Iwai break; 314919110595STakashi Iwai } 3150254f2968STakashi Iwai 3151254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 3152254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 3153254f2968STakashi Iwai * pins, and we can control EAPD per pin. 3154254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 3155254f2968STakashi Iwai * thus it might control over all pins. 3156254f2968STakashi Iwai */ 3157aed523f1STakashi Iwai if (spec->num_eapds > 2) 3158aed523f1STakashi Iwai spec->gen.own_eapd_ctl = 1; 3159f2e5731dSTakashi Iwai } 3160f2e5731dSTakashi Iwai 3161da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 3162da339866STakashi Iwai hda_nid_t *pins, bool on) 3163f2e5731dSTakashi Iwai { 3164f2e5731dSTakashi Iwai int i; 3165f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 3166f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 3167f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 3168da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 3169da339866STakashi Iwai on ? 0x02 : 0); 3170f2e5731dSTakashi Iwai } 3171f2e5731dSTakashi Iwai } 3172f2e5731dSTakashi Iwai 3173527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 3174527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 3175527c73baSTakashi Iwai { 3176527c73baSTakashi Iwai struct hda_codec *codec = private_data; 3177527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 3178527c73baSTakashi Iwai 3179527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 3180527c73baSTakashi Iwai } 3181527c73baSTakashi Iwai 3182f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec) 3183f2e5731dSTakashi Iwai { 3184f2e5731dSTakashi Iwai int err; 3185f2e5731dSTakashi Iwai 3186aed523f1STakashi Iwai err = snd_hda_gen_build_controls(codec); 3187f2e5731dSTakashi Iwai if (err < 0) 3188f2e5731dSTakashi Iwai return err; 3189f2e5731dSTakashi Iwai 3190aed523f1STakashi Iwai err = add_beep_ctls(codec); 3191aed523f1STakashi Iwai if (err < 0) 3192aed523f1STakashi Iwai return err; 319322ce5f74STakashi Iwai 319422ce5f74STakashi Iwai return 0; 319522ce5f74STakashi Iwai } 319622ce5f74STakashi Iwai 319734cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 3198f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 3199aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 3200aed523f1STakashi Iwai .init = snd_hda_gen_init, 32017504b6cdSTakashi Iwai .free = snd_hda_gen_free, 320229adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 3203164a7adaSTakashi Iwai #ifdef CONFIG_PM 3204164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 3205164a7adaSTakashi Iwai #endif 3206f2e5731dSTakashi Iwai }; 3207f2e5731dSTakashi Iwai 3208e92d4b08STakashi Iwai /* 3209e92d4b08STakashi Iwai * pin fix-up 3210e92d4b08STakashi Iwai */ 321118dcd304SDavid Henningsson enum { 321218dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 3213d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 3214239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 3215239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 321618dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 3217239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 321818dcd304SDavid Henningsson }; 321918dcd304SDavid Henningsson 322023d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 322123d30f28STakashi Iwai const struct hda_fixup *fix, int action) 3222e92d4b08STakashi Iwai { 322318dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 3224aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 3225e92d4b08STakashi Iwai } 3226e92d4b08STakashi Iwai 3227239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 3228239fb862SHuacai Chen const struct hda_fixup *fix, int action) 3229239fb862SHuacai Chen { 3230239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 3231239fb862SHuacai Chen return; 3232239fb862SHuacai Chen 3233239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 3234239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 3235239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3236239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3237239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 3238239fb862SHuacai Chen } 3239239fb862SHuacai Chen 3240d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 324123d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3242e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3243e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3244e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 32453e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3246e92d4b08STakashi Iwai {} 3247e92d4b08STakashi Iwai }; 3248e92d4b08STakashi Iwai 3249d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 325023d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3251d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3252d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3253d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3254d70f3632STakashi Iwai {} 3255e92d4b08STakashi Iwai }; 3256e92d4b08STakashi Iwai 3257239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3258239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3259239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3260239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3261239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3262239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3263239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3264239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3265239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3266239fb862SHuacai Chen {} 3267239fb862SHuacai Chen }; 3268239fb862SHuacai Chen 326923d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 327023d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 327123d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 327223d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 327323d30f28STakashi Iwai }, 327423d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 327523d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 327623d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 327723d30f28STakashi Iwai }, 3278239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3279239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3280239fb862SHuacai Chen .chained = true, 3281239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3282239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3283239fb862SHuacai Chen }, 3284239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3285239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3286239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3287239fb862SHuacai Chen }, 328823d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 328923d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 329023d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 329123d30f28STakashi Iwai }, 3292239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3293239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3294239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3295239fb862SHuacai Chen }, 3296e92d4b08STakashi Iwai }; 3297e92d4b08STakashi Iwai 3298d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3299e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3300e92d4b08STakashi Iwai {} 3301e92d4b08STakashi Iwai }; 3302e92d4b08STakashi Iwai 3303d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 330463a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 3305d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3306d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3307d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3308d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3309d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 3310*a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 331118dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3312e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3313b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 3314239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3315239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3316f2e5731dSTakashi Iwai {} 3317f2e5731dSTakashi Iwai }; 3318f2e5731dSTakashi Iwai 33193868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 33203868137eSTakashi Iwai * can be created (bko#42825) 33213868137eSTakashi Iwai */ 33223868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 33233868137eSTakashi Iwai { 33243868137eSTakashi Iwai static hda_nid_t out_nids[] = { 33253868137eSTakashi Iwai 0x10, 0x11, 0 33263868137eSTakashi Iwai }; 33273868137eSTakashi Iwai hda_nid_t *p; 33283868137eSTakashi Iwai 33293868137eSTakashi Iwai for (p = out_nids; *p; p++) 33303868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 33313868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 33323868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 33333868137eSTakashi Iwai } 33343868137eSTakashi Iwai 3335f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3336f2e5731dSTakashi Iwai { 3337f2e5731dSTakashi Iwai struct conexant_spec *spec; 3338f2e5731dSTakashi Iwai int err; 3339f2e5731dSTakashi Iwai 33401f8458a2STakashi Iwai printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 33411f8458a2STakashi Iwai codec->chip_name); 33421f8458a2STakashi Iwai 3343f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3344f2e5731dSTakashi Iwai if (!spec) 3345f2e5731dSTakashi Iwai return -ENOMEM; 3346aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3347f2e5731dSTakashi Iwai codec->spec = spec; 3348e92d4b08STakashi Iwai 3349aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3350aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3351aed523f1STakashi Iwai if (spec->gen.own_eapd_ctl) 3352aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3353e92d4b08STakashi Iwai 33546b452142STakashi Iwai switch (codec->vendor_id) { 33556b452142STakashi Iwai case 0x14f15045: 33564f32456eSMichael Karcher codec->single_adc_amp = 1; 33576b452142STakashi Iwai break; 3358164a7adaSTakashi Iwai case 0x14f15047: 3359164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 3360164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 3361164a7adaSTakashi Iwai break; 33623868137eSTakashi Iwai case 0x14f15051: 33633868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 336451969d62SMichael Karcher codec->pin_amp_workaround = 1; 336523d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); 33663868137eSTakashi Iwai break; 336751969d62SMichael Karcher default: 336851969d62SMichael Karcher codec->pin_amp_workaround = 1; 336923d30f28STakashi Iwai snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); 337023d30f28STakashi Iwai break; 33716b452142STakashi Iwai } 33726b452142STakashi Iwai 3373f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3374f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3375f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3376f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3377f29735cbSTakashi Iwai * not good to expose it blindly. 3378527c73baSTakashi Iwai */ 3379f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3380f29735cbSTakashi Iwai case 0x103c: 3381aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3382f29735cbSTakashi Iwai break; 3383f29735cbSTakashi Iwai } 3384527c73baSTakashi Iwai 3385aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3386aed523f1STakashi Iwai 3387aed523f1STakashi Iwai err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); 338822ce5f74STakashi Iwai if (err < 0) 3389aed523f1STakashi Iwai goto error; 3390aed523f1STakashi Iwai 3391aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3392aed523f1STakashi Iwai if (err < 0) 3393aed523f1STakashi Iwai goto error; 3394aed523f1STakashi Iwai 3395f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 33964f2864a4STakashi Iwai 33974f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 33984f2864a4STakashi Iwai * which falls into the single-cmd mode. 33994f2864a4STakashi Iwai * Better to make reset, then. 34004f2864a4STakashi Iwai */ 34014f2864a4STakashi Iwai if (!codec->bus->sync_write) { 34024f2864a4STakashi Iwai snd_printd("hda_codec: " 34034f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 34044f2864a4STakashi Iwai codec->bus->sync_write = 1; 34054f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 34064f2864a4STakashi Iwai } 34074f2864a4STakashi Iwai 3408f2e5731dSTakashi Iwai return 0; 3409aed523f1STakashi Iwai 3410aed523f1STakashi Iwai error: 3411aed523f1STakashi Iwai snd_hda_gen_free(codec); 3412aed523f1STakashi Iwai return err; 3413f2e5731dSTakashi Iwai } 3414f2e5731dSTakashi Iwai 3415bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3416bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3417bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3418bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3419bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3420bf92d1d5STakashi Iwai #endif 3421bf92d1d5STakashi Iwai 3422f2e5731dSTakashi Iwai /* 3423461e2c78STakashi Iwai */ 3424461e2c78STakashi Iwai 342534cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 342682f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 342782f30040STobin Davis .patch = patch_cxt5045 }, 342882f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 342982f30040STobin Davis .patch = patch_cxt5047 }, 3430461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3431461e2c78STakashi Iwai .patch = patch_cxt5051 }, 34320fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 34330fb67e98SDaniel Drake .patch = patch_cxt5066 }, 343495a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 343595a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3436850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3437850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 34387b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 34397b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3440f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3441f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 34426da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 34436da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3444f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3445f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3446f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3447f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3448f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3449f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3450f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3451f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3452f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3453f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3454f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3455f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3456f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3457f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3458f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3459f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 34602d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 34612d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34622d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 34632d825fd8STakashi Iwai .patch = patch_conexant_auto }, 34642d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 34652d825fd8STakashi Iwai .patch = patch_conexant_auto }, 346642c364acSTakashi Iwai { .id = 0x14f15113, .name = "CX20755", 346742c364acSTakashi Iwai .patch = patch_conexant_auto }, 346842c364acSTakashi Iwai { .id = 0x14f15114, .name = "CX20756", 346942c364acSTakashi Iwai .patch = patch_conexant_auto }, 347042c364acSTakashi Iwai { .id = 0x14f15115, .name = "CX20757", 347142c364acSTakashi Iwai .patch = patch_conexant_auto }, 3472c9b443d4STobin Davis {} /* terminator */ 3473c9b443d4STobin Davis }; 34741289e9e8STakashi Iwai 34751289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 34761289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 34771289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 34780fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 347995a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3480850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 34817b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3482f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 34836da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3484f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3485f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3486f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3487f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3488f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3489f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3490f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3491f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 34922d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 34932d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 34942d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 349542c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113"); 349642c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114"); 349742c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115"); 34981289e9e8STakashi Iwai 34991289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 35001289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 35011289e9e8STakashi Iwai 35021289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 35031289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 35041289e9e8STakashi Iwai .owner = THIS_MODULE, 35051289e9e8STakashi Iwai }; 35061289e9e8STakashi Iwai 35071289e9e8STakashi Iwai static int __init patch_conexant_init(void) 35081289e9e8STakashi Iwai { 35091289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 35101289e9e8STakashi Iwai } 35111289e9e8STakashi Iwai 35121289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 35131289e9e8STakashi Iwai { 35141289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 35151289e9e8STakashi Iwai } 35161289e9e8STakashi Iwai 35171289e9e8STakashi Iwai module_init(patch_conexant_init) 35181289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3519