1c9b443d4STobin Davis /* 2c9b443d4STobin Davis * HD audio interface patch for Conexant HDA audio codec 3c9b443d4STobin Davis * 4c9b443d4STobin Davis * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> 5c9b443d4STobin Davis * Takashi Iwai <tiwai@suse.de> 6c9b443d4STobin Davis * Tobin Davis <tdavis@dsl-only.net> 7c9b443d4STobin Davis * 8c9b443d4STobin Davis * This driver is free software; you can redistribute it and/or modify 9c9b443d4STobin Davis * it under the terms of the GNU General Public License as published by 10c9b443d4STobin Davis * the Free Software Foundation; either version 2 of the License, or 11c9b443d4STobin Davis * (at your option) any later version. 12c9b443d4STobin Davis * 13c9b443d4STobin Davis * This driver is distributed in the hope that it will be useful, 14c9b443d4STobin Davis * but WITHOUT ANY WARRANTY; without even the implied warranty of 15c9b443d4STobin Davis * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16c9b443d4STobin Davis * GNU General Public License for more details. 17c9b443d4STobin Davis * 18c9b443d4STobin Davis * You should have received a copy of the GNU General Public License 19c9b443d4STobin Davis * along with this program; if not, write to the Free Software 20c9b443d4STobin Davis * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21c9b443d4STobin Davis */ 22c9b443d4STobin Davis 23c9b443d4STobin Davis #include <linux/init.h> 24c9b443d4STobin Davis #include <linux/delay.h> 25c9b443d4STobin Davis #include <linux/slab.h> 26c9b443d4STobin Davis #include <linux/pci.h> 27da155d5bSPaul Gortmaker #include <linux/module.h> 28c9b443d4STobin Davis #include <sound/core.h> 29bc7a166dSUlrich Dangel #include <sound/jack.h> 30bc7a166dSUlrich Dangel 31c9b443d4STobin Davis #include "hda_codec.h" 32c9b443d4STobin Davis #include "hda_local.h" 3323d30f28STakashi Iwai #include "hda_auto_parser.h" 34c0f8faf0SEinar Rünkaru #include "hda_beep.h" 351835a0f9STakashi Iwai #include "hda_jack.h" 36aed523f1STakashi Iwai #include "hda_generic.h" 37c9b443d4STobin Davis 38bf92d1d5STakashi Iwai #define ENABLE_CXT_STATIC_QUIRKS 39c9b443d4STobin Davis 40c9b443d4STobin Davis #define CXT_PIN_DIR_IN 0x00 41c9b443d4STobin Davis #define CXT_PIN_DIR_OUT 0x01 42c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT 0x02 43c9b443d4STobin Davis #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 44c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 45c9b443d4STobin Davis 46c9b443d4STobin Davis #define CONEXANT_HP_EVENT 0x37 47c9b443d4STobin Davis #define CONEXANT_MIC_EVENT 0x38 4803697e2aSTakashi Iwai #define CONEXANT_LINE_EVENT 0x39 49c9b443d4STobin Davis 50bc7a166dSUlrich Dangel /* Conexant 5051 specific */ 51c9b443d4STobin Davis 52ecda0cffSTakashi Iwai #define CXT5051_SPDIF_OUT 0x12 53bc7a166dSUlrich Dangel #define CXT5051_PORTB_EVENT 0x38 54bc7a166dSUlrich Dangel #define CXT5051_PORTC_EVENT 0x39 55bc7a166dSUlrich Dangel 56faddaa5dSTakashi Iwai #define AUTO_MIC_PORTB (1 << 1) 57faddaa5dSTakashi Iwai #define AUTO_MIC_PORTC (1 << 2) 58bc7a166dSUlrich Dangel 59c9b443d4STobin Davis struct conexant_spec { 6023d30f28STakashi Iwai struct hda_gen_spec gen; 61c9b443d4STobin Davis 62bf92d1d5STakashi Iwai unsigned int beep_amp; 63bf92d1d5STakashi Iwai 64bf92d1d5STakashi Iwai /* extra EAPD pins */ 65bf92d1d5STakashi Iwai unsigned int num_eapds; 66bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 67ff359b14STakashi Iwai bool dynamic_eapd; 68bf92d1d5STakashi Iwai 69e4c3bce2SDavid Henningsson unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 70e4c3bce2SDavid Henningsson 713a00c660STakashi Iwai /* OPLC XO specific */ 723a00c660STakashi Iwai bool recording; 733a00c660STakashi Iwai bool dc_enable; 743a00c660STakashi Iwai unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */ 753a00c660STakashi Iwai struct nid_path *dc_mode_path; 763a00c660STakashi Iwai 77bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 7834cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 79c9b443d4STobin Davis int num_mixers; 80dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 81c9b443d4STobin Davis 82c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 83c9b443d4STobin Davis * don't forget NULL 84c9b443d4STobin Davis * termination! 85c9b443d4STobin Davis */ 86c9b443d4STobin Davis unsigned int num_init_verbs; 87c9b443d4STobin Davis 88c9b443d4STobin Davis /* playback */ 89c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 90c9b443d4STobin Davis * max_channels, dacs must be set 91c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 92c9b443d4STobin Davis */ 93c9b443d4STobin Davis unsigned int cur_eapd; 9482f30040STobin Davis unsigned int hp_present; 9503697e2aSTakashi Iwai unsigned int line_present; 96faddaa5dSTakashi Iwai unsigned int auto_mic; 97c9b443d4STobin Davis 98c9b443d4STobin Davis /* capture */ 99c9b443d4STobin Davis unsigned int num_adc_nids; 10034cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 101c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 102c9b443d4STobin Davis 103461e2c78STakashi Iwai unsigned int cur_adc_idx; 104461e2c78STakashi Iwai hda_nid_t cur_adc; 105461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 106461e2c78STakashi Iwai unsigned int cur_adc_format; 107461e2c78STakashi Iwai 1086764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1096764bcefSTakashi Iwai 110c9b443d4STobin Davis /* capture source */ 111c9b443d4STobin Davis const struct hda_input_mux *input_mux; 11234cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 113c9b443d4STobin Davis unsigned int cur_mux[3]; 114c9b443d4STobin Davis 115c9b443d4STobin Davis /* channel model */ 116c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 117c9b443d4STobin Davis int num_channel_mode; 118c9b443d4STobin Davis 119c9b443d4STobin Davis /* PCM information */ 120c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 121c9b443d4STobin Davis 122c9b443d4STobin Davis unsigned int spdif_route; 123c9b443d4STobin Davis 1240fb67e98SDaniel Drake unsigned int port_d_mode; 125f2e5731dSTakashi Iwai unsigned int dell_automute:1; 126cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 127cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1287b2bfdbcSJens Taprogge unsigned int thinkpad:1; 129048e78a5SDavid Henningsson unsigned int hp_laptop:1; 130a1d6906eSDavid Henningsson unsigned int asus:1; 1316764bcefSTakashi Iwai 132c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 133bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 134c9b443d4STobin Davis }; 135c9b443d4STobin Davis 136bf92d1d5STakashi Iwai 137bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 1387504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 1397504b6cdSTakashi Iwai int idx, int dir) 1407504b6cdSTakashi Iwai { 1417504b6cdSTakashi Iwai spec->gen.beep_nid = nid; 1427504b6cdSTakashi Iwai spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 1437504b6cdSTakashi Iwai } 144bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 145bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 146bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 147bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 148bf92d1d5STakashi Iwai { } /* end */ 149bf92d1d5STakashi Iwai }; 150bf92d1d5STakashi Iwai 151bf92d1d5STakashi Iwai /* create beep controls if needed */ 152bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 153bf92d1d5STakashi Iwai { 154bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 155bf92d1d5STakashi Iwai int err; 156bf92d1d5STakashi Iwai 157bf92d1d5STakashi Iwai if (spec->beep_amp) { 158bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 159bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 160bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 161bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 162bf92d1d5STakashi Iwai if (!kctl) 163bf92d1d5STakashi Iwai return -ENOMEM; 164bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 165bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 166bf92d1d5STakashi Iwai if (err < 0) 167bf92d1d5STakashi Iwai return err; 168bf92d1d5STakashi Iwai } 169bf92d1d5STakashi Iwai } 170bf92d1d5STakashi Iwai return 0; 171bf92d1d5STakashi Iwai } 172bf92d1d5STakashi Iwai #else 173bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 174bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 175bf92d1d5STakashi Iwai #endif 176bf92d1d5STakashi Iwai 177bf92d1d5STakashi Iwai 178bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 179c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 180c9b443d4STobin Davis struct hda_codec *codec, 181c9b443d4STobin Davis struct snd_pcm_substream *substream) 182c9b443d4STobin Davis { 183c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1849a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1859a08160bSTakashi Iwai hinfo); 186c9b443d4STobin Davis } 187c9b443d4STobin Davis 188c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 189c9b443d4STobin Davis struct hda_codec *codec, 190c9b443d4STobin Davis unsigned int stream_tag, 191c9b443d4STobin Davis unsigned int format, 192c9b443d4STobin Davis struct snd_pcm_substream *substream) 193c9b443d4STobin Davis { 194c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 195c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 196c9b443d4STobin Davis stream_tag, 197c9b443d4STobin Davis format, substream); 198c9b443d4STobin Davis } 199c9b443d4STobin Davis 200c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 201c9b443d4STobin Davis struct hda_codec *codec, 202c9b443d4STobin Davis struct snd_pcm_substream *substream) 203c9b443d4STobin Davis { 204c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 205c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 206c9b443d4STobin Davis } 207c9b443d4STobin Davis 208c9b443d4STobin Davis /* 209c9b443d4STobin Davis * Digital out 210c9b443d4STobin Davis */ 211c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 212c9b443d4STobin Davis struct hda_codec *codec, 213c9b443d4STobin Davis struct snd_pcm_substream *substream) 214c9b443d4STobin Davis { 215c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 216c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 217c9b443d4STobin Davis } 218c9b443d4STobin Davis 219c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 220c9b443d4STobin Davis struct hda_codec *codec, 221c9b443d4STobin Davis struct snd_pcm_substream *substream) 222c9b443d4STobin Davis { 223c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 224c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 225c9b443d4STobin Davis } 226c9b443d4STobin Davis 2276b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2286b97eb45STakashi Iwai struct hda_codec *codec, 2296b97eb45STakashi Iwai unsigned int stream_tag, 2306b97eb45STakashi Iwai unsigned int format, 2316b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2326b97eb45STakashi Iwai { 2336b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2346b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2356b97eb45STakashi Iwai stream_tag, 2366b97eb45STakashi Iwai format, substream); 2376b97eb45STakashi Iwai } 2386b97eb45STakashi Iwai 239c9b443d4STobin Davis /* 240c9b443d4STobin Davis * Analog capture 241c9b443d4STobin Davis */ 242c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 243c9b443d4STobin Davis struct hda_codec *codec, 244c9b443d4STobin Davis unsigned int stream_tag, 245c9b443d4STobin Davis unsigned int format, 246c9b443d4STobin Davis struct snd_pcm_substream *substream) 247c9b443d4STobin Davis { 248c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 249c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 250c9b443d4STobin Davis stream_tag, 0, format); 251c9b443d4STobin Davis return 0; 252c9b443d4STobin Davis } 253c9b443d4STobin Davis 254c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 255c9b443d4STobin Davis struct hda_codec *codec, 256c9b443d4STobin Davis struct snd_pcm_substream *substream) 257c9b443d4STobin Davis { 258c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 259888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 260c9b443d4STobin Davis return 0; 261c9b443d4STobin Davis } 262c9b443d4STobin Davis 263c9b443d4STobin Davis 264c9b443d4STobin Davis 26534cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 266c9b443d4STobin Davis .substreams = 1, 267c9b443d4STobin Davis .channels_min = 2, 268c9b443d4STobin Davis .channels_max = 2, 269c9b443d4STobin Davis .nid = 0, /* fill later */ 270c9b443d4STobin Davis .ops = { 271c9b443d4STobin Davis .open = conexant_playback_pcm_open, 272c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 273c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 274c9b443d4STobin Davis }, 275c9b443d4STobin Davis }; 276c9b443d4STobin Davis 27734cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 278c9b443d4STobin Davis .substreams = 1, 279c9b443d4STobin Davis .channels_min = 2, 280c9b443d4STobin Davis .channels_max = 2, 281c9b443d4STobin Davis .nid = 0, /* fill later */ 282c9b443d4STobin Davis .ops = { 283c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 284c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 285c9b443d4STobin Davis }, 286c9b443d4STobin Davis }; 287c9b443d4STobin Davis 288c9b443d4STobin Davis 28934cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 290c9b443d4STobin Davis .substreams = 1, 291c9b443d4STobin Davis .channels_min = 2, 292c9b443d4STobin Davis .channels_max = 2, 293c9b443d4STobin Davis .nid = 0, /* fill later */ 294c9b443d4STobin Davis .ops = { 295c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 2966b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 2976b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 298c9b443d4STobin Davis }, 299c9b443d4STobin Davis }; 300c9b443d4STobin Davis 30134cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 302c9b443d4STobin Davis .substreams = 1, 303c9b443d4STobin Davis .channels_min = 2, 304c9b443d4STobin Davis .channels_max = 2, 305c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 306c9b443d4STobin Davis }; 307c9b443d4STobin Davis 308461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 309461e2c78STakashi Iwai struct hda_codec *codec, 310461e2c78STakashi Iwai unsigned int stream_tag, 311461e2c78STakashi Iwai unsigned int format, 312461e2c78STakashi Iwai struct snd_pcm_substream *substream) 313461e2c78STakashi Iwai { 314461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 315461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 316461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 317461e2c78STakashi Iwai spec->cur_adc_format = format; 318461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 319461e2c78STakashi Iwai return 0; 320461e2c78STakashi Iwai } 321461e2c78STakashi Iwai 322461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 323461e2c78STakashi Iwai struct hda_codec *codec, 324461e2c78STakashi Iwai struct snd_pcm_substream *substream) 325461e2c78STakashi Iwai { 326461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 327888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 328461e2c78STakashi Iwai spec->cur_adc = 0; 329461e2c78STakashi Iwai return 0; 330461e2c78STakashi Iwai } 331461e2c78STakashi Iwai 33234cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 333461e2c78STakashi Iwai .substreams = 1, 334461e2c78STakashi Iwai .channels_min = 2, 335461e2c78STakashi Iwai .channels_max = 2, 336461e2c78STakashi Iwai .nid = 0, /* fill later */ 337461e2c78STakashi Iwai .ops = { 338461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 339461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 340461e2c78STakashi Iwai }, 341461e2c78STakashi Iwai }; 342461e2c78STakashi Iwai 343c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 344c9b443d4STobin Davis { 345c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 346c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 347c9b443d4STobin Davis 348c9b443d4STobin Davis codec->num_pcms = 1; 349c9b443d4STobin Davis codec->pcm_info = info; 350c9b443d4STobin Davis 351c9b443d4STobin Davis info->name = "CONEXANT Analog"; 352c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 353c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 354c9b443d4STobin Davis spec->multiout.max_channels; 355c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 356c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3576764bcefSTakashi Iwai if (spec->capture_stream) 3586764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3596764bcefSTakashi Iwai else { 360461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 361461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 362461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3636764bcefSTakashi Iwai else { 364461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 365461e2c78STakashi Iwai conexant_pcm_analog_capture; 3666764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3676764bcefSTakashi Iwai spec->num_adc_nids; 3686764bcefSTakashi Iwai } 3696764bcefSTakashi Iwai } 370c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 371c9b443d4STobin Davis 372c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 373c9b443d4STobin Davis info++; 374c9b443d4STobin Davis codec->num_pcms++; 375c9b443d4STobin Davis info->name = "Conexant Digital"; 3767ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 377c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 378c9b443d4STobin Davis conexant_pcm_digital_playback; 379c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 380c9b443d4STobin Davis spec->multiout.dig_out_nid; 381c9b443d4STobin Davis if (spec->dig_in_nid) { 382c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 383c9b443d4STobin Davis conexant_pcm_digital_capture; 384c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 385c9b443d4STobin Davis spec->dig_in_nid; 386c9b443d4STobin Davis } 387c9b443d4STobin Davis } 388c9b443d4STobin Davis 389c9b443d4STobin Davis return 0; 390c9b443d4STobin Davis } 391c9b443d4STobin Davis 392c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 393c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 394c9b443d4STobin Davis { 395c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 396c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 397c9b443d4STobin Davis 398c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 399c9b443d4STobin Davis } 400c9b443d4STobin Davis 401c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 402c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 403c9b443d4STobin Davis { 404c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 405c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 406c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 407c9b443d4STobin Davis 408c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 409c9b443d4STobin Davis return 0; 410c9b443d4STobin Davis } 411c9b443d4STobin Davis 412c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 413c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 414c9b443d4STobin Davis { 415c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 416c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 417c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 418c9b443d4STobin Davis 419c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 420c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 421c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 422c9b443d4STobin Davis } 423c9b443d4STobin Davis 4244d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4254d7fbdbcSTakashi Iwai unsigned int power_state) 4264d7fbdbcSTakashi Iwai { 4274d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4284d7fbdbcSTakashi Iwai msleep(100); 4294d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4304d7fbdbcSTakashi Iwai power_state); 4314d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4324d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4334d7fbdbcSTakashi Iwai msleep(10); 4349419ab6bSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state); 4354d7fbdbcSTakashi Iwai } 4364d7fbdbcSTakashi Iwai 437c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 438c9b443d4STobin Davis { 439c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 440c9b443d4STobin Davis int i; 441c9b443d4STobin Davis 442c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 443c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 444c9b443d4STobin Davis return 0; 445c9b443d4STobin Davis } 446c9b443d4STobin Davis 447c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 448c9b443d4STobin Davis { 449ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 450c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 451ee48df57STakashi Iwai kfree(spec); 452c9b443d4STobin Davis } 453c9b443d4STobin Davis 45434cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 455b880c74aSTakashi Iwai { 456b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 457b880c74aSTakashi Iwai .name = "Capture Source", 458b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 459b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 460b880c74aSTakashi Iwai .put = conexant_mux_enum_put 461b880c74aSTakashi Iwai }, 462b880c74aSTakashi Iwai {} 463b880c74aSTakashi Iwai }; 464b880c74aSTakashi Iwai 4659322ca54STakashi Iwai static const char * const slave_pfxs[] = { 466f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 467dd5746a8STakashi Iwai NULL 468dd5746a8STakashi Iwai }; 469dd5746a8STakashi Iwai 470c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 471c9b443d4STobin Davis { 472c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 473c9b443d4STobin Davis unsigned int i; 474c9b443d4STobin Davis int err; 475c9b443d4STobin Davis 476c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 477c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 478c9b443d4STobin Davis if (err < 0) 479c9b443d4STobin Davis return err; 480c9b443d4STobin Davis } 481c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 482c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 48374b654c9SStephen Warren spec->multiout.dig_out_nid, 484c9b443d4STobin Davis spec->multiout.dig_out_nid); 485c9b443d4STobin Davis if (err < 0) 486c9b443d4STobin Davis return err; 4879a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4889a08160bSTakashi Iwai &spec->multiout); 4899a08160bSTakashi Iwai if (err < 0) 4909a08160bSTakashi Iwai return err; 4919a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 492c9b443d4STobin Davis } 493c9b443d4STobin Davis if (spec->dig_in_nid) { 494c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 495c9b443d4STobin Davis if (err < 0) 496c9b443d4STobin Davis return err; 497c9b443d4STobin Davis } 498dd5746a8STakashi Iwai 499dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 500dd5746a8STakashi Iwai if (spec->vmaster_nid && 501dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 502dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 503dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 504dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 505dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5069322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5079322ca54STakashi Iwai "Playback Volume"); 508dd5746a8STakashi Iwai if (err < 0) 509dd5746a8STakashi Iwai return err; 510dd5746a8STakashi Iwai } 511dd5746a8STakashi Iwai if (spec->vmaster_nid && 512dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 513aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5149322ca54STakashi Iwai NULL, slave_pfxs, 515aed523f1STakashi Iwai "Playback Switch"); 516dd5746a8STakashi Iwai if (err < 0) 517dd5746a8STakashi Iwai return err; 518dd5746a8STakashi Iwai } 519dd5746a8STakashi Iwai 520b880c74aSTakashi Iwai if (spec->input_mux) { 521b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 522b880c74aSTakashi Iwai if (err < 0) 523b880c74aSTakashi Iwai return err; 524b880c74aSTakashi Iwai } 525b880c74aSTakashi Iwai 526aed523f1STakashi Iwai err = add_beep_ctls(codec); 5273507e2a8STakashi Iwai if (err < 0) 5283507e2a8STakashi Iwai return err; 5293507e2a8STakashi Iwai 530c9b443d4STobin Davis return 0; 531c9b443d4STobin Davis } 532c9b443d4STobin Davis 53334cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 534c9b443d4STobin Davis .build_controls = conexant_build_controls, 535c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 536c9b443d4STobin Davis .init = conexant_init, 537c9b443d4STobin Davis .free = conexant_free, 5384d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 539c9b443d4STobin Davis }; 540c9b443d4STobin Davis 5416764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 542c9b443d4STobin Davis /* 543c9b443d4STobin Davis * EAPD control 544c9b443d4STobin Davis * the private value = nid | (invert << 8) 545c9b443d4STobin Davis */ 546c9b443d4STobin Davis 547a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 548c9b443d4STobin Davis 54982f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 550c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 551c9b443d4STobin Davis { 552c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 553c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 554c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 555c9b443d4STobin Davis if (invert) 556c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 557c9b443d4STobin Davis else 558c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 559c9b443d4STobin Davis return 0; 56082f30040STobin Davis 561c9b443d4STobin Davis } 562c9b443d4STobin Davis 56382f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 564c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 565c9b443d4STobin Davis { 566c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 567c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 568c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 569c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 570c9b443d4STobin Davis unsigned int eapd; 57182f30040STobin Davis 57268ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 573c9b443d4STobin Davis if (invert) 574c9b443d4STobin Davis eapd = !eapd; 57582beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 576c9b443d4STobin Davis return 0; 57782f30040STobin Davis 578c9b443d4STobin Davis spec->cur_eapd = eapd; 57982beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 580c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 581c9b443d4STobin Davis eapd ? 0x02 : 0x00); 582c9b443d4STobin Davis return 1; 583c9b443d4STobin Davis } 584c9b443d4STobin Davis 58586d72bdfSTakashi Iwai /* controls for test mode */ 58686d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 58786d72bdfSTakashi Iwai 58882f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 58982f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 59082f30040STobin Davis .info = cxt_eapd_info, \ 59182f30040STobin Davis .get = cxt_eapd_get, \ 59282f30040STobin Davis .put = cxt_eapd_put, \ 59382f30040STobin Davis .private_value = nid | (mask<<16) } 59482f30040STobin Davis 59582f30040STobin Davis 59682f30040STobin Davis 597c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 598c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 599c9b443d4STobin Davis { 600c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 601c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 602c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 603c9b443d4STobin Davis spec->num_channel_mode); 604c9b443d4STobin Davis } 605c9b443d4STobin Davis 606c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 607c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 608c9b443d4STobin Davis { 609c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 610c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 611c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 612c9b443d4STobin Davis spec->num_channel_mode, 613c9b443d4STobin Davis spec->multiout.max_channels); 614c9b443d4STobin Davis } 615c9b443d4STobin Davis 616c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 617c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 618c9b443d4STobin Davis { 619c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 620c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 621c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 622c9b443d4STobin Davis spec->num_channel_mode, 623c9b443d4STobin Davis &spec->multiout.max_channels); 624c9b443d4STobin Davis return err; 625c9b443d4STobin Davis } 626c9b443d4STobin Davis 627c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 628c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 629c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 630c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 631c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 632c9b443d4STobin Davis .private_value = nid | (dir<<16) } 633c9b443d4STobin Davis 63486d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 63586d72bdfSTakashi Iwai 636c9b443d4STobin Davis /* Conexant 5045 specific */ 637c9b443d4STobin Davis 63834cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 63934cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 64034cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 641cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 642c9b443d4STobin Davis 64334cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6445cd57529STobin Davis { 2, NULL }, 6455cd57529STobin Davis }; 646c9b443d4STobin Davis 64734cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 648c9b443d4STobin Davis .num_items = 2, 649c9b443d4STobin Davis .items = { 6503edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6513edbbb9eSMichael Karcher { "Mic", 0x2 }, 652c9b443d4STobin Davis } 653c9b443d4STobin Davis }; 654c9b443d4STobin Davis 65534cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 656e6e03daeSMichael Karcher .num_items = 4, 6575218c892SJiang Zhe .items = { 6583edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6593edbbb9eSMichael Karcher { "Mic", 0x2 }, 6603edbbb9eSMichael Karcher { "Line", 0x3 }, 66122e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6625218c892SJiang Zhe } 6635218c892SJiang Zhe }; 6645218c892SJiang Zhe 665c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 666c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 667c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 668c9b443d4STobin Davis { 669c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 670c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 67182f30040STobin Davis unsigned int bits; 672c9b443d4STobin Davis 67382f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 674c9b443d4STobin Davis return 0; 675c9b443d4STobin Davis 67682f30040STobin Davis /* toggle internal speakers mute depending of presence of 67782f30040STobin Davis * the headphone jack 67882f30040STobin Davis */ 67947fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 68047fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 68147fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 6827f29673bSTobin Davis 68347fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 68447fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 68547fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 686c9b443d4STobin Davis return 1; 687c9b443d4STobin Davis } 688c9b443d4STobin Davis 689c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 69034cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 691cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 692cca3b371STakashi Iwai .values = { 693cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 694cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 695cca3b371STakashi Iwai 0 696cca3b371STakashi Iwai }, 697cca3b371STakashi Iwai }; 698c9b443d4STobin Davis 6997f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 7007f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7017f29673bSTobin Davis { 70234cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7037f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7047f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7057f29673bSTobin Davis {} 7067f29673bSTobin Davis }; 70734cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7087f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7097f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7107f29673bSTobin Davis {} 7117f29673bSTobin Davis }; 7127f29673bSTobin Davis unsigned int present; 7137f29673bSTobin Davis 714d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7157f29673bSTobin Davis if (present) 7167f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7177f29673bSTobin Davis else 7187f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7197f29673bSTobin Davis } 7207f29673bSTobin Davis 721c9b443d4STobin Davis 722c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 723c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 724c9b443d4STobin Davis { 72582f30040STobin Davis struct conexant_spec *spec = codec->spec; 726dd87da1cSTobin Davis unsigned int bits; 727c9b443d4STobin Davis 728d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 729dd87da1cSTobin Davis 73047fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 73147fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 73247fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 733c9b443d4STobin Davis } 734c9b443d4STobin Davis 735c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 736c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 737c9b443d4STobin Davis unsigned int res) 738c9b443d4STobin Davis { 739c9b443d4STobin Davis res >>= 26; 740c9b443d4STobin Davis switch (res) { 741c9b443d4STobin Davis case CONEXANT_HP_EVENT: 742c9b443d4STobin Davis cxt5045_hp_automute(codec); 743c9b443d4STobin Davis break; 7447f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7457f29673bSTobin Davis cxt5045_hp_automic(codec); 7467f29673bSTobin Davis break; 7477f29673bSTobin Davis 748c9b443d4STobin Davis } 749c9b443d4STobin Davis } 750c9b443d4STobin Davis 75134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 752cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 753cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 754c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 755c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 75628c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 75728c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7588607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7598607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 760cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 761c9b443d4STobin Davis { 762c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 763c9b443d4STobin Davis .name = "Master Playback Switch", 76482f30040STobin Davis .info = cxt_eapd_info, 76582f30040STobin Davis .get = cxt_eapd_get, 766c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 76782f30040STobin Davis .private_value = 0x10, 768c9b443d4STobin Davis }, 769c9b443d4STobin Davis 770c9b443d4STobin Davis {} 771c9b443d4STobin Davis }; 772c9b443d4STobin Davis 77334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7743edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7753edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 77622e14130SLukasz Marcinowski 7775218c892SJiang Zhe {} 7785218c892SJiang Zhe }; 7795218c892SJiang Zhe 78034cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 781c9b443d4STobin Davis /* Line in, Mic */ 7824090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 7837f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 784c9b443d4STobin Davis /* HP, Amp */ 785c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 786c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 78782f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 788c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 789c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 790c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 791c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 792c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 793c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 79428c4edb7SDavid Henningsson /* Record selector: Internal mic */ 7957f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 79682f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 797c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 798c9b443d4STobin Davis /* SPDIF route: PCM */ 799cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 800c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 801c9b443d4STobin Davis /* EAPD */ 80282f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 803c9b443d4STobin Davis { } /* end */ 804c9b443d4STobin Davis }; 805c9b443d4STobin Davis 80634cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 80728c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8085218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8095218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8105218c892SJiang Zhe /* Line In,HP, Amp */ 8115218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8125218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8135218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8145218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8155218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8165218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8175218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8185218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8195218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 82028c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8215218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8225218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8235218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8245218c892SJiang Zhe /* SPDIF route: PCM */ 825cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8265218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8275218c892SJiang Zhe /* EAPD */ 8285218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8295218c892SJiang Zhe { } /* end */ 8305218c892SJiang Zhe }; 8317f29673bSTobin Davis 83234cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8337f29673bSTobin Davis /* pin sensing on HP jack */ 8347f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 835d3091fadSTakashi Iwai { } /* end */ 8367f29673bSTobin Davis }; 8377f29673bSTobin Davis 83834cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8397f29673bSTobin Davis /* pin sensing on HP jack */ 8407f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 841d3091fadSTakashi Iwai { } /* end */ 8427f29673bSTobin Davis }; 8437f29673bSTobin Davis 844c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 845c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 846c9b443d4STobin Davis * configuration. 847c9b443d4STobin Davis */ 84834cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 849c9b443d4STobin Davis .num_items = 5, 850c9b443d4STobin Davis .items = { 851c9b443d4STobin Davis { "MIXER", 0x0 }, 852c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 853c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 854c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 855c9b443d4STobin Davis { "CD pin", 0x4 }, 856c9b443d4STobin Davis }, 857c9b443d4STobin Davis }; 858c9b443d4STobin Davis 85934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 860c9b443d4STobin Davis 861c9b443d4STobin Davis /* Output controls */ 862c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 863c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 864250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 865250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 866250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 867250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 868c9b443d4STobin Davis 869c9b443d4STobin Davis /* Modes for retasking pin widgets */ 870c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 871c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 872c9b443d4STobin Davis 87382f30040STobin Davis /* EAPD Switch Control */ 87482f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 87582f30040STobin Davis 876c9b443d4STobin Davis /* Loopback mixer controls */ 877c9b443d4STobin Davis 878250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 879250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 880250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 881250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 882250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 883250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 884250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 885250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 886250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 887250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 888c9b443d4STobin Davis { 889c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 890c9b443d4STobin Davis .name = "Input Source", 891c9b443d4STobin Davis .info = conexant_mux_enum_info, 892c9b443d4STobin Davis .get = conexant_mux_enum_get, 893c9b443d4STobin Davis .put = conexant_mux_enum_put, 894c9b443d4STobin Davis }, 895fb3409e7STobin Davis /* Audio input controls */ 896cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 897cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 898c9b443d4STobin Davis { } /* end */ 899c9b443d4STobin Davis }; 900c9b443d4STobin Davis 90134cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9027f29673bSTobin Davis /* Set connections */ 9037f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9047f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9057f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 906c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 907c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9087f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 909c9b443d4STobin Davis 910c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 911c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 912c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 913c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 914c9b443d4STobin Davis * control. 915c9b443d4STobin Davis */ 916cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 917cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 918c9b443d4STobin Davis 919c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 920c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 921c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 922c9b443d4STobin Davis * input/output buffers as needed. 923c9b443d4STobin Davis */ 924c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 925c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 926c9b443d4STobin Davis 927c9b443d4STobin Davis /* Mute capture amp left and right */ 928c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 929c9b443d4STobin Davis 930c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 931c9b443d4STobin Davis * pin) 932c9b443d4STobin Davis */ 933250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 934250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 935c9b443d4STobin Davis 936c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 937250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 938c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 939c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 940c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 941c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 942c9b443d4STobin Davis 943c9b443d4STobin Davis { } 944c9b443d4STobin Davis }; 945c9b443d4STobin Davis #endif 946c9b443d4STobin Davis 947c9b443d4STobin Davis 948c9b443d4STobin Davis /* initialize jack-sensing, too */ 949c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 950c9b443d4STobin Davis { 951c9b443d4STobin Davis conexant_init(codec); 952c9b443d4STobin Davis cxt5045_hp_automute(codec); 953c9b443d4STobin Davis return 0; 954c9b443d4STobin Davis } 955c9b443d4STobin Davis 956c9b443d4STobin Davis 957c9b443d4STobin Davis enum { 95815908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 95915908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 96015908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 9615218c892SJiang Zhe CXT5045_BENQ, 962c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 963c9b443d4STobin Davis CXT5045_TEST, 964c9b443d4STobin Davis #endif 9651f8458a2STakashi Iwai CXT5045_AUTO, 966f5fcc13cSTakashi Iwai CXT5045_MODELS 967c9b443d4STobin Davis }; 968c9b443d4STobin Davis 969ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 97015908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 97115908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 97215908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 9735218c892SJiang Zhe [CXT5045_BENQ] = "benq", 974c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 975f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 976c9b443d4STobin Davis #endif 9771f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 978f5fcc13cSTakashi Iwai }; 979c9b443d4STobin Davis 98034cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 9815218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 98215908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 98315908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 9849e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 9859e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 98615908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 98715908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 98815908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 989dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 990dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 99115908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 992c9b443d4STobin Davis {} 993c9b443d4STobin Davis }; 994c9b443d4STobin Davis 995c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 996c9b443d4STobin Davis { 997c9b443d4STobin Davis struct conexant_spec *spec; 998c9b443d4STobin Davis int board_config; 999c9b443d4STobin Davis 10001f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10011f8458a2STakashi Iwai cxt5045_models, 10021f8458a2STakashi Iwai cxt5045_cfg_tbl); 10031f8458a2STakashi Iwai if (board_config < 0) 1004c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10051f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10061f8458a2STakashi Iwai return patch_conexant_auto(codec); 10071f8458a2STakashi Iwai 1008c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1009c9b443d4STobin Davis if (!spec) 1010c9b443d4STobin Davis return -ENOMEM; 1011c9b443d4STobin Davis codec->spec = spec; 10124f32456eSMichael Karcher codec->single_adc_amp = 1; 1013c9b443d4STobin Davis 1014c9b443d4STobin Davis spec->multiout.max_channels = 2; 1015c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1016c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1017c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1018c9b443d4STobin Davis spec->num_adc_nids = 1; 1019c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1020c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1021c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1022c9b443d4STobin Davis spec->num_mixers = 1; 1023c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1024c9b443d4STobin Davis spec->num_init_verbs = 1; 1025c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1026c9b443d4STobin Davis spec->spdif_route = 0; 10273507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10283507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10295cd57529STobin Davis 10303507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1031c9b443d4STobin Davis 1032c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1033c9b443d4STobin Davis 1034c9b443d4STobin Davis switch (board_config) { 103515908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10367f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1037c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1038c9b443d4STobin Davis spec->num_init_verbs = 2; 10397f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10407f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10417f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10427f29673bSTobin Davis break; 104315908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 104486376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10457f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10467f29673bSTobin Davis spec->num_init_verbs = 2; 10477f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1048c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1049c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1050c9b443d4STobin Davis break; 105115908c36SMarc Boucher default: 105215908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 105315908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 105415908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 105515908c36SMarc Boucher spec->num_init_verbs = 3; 105615908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 105715908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 105815908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 105915908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 106015908c36SMarc Boucher break; 10615218c892SJiang Zhe case CXT5045_BENQ: 10625218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10635218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 10645218c892SJiang Zhe spec->num_init_verbs = 1; 10655218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 10665218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 10675218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 10685218c892SJiang Zhe spec->num_mixers = 2; 10695218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 10705218c892SJiang Zhe break; 1071c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1072c9b443d4STobin Davis case CXT5045_TEST: 1073c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1074c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1075c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 107615908c36SMarc Boucher break; 107715908c36SMarc Boucher 1078c9b443d4STobin Davis #endif 1079c9b443d4STobin Davis } 108048ecb7e8STakashi Iwai 1081031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1082031005f7STakashi Iwai case 0x103c: 10838f0f5ff6SDaniel T Chen case 0x1631: 10840b587fc4SDaniel T Chen case 0x1734: 10850ebf9e36SDaniel T Chen case 0x17aa: 10860ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 10870ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 10880ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 108948ecb7e8STakashi Iwai */ 109048ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 109148ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 109248ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 109348ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 109448ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1095031005f7STakashi Iwai break; 1096031005f7STakashi Iwai } 109748ecb7e8STakashi Iwai 10983507e2a8STakashi Iwai if (spec->beep_amp) 1099a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 11003507e2a8STakashi Iwai 1101c9b443d4STobin Davis return 0; 1102c9b443d4STobin Davis } 1103c9b443d4STobin Davis 1104c9b443d4STobin Davis 1105c9b443d4STobin Davis /* Conexant 5047 specific */ 110682f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1107c9b443d4STobin Davis 110834cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 110934cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 111034cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1111c9b443d4STobin Davis 111234cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11135cd57529STobin Davis { 2, NULL }, 11145cd57529STobin Davis }; 1115c9b443d4STobin Davis 111634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 111782f30040STobin Davis .num_items = 2, 111882f30040STobin Davis .items = { 111982f30040STobin Davis { "ExtMic", 0x2 }, 112082f30040STobin Davis { "Line-In", 0x1 }, 1121c9b443d4STobin Davis } 1122c9b443d4STobin Davis }; 1123c9b443d4STobin Davis 1124c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1125c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1126c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1127c9b443d4STobin Davis { 1128c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1129c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 113082f30040STobin Davis unsigned int bits; 1131c9b443d4STobin Davis 113282f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1133c9b443d4STobin Davis return 0; 1134c9b443d4STobin Davis 113582f30040STobin Davis /* toggle internal speakers mute depending of presence of 113682f30040STobin Davis * the headphone jack 113782f30040STobin Davis */ 113847fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11393b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11403b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11413b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11423b7523fcSTakashi Iwai */ 11435d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 114447fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 114547fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 114647fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 114747fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1148c9b443d4STobin Davis return 1; 1149c9b443d4STobin Davis } 1150c9b443d4STobin Davis 1151c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1152c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1153c9b443d4STobin Davis { 115482f30040STobin Davis struct conexant_spec *spec = codec->spec; 1155dd87da1cSTobin Davis unsigned int bits; 1156c9b443d4STobin Davis 1157d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1158dd87da1cSTobin Davis 115947fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 11603b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 11615d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 116247fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1163c9b443d4STobin Davis } 1164c9b443d4STobin Davis 1165c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1166c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1167c9b443d4STobin Davis { 116834cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 11699f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11709f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1171c9b443d4STobin Davis {} 1172c9b443d4STobin Davis }; 117334cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 11749f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11759f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1176c9b443d4STobin Davis {} 1177c9b443d4STobin Davis }; 1178c9b443d4STobin Davis unsigned int present; 1179c9b443d4STobin Davis 1180d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1181c9b443d4STobin Davis if (present) 1182c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1183c9b443d4STobin Davis else 1184c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1185c9b443d4STobin Davis } 1186c9b443d4STobin Davis 1187c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1188c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1189c9b443d4STobin Davis unsigned int res) 1190c9b443d4STobin Davis { 11919f113e0eSMarc Boucher switch (res >> 26) { 1192c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1193c9b443d4STobin Davis cxt5047_hp_automute(codec); 1194c9b443d4STobin Davis break; 1195c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1196c9b443d4STobin Davis cxt5047_hp_automic(codec); 1197c9b443d4STobin Davis break; 1198c9b443d4STobin Davis } 1199c9b443d4STobin Davis } 1200c9b443d4STobin Davis 120134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1202df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1203df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12045f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1205c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1206c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1207c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1208c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 120982f30040STobin Davis { 121082f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 121182f30040STobin Davis .name = "Master Playback Switch", 121282f30040STobin Davis .info = cxt_eapd_info, 121382f30040STobin Davis .get = cxt_eapd_get, 1214c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1215c9b443d4STobin Davis .private_value = 0x13, 1216c9b443d4STobin Davis }, 1217c9b443d4STobin Davis 1218c9b443d4STobin Davis {} 1219c9b443d4STobin Davis }; 1220c9b443d4STobin Davis 122134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12223b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12235d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1224df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1225df481e41STakashi Iwai {} 1226df481e41STakashi Iwai }; 1227df481e41STakashi Iwai 122834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1229c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1230c9b443d4STobin Davis { } /* end */ 1231c9b443d4STobin Davis }; 1232c9b443d4STobin Davis 123334cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1234c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1235c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1236c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1237c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12387f29673bSTobin Davis /* HP, Speaker */ 1239b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12405b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12415b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12427f29673bSTobin Davis /* Record selector: Mic */ 12437f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12447f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12457f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12467f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1247c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1248c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1249c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1250c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1251c9b443d4STobin Davis /* SPDIF route: PCM */ 1252c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 125382f30040STobin Davis /* Enable unsolicited events */ 125482f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 125582f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1256c9b443d4STobin Davis { } /* end */ 1257c9b443d4STobin Davis }; 1258c9b443d4STobin Davis 1259c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 126034cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 12613b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1262c9b443d4STobin Davis {} 1263c9b443d4STobin Davis }; 1264c9b443d4STobin Davis 1265c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1266c9b443d4STobin Davis * configuration. 1267c9b443d4STobin Davis */ 1268c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 126934cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 127082f30040STobin Davis .num_items = 4, 1271c9b443d4STobin Davis .items = { 127282f30040STobin Davis { "LINE1 pin", 0x0 }, 127382f30040STobin Davis { "MIC1 pin", 0x1 }, 127482f30040STobin Davis { "MIC2 pin", 0x2 }, 127582f30040STobin Davis { "CD pin", 0x3 }, 1276c9b443d4STobin Davis }, 1277c9b443d4STobin Davis }; 1278c9b443d4STobin Davis 127934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1280c9b443d4STobin Davis 1281c9b443d4STobin Davis /* Output only controls */ 128282f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 128382f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 128482f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 128582f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1286c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1287c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1288c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1289c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 129082f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 129182f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 129282f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 129382f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1294c9b443d4STobin Davis 1295c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1296c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1297c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1298c9b443d4STobin Davis 129982f30040STobin Davis /* EAPD Switch Control */ 130082f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 130182f30040STobin Davis 1302c9b443d4STobin Davis /* Loopback mixer controls */ 130382f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 130482f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 130582f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 130682f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 130782f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 130882f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 130982f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 131082f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1311c9b443d4STobin Davis 131282f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 131382f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 131482f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 131582f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 131682f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 131782f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 131882f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 131982f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1320c9b443d4STobin Davis { 1321c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1322c9b443d4STobin Davis .name = "Input Source", 1323c9b443d4STobin Davis .info = conexant_mux_enum_info, 1324c9b443d4STobin Davis .get = conexant_mux_enum_get, 1325c9b443d4STobin Davis .put = conexant_mux_enum_put, 1326c9b443d4STobin Davis }, 1327854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13289f113e0eSMarc Boucher 1329c9b443d4STobin Davis { } /* end */ 1330c9b443d4STobin Davis }; 1331c9b443d4STobin Davis 133234cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1333c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1334c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1335c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1336c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1337c9b443d4STobin Davis 1338c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1339c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1340c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1341c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1342c9b443d4STobin Davis * control. 1343c9b443d4STobin Davis */ 1344c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1345c9b443d4STobin Davis 1346c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1347c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1348c9b443d4STobin Davis */ 1349c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1350c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1351c9b443d4STobin Davis 1352c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1353c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1354c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1355c9b443d4STobin Davis 1356c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1357c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1358c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1359c9b443d4STobin Davis * input/output buffers as needed. 1360c9b443d4STobin Davis */ 1361c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1362c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1363c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1364c9b443d4STobin Davis 1365c9b443d4STobin Davis /* Mute capture amp left and right */ 1366c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1367c9b443d4STobin Davis 1368c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1369c9b443d4STobin Davis * pin) 1370c9b443d4STobin Davis */ 1371c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1372c9b443d4STobin Davis 1373c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1374c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1375c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1376c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1377c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1378c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1379c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1380c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1381c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1382c9b443d4STobin Davis 1383c9b443d4STobin Davis { } 1384c9b443d4STobin Davis }; 1385c9b443d4STobin Davis #endif 1386c9b443d4STobin Davis 1387c9b443d4STobin Davis 1388c9b443d4STobin Davis /* initialize jack-sensing, too */ 1389c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1390c9b443d4STobin Davis { 1391c9b443d4STobin Davis conexant_init(codec); 1392c9b443d4STobin Davis cxt5047_hp_automute(codec); 1393c9b443d4STobin Davis return 0; 1394c9b443d4STobin Davis } 1395c9b443d4STobin Davis 1396c9b443d4STobin Davis 1397c9b443d4STobin Davis enum { 1398f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1399f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1400f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1401c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1402c9b443d4STobin Davis CXT5047_TEST, 1403c9b443d4STobin Davis #endif 1404fa5dadcbSTakashi Iwai CXT5047_AUTO, 1405f5fcc13cSTakashi Iwai CXT5047_MODELS 1406c9b443d4STobin Davis }; 1407c9b443d4STobin Davis 1408ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1409f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1410f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1411f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1412c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1413f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1414c9b443d4STobin Davis #endif 1415fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1416f5fcc13cSTakashi Iwai }; 1417c9b443d4STobin Davis 141834cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1419ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1420dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1421dea0a509STakashi Iwai CXT5047_LAPTOP), 1422f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1423c9b443d4STobin Davis {} 1424c9b443d4STobin Davis }; 1425c9b443d4STobin Davis 1426c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1427c9b443d4STobin Davis { 1428c9b443d4STobin Davis struct conexant_spec *spec; 1429c9b443d4STobin Davis int board_config; 1430c9b443d4STobin Davis 1431fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1432fa5dadcbSTakashi Iwai cxt5047_models, 1433fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1434fa5dadcbSTakashi Iwai if (board_config < 0) 1435c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1436fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1437fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1438fa5dadcbSTakashi Iwai 1439c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1440c9b443d4STobin Davis if (!spec) 1441c9b443d4STobin Davis return -ENOMEM; 1442c9b443d4STobin Davis codec->spec = spec; 14439421f954STakashi Iwai codec->pin_amp_workaround = 1; 1444c9b443d4STobin Davis 1445c9b443d4STobin Davis spec->multiout.max_channels = 2; 1446c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1447c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1448c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1449c9b443d4STobin Davis spec->num_adc_nids = 1; 1450c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1451c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1452c9b443d4STobin Davis spec->num_mixers = 1; 1453df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1454c9b443d4STobin Davis spec->num_init_verbs = 1; 1455c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1456c9b443d4STobin Davis spec->spdif_route = 0; 14575cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 14585cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1459c9b443d4STobin Davis 1460c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1461c9b443d4STobin Davis 1462c9b443d4STobin Davis switch (board_config) { 1463c9b443d4STobin Davis case CXT5047_LAPTOP: 1464df481e41STakashi Iwai spec->num_mixers = 2; 1465df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1466df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1467c9b443d4STobin Davis break; 1468c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1469df481e41STakashi Iwai spec->num_mixers = 2; 1470df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1471fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1472c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1473c9b443d4STobin Davis break; 1474c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 147582f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1476df481e41STakashi Iwai spec->num_mixers = 2; 1477df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1478c9b443d4STobin Davis spec->num_init_verbs = 2; 1479c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1480fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1481c9b443d4STobin Davis break; 1482c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1483c9b443d4STobin Davis case CXT5047_TEST: 1484c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1485c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1486c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1487fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1488c9b443d4STobin Davis #endif 1489c9b443d4STobin Davis } 1490dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1491025f206cSDaniel T Chen 1492025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1493025f206cSDaniel T Chen case 0x103c: 1494025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1495025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1496025f206cSDaniel T Chen * with 0 dB offset 0x17) 1497025f206cSDaniel T Chen */ 1498025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1499025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1500025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1501025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1502025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1503025f206cSDaniel T Chen break; 1504025f206cSDaniel T Chen } 1505025f206cSDaniel T Chen 1506c9b443d4STobin Davis return 0; 1507c9b443d4STobin Davis } 1508c9b443d4STobin Davis 1509461e2c78STakashi Iwai /* Conexant 5051 specific */ 151034cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 151134cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1512461e2c78STakashi Iwai 151334cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1514461e2c78STakashi Iwai { 2, NULL }, 1515461e2c78STakashi Iwai }; 1516461e2c78STakashi Iwai 1517461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1518461e2c78STakashi Iwai { 1519461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1520461e2c78STakashi Iwai unsigned int pinctl; 152123d2df5bSTakashi Iwai /* headphone pin */ 152223d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1523cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 152423d2df5bSTakashi Iwai /* speaker pin */ 1525461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1526cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1527a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1528f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1529cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1530461e2c78STakashi Iwai } 1531461e2c78STakashi Iwai 1532461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1533461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1534461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1535461e2c78STakashi Iwai { 1536461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1537461e2c78STakashi Iwai 1538461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1539461e2c78STakashi Iwai return 0; 1540461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1541461e2c78STakashi Iwai return 1; 1542461e2c78STakashi Iwai } 1543461e2c78STakashi Iwai 1544461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1545461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1546461e2c78STakashi Iwai { 154779d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1548461e2c78STakashi Iwai unsigned int present; 1549461e2c78STakashi Iwai 1550faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 155179d7d533STakashi Iwai return; 1552d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1553461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1554461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1555461e2c78STakashi Iwai present ? 0x01 : 0x00); 1556461e2c78STakashi Iwai } 1557461e2c78STakashi Iwai 1558461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1559461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1560461e2c78STakashi Iwai { 1561461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1562461e2c78STakashi Iwai unsigned int present; 1563461e2c78STakashi Iwai hda_nid_t new_adc; 1564461e2c78STakashi Iwai 1565faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 156679d7d533STakashi Iwai return; 1567d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1568461e2c78STakashi Iwai if (present) 1569461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1570461e2c78STakashi Iwai else 1571461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1572461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1573461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1574461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1575f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1576461e2c78STakashi Iwai spec->cur_adc = new_adc; 1577461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1578461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1579461e2c78STakashi Iwai spec->cur_adc_format); 1580461e2c78STakashi Iwai } 1581461e2c78STakashi Iwai } 1582461e2c78STakashi Iwai 1583461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1584461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1585461e2c78STakashi Iwai { 1586461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1587461e2c78STakashi Iwai 1588d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1589461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1590461e2c78STakashi Iwai } 1591461e2c78STakashi Iwai 1592461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1593461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1594461e2c78STakashi Iwai unsigned int res) 1595461e2c78STakashi Iwai { 1596461e2c78STakashi Iwai switch (res >> 26) { 1597461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1598461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1599461e2c78STakashi Iwai break; 1600461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1601461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1602461e2c78STakashi Iwai break; 1603461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1604461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1605461e2c78STakashi Iwai break; 1606461e2c78STakashi Iwai } 1607461e2c78STakashi Iwai } 1608461e2c78STakashi Iwai 160934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1610461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1611461e2c78STakashi Iwai { 1612461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1613461e2c78STakashi Iwai .name = "Master Playback Switch", 1614461e2c78STakashi Iwai .info = cxt_eapd_info, 1615461e2c78STakashi Iwai .get = cxt_eapd_get, 1616461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1617461e2c78STakashi Iwai .private_value = 0x1a, 1618461e2c78STakashi Iwai }, 16192c7a3fb3STakashi Iwai {} 16202c7a3fb3STakashi Iwai }; 1621461e2c78STakashi Iwai 162234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16232c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16242c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16258607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16268607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1627c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1628c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1629461e2c78STakashi Iwai {} 1630461e2c78STakashi Iwai }; 1631461e2c78STakashi Iwai 163234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1633461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1634461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16358607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16368607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1637461e2c78STakashi Iwai {} 1638461e2c78STakashi Iwai }; 1639461e2c78STakashi Iwai 164034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16414e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16424e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 164379d7d533STakashi Iwai {} 164479d7d533STakashi Iwai }; 164579d7d533STakashi Iwai 164634cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 16475f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 16485f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1649cd9d95a5SKen Prox {} 1650cd9d95a5SKen Prox }; 1651cd9d95a5SKen Prox 165234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1653faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1654faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16558607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16568607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1657faddaa5dSTakashi Iwai {} 1658faddaa5dSTakashi Iwai }; 1659faddaa5dSTakashi Iwai 166034cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1661461e2c78STakashi Iwai /* Line in, Mic */ 1662461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1663461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1664461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1665461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1666461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1667461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1668461e2c78STakashi Iwai /* SPK */ 1669461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1670461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1671461e2c78STakashi Iwai /* HP, Amp */ 1672461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1673461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1674461e2c78STakashi Iwai /* DAC1 */ 1675461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 167628c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1677461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1678461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1679461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1680461e2c78STakashi Iwai /* SPDIF route: PCM */ 16811965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1682461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1683461e2c78STakashi Iwai /* EAPD */ 1684461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1685461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1686461e2c78STakashi Iwai { } /* end */ 1687461e2c78STakashi Iwai }; 1688461e2c78STakashi Iwai 168934cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 169079d7d533STakashi Iwai /* Line in, Mic */ 169179d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 169279d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 169379d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 169479d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 169579d7d533STakashi Iwai /* SPK */ 169679d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 169779d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 169879d7d533STakashi Iwai /* HP, Amp */ 169979d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 170079d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 170179d7d533STakashi Iwai /* DAC1 */ 170279d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 170328c4edb7SDavid Henningsson /* Record selector: Internal mic */ 170479d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 170579d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 170679d7d533STakashi Iwai /* SPDIF route: PCM */ 170779d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 170879d7d533STakashi Iwai /* EAPD */ 170979d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 171079d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 171179d7d533STakashi Iwai { } /* end */ 171279d7d533STakashi Iwai }; 171379d7d533STakashi Iwai 171434cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1715cd9d95a5SKen Prox /* Line in, Mic */ 171630ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1717cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1718cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1719cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1720cd9d95a5SKen Prox /* SPK */ 1721cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1722cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1723cd9d95a5SKen Prox /* HP, Amp */ 1724cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1725cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1726cd9d95a5SKen Prox /* DAC1 */ 1727cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172828c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1729cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1730cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1731cd9d95a5SKen Prox /* SPDIF route: PCM */ 1732cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1733cd9d95a5SKen Prox /* EAPD */ 1734cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1735cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1736cd9d95a5SKen Prox { } /* end */ 1737cd9d95a5SKen Prox }; 1738cd9d95a5SKen Prox 17396953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17406953e552STakashi Iwai unsigned int event) 17416953e552STakashi Iwai { 17426953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17436953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17446953e552STakashi Iwai AC_USRSP_EN | event); 17456953e552STakashi Iwai } 17466953e552STakashi Iwai 174734cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1748f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1749f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1750f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1751f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1752f7154de2SHerton Ronaldo Krzesinski }; 1753f7154de2SHerton Ronaldo Krzesinski 1754461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1755461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1756461e2c78STakashi Iwai { 17576953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 17586953e552STakashi Iwai 1759461e2c78STakashi Iwai conexant_init(codec); 17606953e552STakashi Iwai 17616953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 17626953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 17636953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 17646953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 17656953e552STakashi Iwai 1766461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1767461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1768461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1769461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1770461e2c78STakashi Iwai } 1771461e2c78STakashi Iwai return 0; 1772461e2c78STakashi Iwai } 1773461e2c78STakashi Iwai 1774461e2c78STakashi Iwai 1775461e2c78STakashi Iwai enum { 1776461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1777461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 177879d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1779cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1780faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1781f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 17826764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1783461e2c78STakashi Iwai CXT5051_MODELS 1784461e2c78STakashi Iwai }; 1785461e2c78STakashi Iwai 1786ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1787461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1788461e2c78STakashi Iwai [CXT5051_HP] = "hp", 178979d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 17905f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1791faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1792f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 17936764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1794461e2c78STakashi Iwai }; 1795461e2c78STakashi Iwai 179634cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 179779d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 17981812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 17995f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1800faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1801461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1802461e2c78STakashi Iwai CXT5051_LAPTOP), 1803461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1804f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1805461e2c78STakashi Iwai {} 1806461e2c78STakashi Iwai }; 1807461e2c78STakashi Iwai 1808461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1809461e2c78STakashi Iwai { 1810461e2c78STakashi Iwai struct conexant_spec *spec; 1811461e2c78STakashi Iwai int board_config; 1812461e2c78STakashi Iwai 18136764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18146764bcefSTakashi Iwai cxt5051_models, 18156764bcefSTakashi Iwai cxt5051_cfg_tbl); 18166764bcefSTakashi Iwai if (board_config < 0) 1817c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18181f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18196764bcefSTakashi Iwai return patch_conexant_auto(codec); 18206764bcefSTakashi Iwai 1821461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1822461e2c78STakashi Iwai if (!spec) 1823461e2c78STakashi Iwai return -ENOMEM; 1824461e2c78STakashi Iwai codec->spec = spec; 18259421f954STakashi Iwai codec->pin_amp_workaround = 1; 1826461e2c78STakashi Iwai 1827461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1828461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1829461e2c78STakashi Iwai 1830461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1831461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1832461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1833461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1834461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1835461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18362c7a3fb3STakashi Iwai spec->num_mixers = 2; 18372c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18382c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1839461e2c78STakashi Iwai spec->num_init_verbs = 1; 1840461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1841461e2c78STakashi Iwai spec->spdif_route = 0; 1842461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1843461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1844461e2c78STakashi Iwai spec->cur_adc = 0; 1845461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1846461e2c78STakashi Iwai 18473507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 18483507e2a8STakashi Iwai 184979d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 185079d7d533STakashi Iwai 1851faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1852461e2c78STakashi Iwai switch (board_config) { 1853461e2c78STakashi Iwai case CXT5051_HP: 1854461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1855461e2c78STakashi Iwai break; 185679d7d533STakashi Iwai case CXT5051_HP_DV6736: 185779d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 185879d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1859faddaa5dSTakashi Iwai spec->auto_mic = 0; 186079d7d533STakashi Iwai break; 1861cd9d95a5SKen Prox case CXT5051_F700: 1862cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1863cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1864faddaa5dSTakashi Iwai spec->auto_mic = 0; 1865faddaa5dSTakashi Iwai break; 1866faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1867faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1868faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1869cd9d95a5SKen Prox break; 1870f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1871f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1872f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1873f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1874f7154de2SHerton Ronaldo Krzesinski break; 1875461e2c78STakashi Iwai } 1876461e2c78STakashi Iwai 18773507e2a8STakashi Iwai if (spec->beep_amp) 1878a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 18793507e2a8STakashi Iwai 1880461e2c78STakashi Iwai return 0; 1881461e2c78STakashi Iwai } 1882461e2c78STakashi Iwai 18830fb67e98SDaniel Drake /* Conexant 5066 specific */ 18840fb67e98SDaniel Drake 188534cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 188634cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 188734cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 188834cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 18890fb67e98SDaniel Drake 189034cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 18910fb67e98SDaniel Drake { 2, NULL }, 18920fb67e98SDaniel Drake }; 18930fb67e98SDaniel Drake 1894a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1895a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1896a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1897a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1898a3de8ab8STakashi Iwai 18990fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 19000fb67e98SDaniel Drake { 19010fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19020fb67e98SDaniel Drake unsigned int pinctl; 19030fb67e98SDaniel Drake 19043a253445SJohn Baboval snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 19053a253445SJohn Baboval spec->hp_present, spec->cur_eapd); 19060fb67e98SDaniel Drake 19070fb67e98SDaniel Drake /* Port A (HP) */ 1908a3de8ab8STakashi Iwai pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; 1909cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x19, pinctl); 19100fb67e98SDaniel Drake 19110fb67e98SDaniel Drake /* Port D (HP/LO) */ 1912a3de8ab8STakashi Iwai pinctl = spec->cur_eapd ? spec->port_d_mode : 0; 1913a3de8ab8STakashi Iwai if (spec->dell_automute || spec->thinkpad) { 1914a3de8ab8STakashi Iwai /* Mute if Port A is connected */ 1915a3de8ab8STakashi Iwai if (hp_port_a_present(spec)) 19163a253445SJohn Baboval pinctl = 0; 19173a253445SJohn Baboval } else { 1918a3de8ab8STakashi Iwai /* Thinkpad/Dell doesn't give pin-D status */ 1919a3de8ab8STakashi Iwai if (!hp_port_d_present(spec)) 1920a3de8ab8STakashi Iwai pinctl = 0; 19213a253445SJohn Baboval } 1922cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1c, pinctl); 19230fb67e98SDaniel Drake 19240fb67e98SDaniel Drake /* CLASS_D AMP */ 19250fb67e98SDaniel Drake pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1926cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1f, pinctl); 19270fb67e98SDaniel Drake } 19280fb67e98SDaniel Drake 19290fb67e98SDaniel Drake /* turn on/off EAPD (+ mute HP) as a master switch */ 19300fb67e98SDaniel Drake static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, 19310fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 19320fb67e98SDaniel Drake { 19330fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 19340fb67e98SDaniel Drake 19350fb67e98SDaniel Drake if (!cxt_eapd_put(kcontrol, ucontrol)) 19360fb67e98SDaniel Drake return 0; 19370fb67e98SDaniel Drake 19380fb67e98SDaniel Drake cxt5066_update_speaker(codec); 19390fb67e98SDaniel Drake return 1; 19400fb67e98SDaniel Drake } 19410fb67e98SDaniel Drake 194295a618bdSEinar Rünkaru /* toggle input of built-in digital mic and mic jack appropriately */ 194395a618bdSEinar Rünkaru static void cxt5066_vostro_automic(struct hda_codec *codec) 194495a618bdSEinar Rünkaru { 194595a618bdSEinar Rünkaru unsigned int present; 194695a618bdSEinar Rünkaru 194795a618bdSEinar Rünkaru struct hda_verb ext_mic_present[] = { 194895a618bdSEinar Rünkaru /* enable external mic, port B */ 194975f8991dSDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 195095a618bdSEinar Rünkaru 195195a618bdSEinar Rünkaru /* switch to external mic input */ 195295a618bdSEinar Rünkaru {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 195395a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 195495a618bdSEinar Rünkaru 195595a618bdSEinar Rünkaru /* disable internal digital mic */ 195695a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 195795a618bdSEinar Rünkaru {} 195895a618bdSEinar Rünkaru }; 195934cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 196095a618bdSEinar Rünkaru /* enable internal mic, port C */ 196195a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 196295a618bdSEinar Rünkaru 196395a618bdSEinar Rünkaru /* switch to internal mic input */ 196495a618bdSEinar Rünkaru {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 196595a618bdSEinar Rünkaru 196695a618bdSEinar Rünkaru /* disable external mic, port B */ 196795a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 196895a618bdSEinar Rünkaru {} 196995a618bdSEinar Rünkaru }; 197095a618bdSEinar Rünkaru 197195a618bdSEinar Rünkaru present = snd_hda_jack_detect(codec, 0x1a); 197295a618bdSEinar Rünkaru if (present) { 197395a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone detected\n"); 197495a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 197595a618bdSEinar Rünkaru } else { 197695a618bdSEinar Rünkaru snd_printdd("CXT5066: external microphone absent\n"); 197795a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_absent); 197895a618bdSEinar Rünkaru } 197995a618bdSEinar Rünkaru } 198095a618bdSEinar Rünkaru 1981cfd3d8dcSGreg Alexander /* toggle input of built-in digital mic and mic jack appropriately */ 1982cfd3d8dcSGreg Alexander static void cxt5066_ideapad_automic(struct hda_codec *codec) 1983cfd3d8dcSGreg Alexander { 1984cfd3d8dcSGreg Alexander unsigned int present; 1985cfd3d8dcSGreg Alexander 1986cfd3d8dcSGreg Alexander struct hda_verb ext_mic_present[] = { 1987cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 1988cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1989cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 1990cfd3d8dcSGreg Alexander {} 1991cfd3d8dcSGreg Alexander }; 199234cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 1993cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 1994cfd3d8dcSGreg Alexander {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1995cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 1996cfd3d8dcSGreg Alexander {} 1997cfd3d8dcSGreg Alexander }; 1998cfd3d8dcSGreg Alexander 1999cfd3d8dcSGreg Alexander present = snd_hda_jack_detect(codec, 0x1b); 2000cfd3d8dcSGreg Alexander if (present) { 2001cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone detected\n"); 2002cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2003cfd3d8dcSGreg Alexander } else { 2004cfd3d8dcSGreg Alexander snd_printdd("CXT5066: external microphone absent\n"); 2005cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_absent); 2006cfd3d8dcSGreg Alexander } 2007cfd3d8dcSGreg Alexander } 2008cfd3d8dcSGreg Alexander 2009a1d6906eSDavid Henningsson 2010a1d6906eSDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2011a1d6906eSDavid Henningsson static void cxt5066_asus_automic(struct hda_codec *codec) 2012a1d6906eSDavid Henningsson { 2013a1d6906eSDavid Henningsson unsigned int present; 2014a1d6906eSDavid Henningsson 2015a1d6906eSDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2016a1d6906eSDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2017a1d6906eSDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2018a1d6906eSDavid Henningsson present ? 1 : 0); 2019a1d6906eSDavid Henningsson } 2020a1d6906eSDavid Henningsson 2021a1d6906eSDavid Henningsson 2022048e78a5SDavid Henningsson /* toggle input of built-in digital mic and mic jack appropriately */ 2023048e78a5SDavid Henningsson static void cxt5066_hp_laptop_automic(struct hda_codec *codec) 2024048e78a5SDavid Henningsson { 2025048e78a5SDavid Henningsson unsigned int present; 2026048e78a5SDavid Henningsson 2027048e78a5SDavid Henningsson present = snd_hda_jack_detect(codec, 0x1b); 2028048e78a5SDavid Henningsson snd_printdd("CXT5066: external microphone present=%d\n", present); 2029048e78a5SDavid Henningsson snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2030048e78a5SDavid Henningsson present ? 1 : 3); 2031048e78a5SDavid Henningsson } 2032048e78a5SDavid Henningsson 2033048e78a5SDavid Henningsson 20347b2bfdbcSJens Taprogge /* toggle input of built-in digital mic and mic jack appropriately 20357b2bfdbcSJens Taprogge order is: external mic -> dock mic -> interal mic */ 20367b2bfdbcSJens Taprogge static void cxt5066_thinkpad_automic(struct hda_codec *codec) 20377b2bfdbcSJens Taprogge { 20387b2bfdbcSJens Taprogge unsigned int ext_present, dock_present; 20397b2bfdbcSJens Taprogge 204034cbe3a6STakashi Iwai static const struct hda_verb ext_mic_present[] = { 20417b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 20427b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 20437b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 20447b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20457b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20467b2bfdbcSJens Taprogge {} 20477b2bfdbcSJens Taprogge }; 204834cbe3a6STakashi Iwai static const struct hda_verb dock_mic_present[] = { 20497b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 0}, 20507b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 20517b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 20527b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20537b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20547b2bfdbcSJens Taprogge {} 20557b2bfdbcSJens Taprogge }; 205634cbe3a6STakashi Iwai static const struct hda_verb ext_mic_absent[] = { 20577b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, 20587b2bfdbcSJens Taprogge {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 20597b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20607b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 20617b2bfdbcSJens Taprogge {} 20627b2bfdbcSJens Taprogge }; 20637b2bfdbcSJens Taprogge 20647b2bfdbcSJens Taprogge ext_present = snd_hda_jack_detect(codec, 0x1b); 20657b2bfdbcSJens Taprogge dock_present = snd_hda_jack_detect(codec, 0x1a); 20667b2bfdbcSJens Taprogge if (ext_present) { 20677b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone detected\n"); 20687b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 20697b2bfdbcSJens Taprogge } else if (dock_present) { 20707b2bfdbcSJens Taprogge snd_printdd("CXT5066: dock microphone detected\n"); 20717b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 20727b2bfdbcSJens Taprogge } else { 20737b2bfdbcSJens Taprogge snd_printdd("CXT5066: external microphone absent\n"); 20747b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_absent); 20757b2bfdbcSJens Taprogge } 20767b2bfdbcSJens Taprogge } 20777b2bfdbcSJens Taprogge 20780fb67e98SDaniel Drake /* mute internal speaker if HP is plugged */ 20790fb67e98SDaniel Drake static void cxt5066_hp_automute(struct hda_codec *codec) 20800fb67e98SDaniel Drake { 20810fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 20820fb67e98SDaniel Drake unsigned int portA, portD; 20830fb67e98SDaniel Drake 20840fb67e98SDaniel Drake /* Port A */ 2085d56757abSTakashi Iwai portA = snd_hda_jack_detect(codec, 0x19); 20860fb67e98SDaniel Drake 20870fb67e98SDaniel Drake /* Port D */ 2088d56757abSTakashi Iwai portD = snd_hda_jack_detect(codec, 0x1c); 20890fb67e98SDaniel Drake 2090a3de8ab8STakashi Iwai spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2091a3de8ab8STakashi Iwai spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 20920fb67e98SDaniel Drake snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 20930fb67e98SDaniel Drake portA, portD, spec->hp_present); 20940fb67e98SDaniel Drake cxt5066_update_speaker(codec); 20950fb67e98SDaniel Drake } 20960fb67e98SDaniel Drake 209702b6b5b6SDavid Henningsson /* Dispatch the right mic autoswitch function */ 209802b6b5b6SDavid Henningsson static void cxt5066_automic(struct hda_codec *codec) 209902b6b5b6SDavid Henningsson { 210002b6b5b6SDavid Henningsson struct conexant_spec *spec = codec->spec; 210102b6b5b6SDavid Henningsson 210202b6b5b6SDavid Henningsson if (spec->dell_vostro) 210302b6b5b6SDavid Henningsson cxt5066_vostro_automic(codec); 210402b6b5b6SDavid Henningsson else if (spec->ideapad) 210502b6b5b6SDavid Henningsson cxt5066_ideapad_automic(codec); 210602b6b5b6SDavid Henningsson else if (spec->thinkpad) 210702b6b5b6SDavid Henningsson cxt5066_thinkpad_automic(codec); 210802b6b5b6SDavid Henningsson else if (spec->hp_laptop) 210902b6b5b6SDavid Henningsson cxt5066_hp_laptop_automic(codec); 2110a1d6906eSDavid Henningsson else if (spec->asus) 2111a1d6906eSDavid Henningsson cxt5066_asus_automic(codec); 211202b6b5b6SDavid Henningsson } 211302b6b5b6SDavid Henningsson 21140fb67e98SDaniel Drake /* unsolicited event for jack sensing */ 211502b6b5b6SDavid Henningsson static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 211695a618bdSEinar Rünkaru { 211702b6b5b6SDavid Henningsson snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 211895a618bdSEinar Rünkaru switch (res >> 26) { 211995a618bdSEinar Rünkaru case CONEXANT_HP_EVENT: 212095a618bdSEinar Rünkaru cxt5066_hp_automute(codec); 212195a618bdSEinar Rünkaru break; 212295a618bdSEinar Rünkaru case CONEXANT_MIC_EVENT: 212302b6b5b6SDavid Henningsson cxt5066_automic(codec); 212495a618bdSEinar Rünkaru break; 212595a618bdSEinar Rünkaru } 212695a618bdSEinar Rünkaru } 212795a618bdSEinar Rünkaru 21287b2bfdbcSJens Taprogge 21290fb67e98SDaniel Drake static const struct hda_input_mux cxt5066_analog_mic_boost = { 21300fb67e98SDaniel Drake .num_items = 5, 21310fb67e98SDaniel Drake .items = { 21320fb67e98SDaniel Drake { "0dB", 0 }, 21330fb67e98SDaniel Drake { "10dB", 1 }, 21340fb67e98SDaniel Drake { "20dB", 2 }, 21350fb67e98SDaniel Drake { "30dB", 3 }, 21360fb67e98SDaniel Drake { "40dB", 4 }, 21370fb67e98SDaniel Drake }, 21380fb67e98SDaniel Drake }; 21390fb67e98SDaniel Drake 2140cfd3d8dcSGreg Alexander static void cxt5066_set_mic_boost(struct hda_codec *codec) 2141c4cfe66cSDaniel Drake { 2142c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2143cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x17, 0, 2144c4cfe66cSDaniel Drake AC_VERB_SET_AMP_GAIN_MUTE, 2145c4cfe66cSDaniel Drake AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2146c4cfe66cSDaniel Drake cxt5066_analog_mic_boost.items[spec->mic_boost].index); 21477b2bfdbcSJens Taprogge if (spec->ideapad || spec->thinkpad) { 2148cfd3d8dcSGreg Alexander /* adjust the internal mic as well...it is not through 0x17 */ 2149cfd3d8dcSGreg Alexander snd_hda_codec_write_cache(codec, 0x23, 0, 2150cfd3d8dcSGreg Alexander AC_VERB_SET_AMP_GAIN_MUTE, 2151cfd3d8dcSGreg Alexander AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | 2152cfd3d8dcSGreg Alexander cxt5066_analog_mic_boost. 2153cfd3d8dcSGreg Alexander items[spec->mic_boost].index); 2154cfd3d8dcSGreg Alexander } 2155c4cfe66cSDaniel Drake } 2156c4cfe66cSDaniel Drake 21570fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 21580fb67e98SDaniel Drake struct snd_ctl_elem_info *uinfo) 21590fb67e98SDaniel Drake { 21600fb67e98SDaniel Drake return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); 21610fb67e98SDaniel Drake } 21620fb67e98SDaniel Drake 21630fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, 21640fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 21650fb67e98SDaniel Drake { 21660fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2167c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 2168c4cfe66cSDaniel Drake ucontrol->value.enumerated.item[0] = spec->mic_boost; 21690fb67e98SDaniel Drake return 0; 21700fb67e98SDaniel Drake } 21710fb67e98SDaniel Drake 21720fb67e98SDaniel Drake static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, 21730fb67e98SDaniel Drake struct snd_ctl_elem_value *ucontrol) 21740fb67e98SDaniel Drake { 21750fb67e98SDaniel Drake struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2176c4cfe66cSDaniel Drake struct conexant_spec *spec = codec->spec; 21770fb67e98SDaniel Drake const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 21780fb67e98SDaniel Drake unsigned int idx; 21790fb67e98SDaniel Drake idx = ucontrol->value.enumerated.item[0]; 21800fb67e98SDaniel Drake if (idx >= imux->num_items) 21810fb67e98SDaniel Drake idx = imux->num_items - 1; 21820fb67e98SDaniel Drake 2183c4cfe66cSDaniel Drake spec->mic_boost = idx; 2184c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 2185c4cfe66cSDaniel Drake return 1; 2186c4cfe66cSDaniel Drake } 21870fb67e98SDaniel Drake 2188f6a2491cSAndy Robinson static void conexant_check_dig_outs(struct hda_codec *codec, 218934cbe3a6STakashi Iwai const hda_nid_t *dig_pins, 2190f6a2491cSAndy Robinson int num_pins) 2191f6a2491cSAndy Robinson { 2192f6a2491cSAndy Robinson struct conexant_spec *spec = codec->spec; 2193f6a2491cSAndy Robinson hda_nid_t *nid_loc = &spec->multiout.dig_out_nid; 2194f6a2491cSAndy Robinson int i; 2195f6a2491cSAndy Robinson 2196f6a2491cSAndy Robinson for (i = 0; i < num_pins; i++, dig_pins++) { 2197f6a2491cSAndy Robinson unsigned int cfg = snd_hda_codec_get_pincfg(codec, *dig_pins); 2198f6a2491cSAndy Robinson if (get_defcfg_connect(cfg) == AC_JACK_PORT_NONE) 2199f6a2491cSAndy Robinson continue; 2200f6a2491cSAndy Robinson if (snd_hda_get_connections(codec, *dig_pins, nid_loc, 1) != 1) 2201f6a2491cSAndy Robinson continue; 2202f6a2491cSAndy Robinson } 2203f6a2491cSAndy Robinson } 2204f6a2491cSAndy Robinson 220534cbe3a6STakashi Iwai static const struct hda_input_mux cxt5066_capture_source = { 22060fb67e98SDaniel Drake .num_items = 4, 22070fb67e98SDaniel Drake .items = { 22080fb67e98SDaniel Drake { "Mic B", 0 }, 22090fb67e98SDaniel Drake { "Mic C", 1 }, 22100fb67e98SDaniel Drake { "Mic E", 2 }, 22110fb67e98SDaniel Drake { "Mic F", 3 }, 22120fb67e98SDaniel Drake }, 22130fb67e98SDaniel Drake }; 22140fb67e98SDaniel Drake 221534cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_vol_others = { 22160fb67e98SDaniel Drake .ops = &snd_hda_bind_vol, 22170fb67e98SDaniel Drake .values = { 22180fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 22190fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 22200fb67e98SDaniel Drake 0 22210fb67e98SDaniel Drake }, 22220fb67e98SDaniel Drake }; 22230fb67e98SDaniel Drake 222434cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5066_bind_capture_sw_others = { 22250fb67e98SDaniel Drake .ops = &snd_hda_bind_sw, 22260fb67e98SDaniel Drake .values = { 22270fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), 22280fb67e98SDaniel Drake HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), 22290fb67e98SDaniel Drake 0 22300fb67e98SDaniel Drake }, 22310fb67e98SDaniel Drake }; 22320fb67e98SDaniel Drake 223334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixer_master[] = { 22340fb67e98SDaniel Drake HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 22350fb67e98SDaniel Drake {} 22360fb67e98SDaniel Drake }; 22370fb67e98SDaniel Drake 223834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_mixers[] = { 22390fb67e98SDaniel Drake { 22400fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 22410fb67e98SDaniel Drake .name = "Master Playback Switch", 22420fb67e98SDaniel Drake .info = cxt_eapd_info, 22430fb67e98SDaniel Drake .get = cxt_eapd_get, 22440fb67e98SDaniel Drake .put = cxt5066_hp_master_sw_put, 22450fb67e98SDaniel Drake .private_value = 0x1d, 22460fb67e98SDaniel Drake }, 22470fb67e98SDaniel Drake 22480fb67e98SDaniel Drake { 22490fb67e98SDaniel Drake .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2250c4cfe66cSDaniel Drake .name = "Analog Mic Boost Capture Enum", 22510fb67e98SDaniel Drake .info = cxt5066_mic_boost_mux_enum_info, 22520fb67e98SDaniel Drake .get = cxt5066_mic_boost_mux_enum_get, 22530fb67e98SDaniel Drake .put = cxt5066_mic_boost_mux_enum_put, 22540fb67e98SDaniel Drake }, 22550fb67e98SDaniel Drake 22560fb67e98SDaniel Drake HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), 22570fb67e98SDaniel Drake HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), 22580fb67e98SDaniel Drake {} 22590fb67e98SDaniel Drake }; 22600fb67e98SDaniel Drake 226134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5066_vostro_mixers[] = { 2262254bba6aSEinar Rünkaru { 2263254bba6aSEinar Rünkaru .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 226428c4edb7SDavid Henningsson .name = "Internal Mic Boost Capture Enum", 2265254bba6aSEinar Rünkaru .info = cxt5066_mic_boost_mux_enum_info, 2266254bba6aSEinar Rünkaru .get = cxt5066_mic_boost_mux_enum_get, 2267254bba6aSEinar Rünkaru .put = cxt5066_mic_boost_mux_enum_put, 2268254bba6aSEinar Rünkaru .private_value = 0x23 | 0x100, 2269254bba6aSEinar Rünkaru }, 2270254bba6aSEinar Rünkaru {} 2271254bba6aSEinar Rünkaru }; 2272254bba6aSEinar Rünkaru 227334cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs[] = { 22740fb67e98SDaniel Drake {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 22750fb67e98SDaniel Drake {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 22760fb67e98SDaniel Drake {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 22770fb67e98SDaniel Drake {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 22780fb67e98SDaniel Drake 22790fb67e98SDaniel Drake /* Speakers */ 22800fb67e98SDaniel Drake {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 22810fb67e98SDaniel Drake {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 22820fb67e98SDaniel Drake 22830fb67e98SDaniel Drake /* HP, Amp */ 22840fb67e98SDaniel Drake {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 22850fb67e98SDaniel Drake {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 22860fb67e98SDaniel Drake 22870fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 22880fb67e98SDaniel Drake {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 22890fb67e98SDaniel Drake 22900fb67e98SDaniel Drake /* DAC1 */ 22910fb67e98SDaniel Drake {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 22920fb67e98SDaniel Drake 22930fb67e98SDaniel Drake /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 22940fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 22950fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 22960fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 22970fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 22980fb67e98SDaniel Drake {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 22990fb67e98SDaniel Drake 23000fb67e98SDaniel Drake /* no digital microphone support yet */ 23010fb67e98SDaniel Drake {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 23020fb67e98SDaniel Drake 23030fb67e98SDaniel Drake /* Audio input selector */ 23040fb67e98SDaniel Drake {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 23050fb67e98SDaniel Drake 23060fb67e98SDaniel Drake /* SPDIF route: PCM */ 23070fb67e98SDaniel Drake {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 23080fb67e98SDaniel Drake {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 23090fb67e98SDaniel Drake 23100fb67e98SDaniel Drake {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 23110fb67e98SDaniel Drake {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 23120fb67e98SDaniel Drake 23130fb67e98SDaniel Drake /* EAPD */ 23140fb67e98SDaniel Drake {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 23150fb67e98SDaniel Drake 23160fb67e98SDaniel Drake /* not handling these yet */ 23170fb67e98SDaniel Drake {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23180fb67e98SDaniel Drake {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23190fb67e98SDaniel Drake {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23200fb67e98SDaniel Drake {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23210fb67e98SDaniel Drake {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23220fb67e98SDaniel Drake {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23230fb67e98SDaniel Drake {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23240fb67e98SDaniel Drake {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, 23250fb67e98SDaniel Drake { } /* end */ 23260fb67e98SDaniel Drake }; 23270fb67e98SDaniel Drake 232834cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_vostro[] = { 232995a618bdSEinar Rünkaru /* Port A: headphones */ 233095a618bdSEinar Rünkaru {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 233195a618bdSEinar Rünkaru {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 233295a618bdSEinar Rünkaru 233395a618bdSEinar Rünkaru /* Port B: external microphone */ 233495a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 233595a618bdSEinar Rünkaru 233695a618bdSEinar Rünkaru /* Port C: unused */ 233795a618bdSEinar Rünkaru {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 233895a618bdSEinar Rünkaru 233995a618bdSEinar Rünkaru /* Port D: unused */ 234095a618bdSEinar Rünkaru {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 234195a618bdSEinar Rünkaru 234295a618bdSEinar Rünkaru /* Port E: unused, but has primary EAPD */ 234395a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 234495a618bdSEinar Rünkaru {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 234595a618bdSEinar Rünkaru 234695a618bdSEinar Rünkaru /* Port F: unused */ 234795a618bdSEinar Rünkaru {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 234895a618bdSEinar Rünkaru 234995a618bdSEinar Rünkaru /* Port G: internal speakers */ 235095a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 235195a618bdSEinar Rünkaru {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 235295a618bdSEinar Rünkaru 235395a618bdSEinar Rünkaru /* DAC1 */ 235495a618bdSEinar Rünkaru {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 235595a618bdSEinar Rünkaru 235695a618bdSEinar Rünkaru /* DAC2: unused */ 235795a618bdSEinar Rünkaru {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 235895a618bdSEinar Rünkaru 235995a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 236095a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 236195a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 236295a618bdSEinar Rünkaru {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 236395a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 236495a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 236595a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 236695a618bdSEinar Rünkaru {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 236795a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 236895a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 236995a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 237095a618bdSEinar Rünkaru {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 237195a618bdSEinar Rünkaru 237295a618bdSEinar Rünkaru /* Digital microphone port */ 237395a618bdSEinar Rünkaru {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 237495a618bdSEinar Rünkaru 237595a618bdSEinar Rünkaru /* Audio input selectors */ 237695a618bdSEinar Rünkaru {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, 237795a618bdSEinar Rünkaru {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 237895a618bdSEinar Rünkaru 237995a618bdSEinar Rünkaru /* Disable SPDIF */ 238095a618bdSEinar Rünkaru {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 238195a618bdSEinar Rünkaru {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 238295a618bdSEinar Rünkaru 238395a618bdSEinar Rünkaru /* enable unsolicited events for Port A and B */ 238495a618bdSEinar Rünkaru {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 238595a618bdSEinar Rünkaru {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 238695a618bdSEinar Rünkaru { } /* end */ 238795a618bdSEinar Rünkaru }; 238895a618bdSEinar Rünkaru 238934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_ideapad[] = { 2390cfd3d8dcSGreg Alexander {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ 2391cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ 2392cfd3d8dcSGreg Alexander {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 2393cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 2394cfd3d8dcSGreg Alexander 2395cfd3d8dcSGreg Alexander /* Speakers */ 2396cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2397cfd3d8dcSGreg Alexander {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2398cfd3d8dcSGreg Alexander 2399cfd3d8dcSGreg Alexander /* HP, Amp */ 2400cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2401cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2402cfd3d8dcSGreg Alexander 2403cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2404cfd3d8dcSGreg Alexander {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2405cfd3d8dcSGreg Alexander 2406cfd3d8dcSGreg Alexander /* DAC1 */ 2407cfd3d8dcSGreg Alexander {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2408cfd3d8dcSGreg Alexander 2409cfd3d8dcSGreg Alexander /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 2410cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 2411cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2412cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 2413cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 2414cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2415cfd3d8dcSGreg Alexander {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 2416cfd3d8dcSGreg Alexander 2417cfd3d8dcSGreg Alexander /* Audio input selector */ 2418cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 2419cfd3d8dcSGreg Alexander {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 2420cfd3d8dcSGreg Alexander 2421cfd3d8dcSGreg Alexander /* SPDIF route: PCM */ 2422cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 2423cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 2424cfd3d8dcSGreg Alexander 2425cfd3d8dcSGreg Alexander {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2426cfd3d8dcSGreg Alexander {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2427cfd3d8dcSGreg Alexander 2428cfd3d8dcSGreg Alexander /* internal microphone */ 242928c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 2430cfd3d8dcSGreg Alexander 2431cfd3d8dcSGreg Alexander /* EAPD */ 2432cfd3d8dcSGreg Alexander {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2433cfd3d8dcSGreg Alexander 2434cfd3d8dcSGreg Alexander {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2435cfd3d8dcSGreg Alexander {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2436cfd3d8dcSGreg Alexander { } /* end */ 2437cfd3d8dcSGreg Alexander }; 2438cfd3d8dcSGreg Alexander 243934cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_thinkpad[] = { 24407b2bfdbcSJens Taprogge {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ 24417b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ 24427b2bfdbcSJens Taprogge 24437b2bfdbcSJens Taprogge /* Port G: internal speakers */ 24447b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 24457b2bfdbcSJens Taprogge {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 24467b2bfdbcSJens Taprogge 24477b2bfdbcSJens Taprogge /* Port A: HP, Amp */ 24487b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 24497b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 24507b2bfdbcSJens Taprogge 24517b2bfdbcSJens Taprogge /* Port B: Mic Dock */ 24527b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 24537b2bfdbcSJens Taprogge 24547b2bfdbcSJens Taprogge /* Port C: Mic */ 24557b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 24567b2bfdbcSJens Taprogge 24577b2bfdbcSJens Taprogge /* Port D: HP Dock, Amp */ 24587b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 24597b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 24607b2bfdbcSJens Taprogge 24617b2bfdbcSJens Taprogge /* DAC1 */ 24627b2bfdbcSJens Taprogge {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 24637b2bfdbcSJens Taprogge 24647b2bfdbcSJens Taprogge /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ 24657b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, 24667b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 24677b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, 24687b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 24697b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 24707b2bfdbcSJens Taprogge {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ 24717b2bfdbcSJens Taprogge 24727b2bfdbcSJens Taprogge /* Audio input selector */ 24737b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, 24747b2bfdbcSJens Taprogge {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ 24757b2bfdbcSJens Taprogge 24767b2bfdbcSJens Taprogge /* SPDIF route: PCM */ 24777b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, 24787b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, 24797b2bfdbcSJens Taprogge 24807b2bfdbcSJens Taprogge {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 24817b2bfdbcSJens Taprogge {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 24827b2bfdbcSJens Taprogge 24837b2bfdbcSJens Taprogge /* internal microphone */ 248428c4edb7SDavid Henningsson {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable internal mic */ 24857b2bfdbcSJens Taprogge 24867b2bfdbcSJens Taprogge /* EAPD */ 24877b2bfdbcSJens Taprogge {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 24887b2bfdbcSJens Taprogge 24897b2bfdbcSJens Taprogge /* enable unsolicited events for Port A, B, C and D */ 24907b2bfdbcSJens Taprogge {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 24917b2bfdbcSJens Taprogge {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 24927b2bfdbcSJens Taprogge {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 24937b2bfdbcSJens Taprogge {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 24947b2bfdbcSJens Taprogge { } /* end */ 24957b2bfdbcSJens Taprogge }; 24967b2bfdbcSJens Taprogge 249734cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_portd_lo[] = { 24980fb67e98SDaniel Drake {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 24990fb67e98SDaniel Drake { } /* end */ 25000fb67e98SDaniel Drake }; 25010fb67e98SDaniel Drake 2502048e78a5SDavid Henningsson 250334cbe3a6STakashi Iwai static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = { 2504048e78a5SDavid Henningsson {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, 2505048e78a5SDavid Henningsson {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 2506048e78a5SDavid Henningsson {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 2507048e78a5SDavid Henningsson { } /* end */ 2508048e78a5SDavid Henningsson }; 2509048e78a5SDavid Henningsson 25100fb67e98SDaniel Drake /* initialize jack-sensing, too */ 25110fb67e98SDaniel Drake static int cxt5066_init(struct hda_codec *codec) 25120fb67e98SDaniel Drake { 25130fb67e98SDaniel Drake snd_printdd("CXT5066: init\n"); 25140fb67e98SDaniel Drake conexant_init(codec); 25150fb67e98SDaniel Drake if (codec->patch_ops.unsol_event) { 25160fb67e98SDaniel Drake cxt5066_hp_automute(codec); 251702b6b5b6SDavid Henningsson cxt5066_automic(codec); 25180fb67e98SDaniel Drake } 2519c4cfe66cSDaniel Drake cxt5066_set_mic_boost(codec); 25200fb67e98SDaniel Drake return 0; 25210fb67e98SDaniel Drake } 25220fb67e98SDaniel Drake 25230fb67e98SDaniel Drake enum { 25240fb67e98SDaniel Drake CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 25250fb67e98SDaniel Drake CXT5066_DELL_LAPTOP, /* Dell Laptop */ 25261feba3b7SDavid Henningsson CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2527cfd3d8dcSGreg Alexander CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 25287b2bfdbcSJens Taprogge CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2529a1d6906eSDavid Henningsson CXT5066_ASUS, /* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */ 2530048e78a5SDavid Henningsson CXT5066_HP_LAPTOP, /* HP Laptop */ 2531fea4a4f9STakashi Iwai CXT5066_AUTO, /* BIOS auto-parser */ 25320fb67e98SDaniel Drake CXT5066_MODELS 25330fb67e98SDaniel Drake }; 25340fb67e98SDaniel Drake 2535ea734963STakashi Iwai static const char * const cxt5066_models[CXT5066_MODELS] = { 25360fb67e98SDaniel Drake [CXT5066_LAPTOP] = "laptop", 25370fb67e98SDaniel Drake [CXT5066_DELL_LAPTOP] = "dell-laptop", 25381feba3b7SDavid Henningsson [CXT5066_DELL_VOSTRO] = "dell-vostro", 2539cfd3d8dcSGreg Alexander [CXT5066_IDEAPAD] = "ideapad", 25407b2bfdbcSJens Taprogge [CXT5066_THINKPAD] = "thinkpad", 2541a1d6906eSDavid Henningsson [CXT5066_ASUS] = "asus", 2542048e78a5SDavid Henningsson [CXT5066_HP_LAPTOP] = "hp-laptop", 2543fea4a4f9STakashi Iwai [CXT5066_AUTO] = "auto", 25440fb67e98SDaniel Drake }; 25450fb67e98SDaniel Drake 254634cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { 254700cd0bb7STakashi Iwai SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 25481feba3b7SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 25498a96b1e0SDavid Henningsson SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), 2550ca6cd851SDaniel T Chen SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2551231f50bcSAnisse Astier SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2552ebbd224cSDavid Henningsson SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2553048e78a5SDavid Henningsson SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2554f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2555a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2556f6a2491cSAndy Robinson SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 25572ca9cac9SAnisse Astier SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 25585637edb2SDavid Henningsson SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 25595637edb2SDavid Henningsson CXT5066_LAPTOP), 25604d155641STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2561ef61d4e6SManoj Iyer SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 256219593875SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 2563d2859fd4SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS), 2564a1d6906eSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS), 25650fb67e98SDaniel Drake {} 25660fb67e98SDaniel Drake }; 25670fb67e98SDaniel Drake 25680fb67e98SDaniel Drake static int patch_cxt5066(struct hda_codec *codec) 25690fb67e98SDaniel Drake { 25700fb67e98SDaniel Drake struct conexant_spec *spec; 25710fb67e98SDaniel Drake int board_config; 25720fb67e98SDaniel Drake 2573fea4a4f9STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, 2574fea4a4f9STakashi Iwai cxt5066_models, cxt5066_cfg_tbl); 2575fea4a4f9STakashi Iwai if (board_config < 0) 2576c82693dbSTakashi Iwai board_config = CXT5066_AUTO; /* model=auto as default */ 2577fea4a4f9STakashi Iwai if (board_config == CXT5066_AUTO) 2578fea4a4f9STakashi Iwai return patch_conexant_auto(codec); 2579fea4a4f9STakashi Iwai 25800fb67e98SDaniel Drake spec = kzalloc(sizeof(*spec), GFP_KERNEL); 25810fb67e98SDaniel Drake if (!spec) 25820fb67e98SDaniel Drake return -ENOMEM; 25830fb67e98SDaniel Drake codec->spec = spec; 25840fb67e98SDaniel Drake 25850fb67e98SDaniel Drake codec->patch_ops = conexant_patch_ops; 258675f8991dSDaniel Drake codec->patch_ops.init = conexant_init; 25870fb67e98SDaniel Drake 25880fb67e98SDaniel Drake spec->dell_automute = 0; 25890fb67e98SDaniel Drake spec->multiout.max_channels = 2; 25900fb67e98SDaniel Drake spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); 25910fb67e98SDaniel Drake spec->multiout.dac_nids = cxt5066_dac_nids; 2592f6a2491cSAndy Robinson conexant_check_dig_outs(codec, cxt5066_digout_pin_nids, 2593f6a2491cSAndy Robinson ARRAY_SIZE(cxt5066_digout_pin_nids)); 25940fb67e98SDaniel Drake spec->num_adc_nids = 1; 25950fb67e98SDaniel Drake spec->adc_nids = cxt5066_adc_nids; 25960fb67e98SDaniel Drake spec->capsrc_nids = cxt5066_capsrc_nids; 25970fb67e98SDaniel Drake spec->input_mux = &cxt5066_capture_source; 25980fb67e98SDaniel Drake 25990fb67e98SDaniel Drake spec->port_d_mode = PIN_HP; 26000fb67e98SDaniel Drake 26010fb67e98SDaniel Drake spec->num_init_verbs = 1; 26020fb67e98SDaniel Drake spec->init_verbs[0] = cxt5066_init_verbs; 26030fb67e98SDaniel Drake spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); 26040fb67e98SDaniel Drake spec->channel_mode = cxt5066_modes; 26050fb67e98SDaniel Drake spec->cur_adc = 0; 26060fb67e98SDaniel Drake spec->cur_adc_idx = 0; 26070fb67e98SDaniel Drake 26083507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 26093507e2a8STakashi Iwai 26100fb67e98SDaniel Drake switch (board_config) { 26110fb67e98SDaniel Drake default: 26120fb67e98SDaniel Drake case CXT5066_LAPTOP: 26130fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 26140fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 26150fb67e98SDaniel Drake break; 26160fb67e98SDaniel Drake case CXT5066_DELL_LAPTOP: 26170fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 26180fb67e98SDaniel Drake spec->mixers[spec->num_mixers++] = cxt5066_mixers; 26190fb67e98SDaniel Drake 26200fb67e98SDaniel Drake spec->port_d_mode = PIN_OUT; 26210fb67e98SDaniel Drake spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; 26220fb67e98SDaniel Drake spec->num_init_verbs++; 26230fb67e98SDaniel Drake spec->dell_automute = 1; 26240fb67e98SDaniel Drake break; 2625a1d6906eSDavid Henningsson case CXT5066_ASUS: 2626048e78a5SDavid Henningsson case CXT5066_HP_LAPTOP: 2627048e78a5SDavid Henningsson codec->patch_ops.init = cxt5066_init; 262802b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 2629048e78a5SDavid Henningsson spec->init_verbs[spec->num_init_verbs] = 2630048e78a5SDavid Henningsson cxt5066_init_verbs_hp_laptop; 2631048e78a5SDavid Henningsson spec->num_init_verbs++; 2632a1d6906eSDavid Henningsson spec->hp_laptop = board_config == CXT5066_HP_LAPTOP; 2633a1d6906eSDavid Henningsson spec->asus = board_config == CXT5066_ASUS; 2634048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 2635048e78a5SDavid Henningsson spec->mixers[spec->num_mixers++] = cxt5066_mixers; 2636048e78a5SDavid Henningsson /* no S/PDIF out */ 2637f6a2491cSAndy Robinson if (board_config == CXT5066_HP_LAPTOP) 2638048e78a5SDavid Henningsson spec->multiout.dig_out_nid = 0; 2639048e78a5SDavid Henningsson /* input source automatically selected */ 2640048e78a5SDavid Henningsson spec->input_mux = NULL; 2641048e78a5SDavid Henningsson spec->port_d_mode = 0; 2642048e78a5SDavid Henningsson spec->mic_boost = 3; /* default 30dB gain */ 2643048e78a5SDavid Henningsson break; 2644048e78a5SDavid Henningsson 26451feba3b7SDavid Henningsson case CXT5066_DELL_VOSTRO: 264675f8991dSDaniel Drake codec->patch_ops.init = cxt5066_init; 264702b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 264895a618bdSEinar Rünkaru spec->init_verbs[0] = cxt5066_init_verbs_vostro; 26493a00c660STakashi Iwai spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 265095a618bdSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_mixers; 2651254bba6aSEinar Rünkaru spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 265295a618bdSEinar Rünkaru spec->port_d_mode = 0; 2653254bba6aSEinar Rünkaru spec->dell_vostro = 1; 2654c4cfe66cSDaniel Drake spec->mic_boost = 3; /* default 30dB gain */ 265595a618bdSEinar Rünkaru 265695a618bdSEinar Rünkaru /* no S/PDIF out */ 265795a618bdSEinar Rünkaru spec->multiout.dig_out_nid = 0; 265895a618bdSEinar Rünkaru 265995a618bdSEinar Rünkaru /* input source automatically selected */ 266095a618bdSEinar Rünkaru spec->input_mux = NULL; 266195a618bdSEinar Rünkaru break; 2662cfd3d8dcSGreg Alexander case CXT5066_IDEAPAD: 2663cfd3d8dcSGreg Alexander codec->patch_ops.init = cxt5066_init; 266402b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 2665cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 2666cfd3d8dcSGreg Alexander spec->mixers[spec->num_mixers++] = cxt5066_mixers; 2667cfd3d8dcSGreg Alexander spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 2668cfd3d8dcSGreg Alexander spec->port_d_mode = 0; 2669cfd3d8dcSGreg Alexander spec->ideapad = 1; 2670cfd3d8dcSGreg Alexander spec->mic_boost = 2; /* default 20dB gain */ 2671cfd3d8dcSGreg Alexander 2672cfd3d8dcSGreg Alexander /* no S/PDIF out */ 2673cfd3d8dcSGreg Alexander spec->multiout.dig_out_nid = 0; 2674cfd3d8dcSGreg Alexander 2675cfd3d8dcSGreg Alexander /* input source automatically selected */ 2676cfd3d8dcSGreg Alexander spec->input_mux = NULL; 2677cfd3d8dcSGreg Alexander break; 26787b2bfdbcSJens Taprogge case CXT5066_THINKPAD: 26797b2bfdbcSJens Taprogge codec->patch_ops.init = cxt5066_init; 268002b6b5b6SDavid Henningsson codec->patch_ops.unsol_event = cxt5066_unsol_event; 26817b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 26827b2bfdbcSJens Taprogge spec->mixers[spec->num_mixers++] = cxt5066_mixers; 26837b2bfdbcSJens Taprogge spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 26847b2bfdbcSJens Taprogge spec->thinkpad = 1; 26857b2bfdbcSJens Taprogge spec->port_d_mode = PIN_OUT; 26867b2bfdbcSJens Taprogge spec->mic_boost = 2; /* default 20dB gain */ 26877b2bfdbcSJens Taprogge 26887b2bfdbcSJens Taprogge /* no S/PDIF out */ 26897b2bfdbcSJens Taprogge spec->multiout.dig_out_nid = 0; 26907b2bfdbcSJens Taprogge 26917b2bfdbcSJens Taprogge /* input source automatically selected */ 26927b2bfdbcSJens Taprogge spec->input_mux = NULL; 26937b2bfdbcSJens Taprogge break; 26940fb67e98SDaniel Drake } 26950fb67e98SDaniel Drake 26963507e2a8STakashi Iwai if (spec->beep_amp) 2697a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 26983507e2a8STakashi Iwai 26990fb67e98SDaniel Drake return 0; 27000fb67e98SDaniel Drake } 2701461e2c78STakashi Iwai 2702bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 2703bf92d1d5STakashi Iwai 2704bf92d1d5STakashi Iwai 2705461e2c78STakashi Iwai /* 2706f2e5731dSTakashi Iwai * Automatic parser for CX20641 & co 2707f2e5731dSTakashi Iwai */ 2708f2e5731dSTakashi Iwai 2709f2e5731dSTakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 2710f2e5731dSTakashi Iwai static void cx_auto_parse_beep(struct hda_codec *codec) 2711f2e5731dSTakashi Iwai { 2712f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 2713f2e5731dSTakashi Iwai hda_nid_t nid, end_nid; 2714f2e5731dSTakashi Iwai 2715f2e5731dSTakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 2716f2e5731dSTakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) 2717f2e5731dSTakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { 2718f2e5731dSTakashi Iwai set_beep_amp(spec, nid, 0, HDA_OUTPUT); 2719f2e5731dSTakashi Iwai break; 2720f2e5731dSTakashi Iwai } 2721f2e5731dSTakashi Iwai } 2722f2e5731dSTakashi Iwai #else 2723f2e5731dSTakashi Iwai #define cx_auto_parse_beep(codec) 2724f2e5731dSTakashi Iwai #endif 2725f2e5731dSTakashi Iwai 2726254f2968STakashi Iwai /* parse EAPDs */ 272719110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 272819110595STakashi Iwai { 272919110595STakashi Iwai struct conexant_spec *spec = codec->spec; 273019110595STakashi Iwai hda_nid_t nid, end_nid; 273119110595STakashi Iwai 273219110595STakashi Iwai end_nid = codec->start_nid + codec->num_nodes; 273319110595STakashi Iwai for (nid = codec->start_nid; nid < end_nid; nid++) { 273419110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 273519110595STakashi Iwai continue; 273619110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 273719110595STakashi Iwai continue; 273819110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 273919110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 274019110595STakashi Iwai break; 274119110595STakashi Iwai } 2742254f2968STakashi Iwai 2743254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 2744254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 2745254f2968STakashi Iwai * pins, and we can control EAPD per pin. 2746254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 2747254f2968STakashi Iwai * thus it might control over all pins. 2748254f2968STakashi Iwai */ 2749aed523f1STakashi Iwai if (spec->num_eapds > 2) 2750ff359b14STakashi Iwai spec->dynamic_eapd = 1; 2751f2e5731dSTakashi Iwai } 2752f2e5731dSTakashi Iwai 2753da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 2754da339866STakashi Iwai hda_nid_t *pins, bool on) 2755f2e5731dSTakashi Iwai { 2756f2e5731dSTakashi Iwai int i; 2757f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 2758f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 2759f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 2760da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 2761da339866STakashi Iwai on ? 0x02 : 0); 2762f2e5731dSTakashi Iwai } 2763f2e5731dSTakashi Iwai } 2764f2e5731dSTakashi Iwai 2765527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 2766527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 2767527c73baSTakashi Iwai { 2768527c73baSTakashi Iwai struct hda_codec *codec = private_data; 2769527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 2770527c73baSTakashi Iwai 2771527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 2772527c73baSTakashi Iwai } 2773527c73baSTakashi Iwai 2774f2e5731dSTakashi Iwai static int cx_auto_build_controls(struct hda_codec *codec) 2775f2e5731dSTakashi Iwai { 2776f2e5731dSTakashi Iwai int err; 2777f2e5731dSTakashi Iwai 2778aed523f1STakashi Iwai err = snd_hda_gen_build_controls(codec); 2779f2e5731dSTakashi Iwai if (err < 0) 2780f2e5731dSTakashi Iwai return err; 2781f2e5731dSTakashi Iwai 2782aed523f1STakashi Iwai err = add_beep_ctls(codec); 2783aed523f1STakashi Iwai if (err < 0) 2784aed523f1STakashi Iwai return err; 278522ce5f74STakashi Iwai 278622ce5f74STakashi Iwai return 0; 278722ce5f74STakashi Iwai } 278822ce5f74STakashi Iwai 2789ff359b14STakashi Iwai static int cx_auto_init(struct hda_codec *codec) 2790ff359b14STakashi Iwai { 2791ff359b14STakashi Iwai struct conexant_spec *spec = codec->spec; 2792ff359b14STakashi Iwai snd_hda_gen_init(codec); 2793ff359b14STakashi Iwai if (!spec->dynamic_eapd) 2794ff359b14STakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); 2795e4c3bce2SDavid Henningsson 2796e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); 2797e4c3bce2SDavid Henningsson 2798ff359b14STakashi Iwai return 0; 2799ff359b14STakashi Iwai } 2800ff359b14STakashi Iwai 280108cf680cSDavid Henningsson static void cx_auto_free(struct hda_codec *codec) 280208cf680cSDavid Henningsson { 280308cf680cSDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); 280408cf680cSDavid Henningsson snd_hda_gen_free(codec); 280508cf680cSDavid Henningsson } 280608cf680cSDavid Henningsson 280734cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 2808f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 2809aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 2810ff359b14STakashi Iwai .init = cx_auto_init, 281108cf680cSDavid Henningsson .free = cx_auto_free, 281229adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 2813164a7adaSTakashi Iwai #ifdef CONFIG_PM 2814164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 2815164a7adaSTakashi Iwai #endif 2816f2e5731dSTakashi Iwai }; 2817f2e5731dSTakashi Iwai 2818e92d4b08STakashi Iwai /* 2819e92d4b08STakashi Iwai * pin fix-up 2820e92d4b08STakashi Iwai */ 282118dcd304SDavid Henningsson enum { 282218dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 2823d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 2824239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 2825239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 282618dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 2827239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 2828e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC_PIN, 2829e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC, 28304a437044STakashi Iwai CXT_FIXUP_GPIO1, 283108cf680cSDavid Henningsson CXT_FIXUP_THINKPAD_ACPI, 28323a00c660STakashi Iwai CXT_FIXUP_OLPC_XO, 2833ad7725d3STakashi Iwai CXT_FIXUP_CAP_MIX_AMP, 28346dcbadefSTakashi Iwai CXT_FIXUP_TOSHIBA_P105, 2835e5eac90dSTakashi Iwai CXT_FIXUP_HP_530, 2836*ea30e7dfSTakashi Iwai CXT_FIXUP_CAP_MIX_AMP_5047, 283718dcd304SDavid Henningsson }; 283818dcd304SDavid Henningsson 2839b317b032STakashi Iwai /* for hda_fixup_thinkpad_acpi() */ 2840b317b032STakashi Iwai #include "thinkpad_helper.c" 284108cf680cSDavid Henningsson 284223d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 284323d30f28STakashi Iwai const struct hda_fixup *fix, int action) 2844e92d4b08STakashi Iwai { 284518dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 2846aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 2847e92d4b08STakashi Iwai } 2848e92d4b08STakashi Iwai 2849239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 2850239fb862SHuacai Chen const struct hda_fixup *fix, int action) 2851239fb862SHuacai Chen { 2852239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 2853239fb862SHuacai Chen return; 2854239fb862SHuacai Chen 2855239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 2856239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 2857239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 2858239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 2859239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 2860239fb862SHuacai Chen } 2861239fb862SHuacai Chen 2862e4c3bce2SDavid Henningsson static void cxt_update_headset_mode(struct hda_codec *codec) 2863e4c3bce2SDavid Henningsson { 2864e4c3bce2SDavid Henningsson /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ 2865e4c3bce2SDavid Henningsson int i; 2866e4c3bce2SDavid Henningsson bool mic_mode = false; 2867e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 2868e4c3bce2SDavid Henningsson struct auto_pin_cfg *cfg = &spec->gen.autocfg; 2869e4c3bce2SDavid Henningsson 2870e4c3bce2SDavid Henningsson hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; 2871e4c3bce2SDavid Henningsson 2872e4c3bce2SDavid Henningsson for (i = 0; i < cfg->num_inputs; i++) 2873e4c3bce2SDavid Henningsson if (cfg->inputs[i].pin == mux_pin) { 2874e4c3bce2SDavid Henningsson mic_mode = !!cfg->inputs[i].is_headphone_mic; 2875e4c3bce2SDavid Henningsson break; 2876e4c3bce2SDavid Henningsson } 2877e4c3bce2SDavid Henningsson 2878e4c3bce2SDavid Henningsson if (mic_mode) { 2879e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ 2880e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = false; 2881e4c3bce2SDavid Henningsson } else { 2882e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ 2883e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); 2884e4c3bce2SDavid Henningsson } 2885e4c3bce2SDavid Henningsson 2886e4c3bce2SDavid Henningsson snd_hda_gen_update_outputs(codec); 2887e4c3bce2SDavid Henningsson } 2888e4c3bce2SDavid Henningsson 2889e4c3bce2SDavid Henningsson static void cxt_update_headset_mode_hook(struct hda_codec *codec, 2890e4c3bce2SDavid Henningsson struct snd_ctl_elem_value *ucontrol) 2891e4c3bce2SDavid Henningsson { 2892e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 2893e4c3bce2SDavid Henningsson } 2894e4c3bce2SDavid Henningsson 2895e4c3bce2SDavid Henningsson static void cxt_fixup_headphone_mic(struct hda_codec *codec, 2896e4c3bce2SDavid Henningsson const struct hda_fixup *fix, int action) 2897e4c3bce2SDavid Henningsson { 2898e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 2899e4c3bce2SDavid Henningsson 2900e4c3bce2SDavid Henningsson switch (action) { 2901e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PRE_PROBE: 2902e4c3bce2SDavid Henningsson spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; 2903e4c3bce2SDavid Henningsson break; 2904e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PROBE: 2905e4c3bce2SDavid Henningsson spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; 2906e4c3bce2SDavid Henningsson spec->gen.automute_hook = cxt_update_headset_mode; 2907e4c3bce2SDavid Henningsson break; 2908e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_INIT: 2909e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 2910e4c3bce2SDavid Henningsson break; 2911e4c3bce2SDavid Henningsson } 2912e4c3bce2SDavid Henningsson } 2913e4c3bce2SDavid Henningsson 29143a00c660STakashi Iwai /* OPLC XO 1.5 fixup */ 29153a00c660STakashi Iwai 29163a00c660STakashi Iwai /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 29173a00c660STakashi Iwai * through the microphone jack. 29183a00c660STakashi Iwai * When the user enables this through a mixer switch, both internal and 29193a00c660STakashi Iwai * external microphones are disabled. Gain is fixed at 0dB. In this mode, 29203a00c660STakashi Iwai * we also allow the bias to be configured through a separate mixer 29213a00c660STakashi Iwai * control. */ 29223a00c660STakashi Iwai 29233a00c660STakashi Iwai #define update_mic_pin(codec, nid, val) \ 29243a00c660STakashi Iwai snd_hda_codec_update_cache(codec, nid, 0, \ 29253a00c660STakashi Iwai AC_VERB_SET_PIN_WIDGET_CONTROL, val) 29263a00c660STakashi Iwai 29273a00c660STakashi Iwai static const struct hda_input_mux olpc_xo_dc_bias = { 29283a00c660STakashi Iwai .num_items = 3, 29293a00c660STakashi Iwai .items = { 29303a00c660STakashi Iwai { "Off", PIN_IN }, 29313a00c660STakashi Iwai { "50%", PIN_VREF50 }, 29323a00c660STakashi Iwai { "80%", PIN_VREF80 }, 29333a00c660STakashi Iwai }, 29343a00c660STakashi Iwai }; 29353a00c660STakashi Iwai 29363a00c660STakashi Iwai static void olpc_xo_update_mic_boost(struct hda_codec *codec) 29373a00c660STakashi Iwai { 29383a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 29393a00c660STakashi Iwai int ch, val; 29403a00c660STakashi Iwai 29413a00c660STakashi Iwai for (ch = 0; ch < 2; ch++) { 29423a00c660STakashi Iwai val = AC_AMP_SET_OUTPUT | 29433a00c660STakashi Iwai (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT); 29443a00c660STakashi Iwai if (!spec->dc_enable) 29453a00c660STakashi Iwai val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0); 29463a00c660STakashi Iwai snd_hda_codec_write(codec, 0x17, 0, 29473a00c660STakashi Iwai AC_VERB_SET_AMP_GAIN_MUTE, val); 29483a00c660STakashi Iwai } 29493a00c660STakashi Iwai } 29503a00c660STakashi Iwai 29513a00c660STakashi Iwai static void olpc_xo_update_mic_pins(struct hda_codec *codec) 29523a00c660STakashi Iwai { 29533a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 29543a00c660STakashi Iwai int cur_input, val; 29553a00c660STakashi Iwai struct nid_path *path; 29563a00c660STakashi Iwai 29573a00c660STakashi Iwai cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]]; 29583a00c660STakashi Iwai 29593a00c660STakashi Iwai /* Set up mic pins for port-B, C and F dynamically as the recording 29603a00c660STakashi Iwai * LED is turned on/off by these pin controls 29613a00c660STakashi Iwai */ 29623a00c660STakashi Iwai if (!spec->dc_enable) { 29633a00c660STakashi Iwai /* disable DC bias path and pin for port F */ 29643a00c660STakashi Iwai update_mic_pin(codec, 0x1e, 0); 29653a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, false, false); 29663a00c660STakashi Iwai 29673a00c660STakashi Iwai /* update port B (ext mic) and C (int mic) */ 29683a00c660STakashi Iwai /* OLPC defers mic widget control until when capture is 29693a00c660STakashi Iwai * started because the microphone LED comes on as soon as 29703a00c660STakashi Iwai * these settings are put in place. if we did this before 29713a00c660STakashi Iwai * recording, it would give the false indication that 29723a00c660STakashi Iwai * recording is happening when it is not. 29733a00c660STakashi Iwai */ 29743a00c660STakashi Iwai update_mic_pin(codec, 0x1a, spec->recording ? 29753a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1a) : 0); 29763a00c660STakashi Iwai update_mic_pin(codec, 0x1b, spec->recording ? 29773a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1b) : 0); 29783a00c660STakashi Iwai /* enable normal mic path */ 29793a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 29803a00c660STakashi Iwai if (path) 29813a00c660STakashi Iwai snd_hda_activate_path(codec, path, true, false); 29823a00c660STakashi Iwai } else { 29833a00c660STakashi Iwai /* disable normal mic path */ 29843a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 29853a00c660STakashi Iwai if (path) 29863a00c660STakashi Iwai snd_hda_activate_path(codec, path, false, false); 29873a00c660STakashi Iwai 29883a00c660STakashi Iwai /* Even though port F is the DC input, the bias is controlled 29893a00c660STakashi Iwai * on port B. We also leave that port as an active input (but 29903a00c660STakashi Iwai * unselected) in DC mode just in case that is necessary to 29913a00c660STakashi Iwai * make the bias setting take effect. 29923a00c660STakashi Iwai */ 29933a00c660STakashi Iwai if (spec->recording) 29943a00c660STakashi Iwai val = olpc_xo_dc_bias.items[spec->dc_input_bias].index; 29953a00c660STakashi Iwai else 29963a00c660STakashi Iwai val = 0; 29973a00c660STakashi Iwai update_mic_pin(codec, 0x1a, val); 29983a00c660STakashi Iwai update_mic_pin(codec, 0x1b, 0); 29993a00c660STakashi Iwai /* enable DC bias path and pin */ 30003a00c660STakashi Iwai update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0); 30013a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, true, false); 30023a00c660STakashi Iwai } 30033a00c660STakashi Iwai } 30043a00c660STakashi Iwai 30053a00c660STakashi Iwai /* mic_autoswitch hook */ 30063a00c660STakashi Iwai static void olpc_xo_automic(struct hda_codec *codec, struct hda_jack_tbl *jack) 30073a00c660STakashi Iwai { 30083a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30093a00c660STakashi Iwai int saved_cached_write = codec->cached_write; 30103a00c660STakashi Iwai 30113a00c660STakashi Iwai codec->cached_write = 1; 30123a00c660STakashi Iwai /* in DC mode, we don't handle automic */ 30133a00c660STakashi Iwai if (!spec->dc_enable) 30143a00c660STakashi Iwai snd_hda_gen_mic_autoswitch(codec, jack); 30153a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30163a00c660STakashi Iwai snd_hda_codec_flush_cache(codec); 30173a00c660STakashi Iwai codec->cached_write = saved_cached_write; 30183a00c660STakashi Iwai if (spec->dc_enable) 30193a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 30203a00c660STakashi Iwai } 30213a00c660STakashi Iwai 30223a00c660STakashi Iwai /* pcm_capture hook */ 30233a00c660STakashi Iwai static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo, 30243a00c660STakashi Iwai struct hda_codec *codec, 30253a00c660STakashi Iwai struct snd_pcm_substream *substream, 30263a00c660STakashi Iwai int action) 30273a00c660STakashi Iwai { 30283a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30293a00c660STakashi Iwai 30303a00c660STakashi Iwai /* toggle spec->recording flag and update mic pins accordingly 30313a00c660STakashi Iwai * for turning on/off LED 30323a00c660STakashi Iwai */ 30333a00c660STakashi Iwai switch (action) { 30343a00c660STakashi Iwai case HDA_GEN_PCM_ACT_PREPARE: 30353a00c660STakashi Iwai spec->recording = 1; 30363a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30373a00c660STakashi Iwai break; 30383a00c660STakashi Iwai case HDA_GEN_PCM_ACT_CLEANUP: 30393a00c660STakashi Iwai spec->recording = 0; 30403a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30413a00c660STakashi Iwai break; 30423a00c660STakashi Iwai } 30433a00c660STakashi Iwai } 30443a00c660STakashi Iwai 30453a00c660STakashi Iwai static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol, 30463a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30473a00c660STakashi Iwai { 30483a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30493a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30503a00c660STakashi Iwai ucontrol->value.integer.value[0] = spec->dc_enable; 30513a00c660STakashi Iwai return 0; 30523a00c660STakashi Iwai } 30533a00c660STakashi Iwai 30543a00c660STakashi Iwai static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol, 30553a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30563a00c660STakashi Iwai { 30573a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30583a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30593a00c660STakashi Iwai int dc_enable = !!ucontrol->value.integer.value[0]; 30603a00c660STakashi Iwai 30613a00c660STakashi Iwai if (dc_enable == spec->dc_enable) 30623a00c660STakashi Iwai return 0; 30633a00c660STakashi Iwai 30643a00c660STakashi Iwai spec->dc_enable = dc_enable; 30653a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30663a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 30673a00c660STakashi Iwai return 1; 30683a00c660STakashi Iwai } 30693a00c660STakashi Iwai 30703a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 30713a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30723a00c660STakashi Iwai { 30733a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30743a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30753a00c660STakashi Iwai ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 30763a00c660STakashi Iwai return 0; 30773a00c660STakashi Iwai } 30783a00c660STakashi Iwai 30793a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 30803a00c660STakashi Iwai struct snd_ctl_elem_info *uinfo) 30813a00c660STakashi Iwai { 30823a00c660STakashi Iwai return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo); 30833a00c660STakashi Iwai } 30843a00c660STakashi Iwai 30853a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 30863a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30873a00c660STakashi Iwai { 30883a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30893a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30903a00c660STakashi Iwai const struct hda_input_mux *imux = &olpc_xo_dc_bias; 30913a00c660STakashi Iwai unsigned int idx; 30923a00c660STakashi Iwai 30933a00c660STakashi Iwai idx = ucontrol->value.enumerated.item[0]; 30943a00c660STakashi Iwai if (idx >= imux->num_items) 30953a00c660STakashi Iwai idx = imux->num_items - 1; 30963a00c660STakashi Iwai if (spec->dc_input_bias == idx) 30973a00c660STakashi Iwai return 0; 30983a00c660STakashi Iwai 30993a00c660STakashi Iwai spec->dc_input_bias = idx; 31003a00c660STakashi Iwai if (spec->dc_enable) 31013a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 31023a00c660STakashi Iwai return 1; 31033a00c660STakashi Iwai } 31043a00c660STakashi Iwai 31053a00c660STakashi Iwai static const struct snd_kcontrol_new olpc_xo_mixers[] = { 31063a00c660STakashi Iwai { 31073a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 31083a00c660STakashi Iwai .name = "DC Mode Enable Switch", 31093a00c660STakashi Iwai .info = snd_ctl_boolean_mono_info, 31103a00c660STakashi Iwai .get = olpc_xo_dc_mode_get, 31113a00c660STakashi Iwai .put = olpc_xo_dc_mode_put, 31123a00c660STakashi Iwai }, 31133a00c660STakashi Iwai { 31143a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 31153a00c660STakashi Iwai .name = "DC Input Bias Enum", 31163a00c660STakashi Iwai .info = olpc_xo_dc_bias_enum_info, 31173a00c660STakashi Iwai .get = olpc_xo_dc_bias_enum_get, 31183a00c660STakashi Iwai .put = olpc_xo_dc_bias_enum_put, 31193a00c660STakashi Iwai }, 31203a00c660STakashi Iwai {} 31213a00c660STakashi Iwai }; 31223a00c660STakashi Iwai 31233a00c660STakashi Iwai /* overriding mic boost put callback; update mic boost volume only when 31243a00c660STakashi Iwai * DC mode is disabled 31253a00c660STakashi Iwai */ 31263a00c660STakashi Iwai static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol, 31273a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 31283a00c660STakashi Iwai { 31293a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 31303a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 31313a00c660STakashi Iwai int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); 31323a00c660STakashi Iwai if (ret > 0 && spec->dc_enable) 31333a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 31343a00c660STakashi Iwai return ret; 31353a00c660STakashi Iwai } 31363a00c660STakashi Iwai 31373a00c660STakashi Iwai static void cxt_fixup_olpc_xo(struct hda_codec *codec, 31383a00c660STakashi Iwai const struct hda_fixup *fix, int action) 31393a00c660STakashi Iwai { 31403a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 31413a00c660STakashi Iwai int i; 31423a00c660STakashi Iwai 31433a00c660STakashi Iwai if (action != HDA_FIXUP_ACT_PROBE) 31443a00c660STakashi Iwai return; 31453a00c660STakashi Iwai 31463a00c660STakashi Iwai spec->gen.mic_autoswitch_hook = olpc_xo_automic; 31473a00c660STakashi Iwai spec->gen.pcm_capture_hook = olpc_xo_capture_hook; 31483a00c660STakashi Iwai spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0); 31493a00c660STakashi Iwai 31503a00c660STakashi Iwai snd_hda_add_new_ctls(codec, olpc_xo_mixers); 31513a00c660STakashi Iwai 31523a00c660STakashi Iwai /* OLPC's microphone port is DC coupled for use with external sensors, 31533a00c660STakashi Iwai * therefore we use a 50% mic bias in order to center the input signal 31543a00c660STakashi Iwai * with the DC input range of the codec. 31553a00c660STakashi Iwai */ 31563a00c660STakashi Iwai snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50); 31573a00c660STakashi Iwai 31583a00c660STakashi Iwai /* override mic boost control */ 31593a00c660STakashi Iwai for (i = 0; i < spec->gen.kctls.used; i++) { 31603a00c660STakashi Iwai struct snd_kcontrol_new *kctl = 31613a00c660STakashi Iwai snd_array_elem(&spec->gen.kctls, i); 31623a00c660STakashi Iwai if (!strcmp(kctl->name, "Mic Boost Volume")) { 31633a00c660STakashi Iwai kctl->put = olpc_xo_mic_boost_put; 31643a00c660STakashi Iwai break; 31653a00c660STakashi Iwai } 31663a00c660STakashi Iwai } 31673a00c660STakashi Iwai } 31683a00c660STakashi Iwai 3169ad7725d3STakashi Iwai /* 3170ad7725d3STakashi Iwai * Fix max input level on mixer widget to 0dB 3171ad7725d3STakashi Iwai * (originally it has 0x2b steps with 0dB offset 0x14) 3172ad7725d3STakashi Iwai */ 3173ad7725d3STakashi Iwai static void cxt_fixup_cap_mix_amp(struct hda_codec *codec, 3174ad7725d3STakashi Iwai const struct hda_fixup *fix, int action) 3175ad7725d3STakashi Iwai { 3176ad7725d3STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 3177ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 3178ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3179ad7725d3STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3180ad7725d3STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 3181ad7725d3STakashi Iwai } 3182e4c3bce2SDavid Henningsson 3183*ea30e7dfSTakashi Iwai /* 3184*ea30e7dfSTakashi Iwai * Fix max input level on mixer widget to 0dB 3185*ea30e7dfSTakashi Iwai * (originally it has 0x1e steps with 0 dB offset 0x17) 3186*ea30e7dfSTakashi Iwai */ 3187*ea30e7dfSTakashi Iwai static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec, 3188*ea30e7dfSTakashi Iwai const struct hda_fixup *fix, int action) 3189*ea30e7dfSTakashi Iwai { 3190*ea30e7dfSTakashi Iwai snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 3191*ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 3192*ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3193*ea30e7dfSTakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3194*ea30e7dfSTakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 3195*ea30e7dfSTakashi Iwai } 3196*ea30e7dfSTakashi Iwai 3197d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 319823d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3199e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3200e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3201e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 32023e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3203e92d4b08STakashi Iwai {} 3204e92d4b08STakashi Iwai }; 3205e92d4b08STakashi Iwai 3206d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 320723d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3208d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3209d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3210d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3211d70f3632STakashi Iwai {} 3212e92d4b08STakashi Iwai }; 3213e92d4b08STakashi Iwai 3214239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3215239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3216239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3217239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3218239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3219239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3220239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3221239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3222239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3223239fb862SHuacai Chen {} 3224239fb862SHuacai Chen }; 3225239fb862SHuacai Chen 322623d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 322723d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 322823d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 322923d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 323023d30f28STakashi Iwai }, 323123d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 323223d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 323323d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 323408cf680cSDavid Henningsson .chained = true, 323508cf680cSDavid Henningsson .chain_id = CXT_FIXUP_THINKPAD_ACPI, 323623d30f28STakashi Iwai }, 3237239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3238239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3239239fb862SHuacai Chen .chained = true, 3240239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3241239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3242239fb862SHuacai Chen }, 3243239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3244239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3245239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3246239fb862SHuacai Chen }, 324723d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 324823d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 324923d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 325023d30f28STakashi Iwai }, 3251239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3252239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3253239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3254239fb862SHuacai Chen }, 3255e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC_PIN] = { 3256e4c3bce2SDavid Henningsson .type = HDA_FIXUP_PINS, 3257e4c3bce2SDavid Henningsson .chained = true, 3258e4c3bce2SDavid Henningsson .chain_id = CXT_FIXUP_HEADPHONE_MIC, 3259e4c3bce2SDavid Henningsson .v.pins = (const struct hda_pintbl[]) { 3260e4c3bce2SDavid Henningsson { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ 3261e4c3bce2SDavid Henningsson { } 3262e4c3bce2SDavid Henningsson } 3263e4c3bce2SDavid Henningsson }, 3264e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC] = { 3265e4c3bce2SDavid Henningsson .type = HDA_FIXUP_FUNC, 3266e4c3bce2SDavid Henningsson .v.func = cxt_fixup_headphone_mic, 3267e4c3bce2SDavid Henningsson }, 32684a437044STakashi Iwai [CXT_FIXUP_GPIO1] = { 32694a437044STakashi Iwai .type = HDA_FIXUP_VERBS, 32704a437044STakashi Iwai .v.verbs = (const struct hda_verb[]) { 32714a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, 32724a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, 32734a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, 32744a437044STakashi Iwai { } 32754a437044STakashi Iwai }, 32764a437044STakashi Iwai }, 327708cf680cSDavid Henningsson [CXT_FIXUP_THINKPAD_ACPI] = { 327808cf680cSDavid Henningsson .type = HDA_FIXUP_FUNC, 3279b317b032STakashi Iwai .v.func = hda_fixup_thinkpad_acpi, 328008cf680cSDavid Henningsson }, 32813a00c660STakashi Iwai [CXT_FIXUP_OLPC_XO] = { 32823a00c660STakashi Iwai .type = HDA_FIXUP_FUNC, 32833a00c660STakashi Iwai .v.func = cxt_fixup_olpc_xo, 32843a00c660STakashi Iwai }, 3285ad7725d3STakashi Iwai [CXT_FIXUP_CAP_MIX_AMP] = { 3286ad7725d3STakashi Iwai .type = HDA_FIXUP_FUNC, 3287ad7725d3STakashi Iwai .v.func = cxt_fixup_cap_mix_amp, 3288ad7725d3STakashi Iwai }, 32896dcbadefSTakashi Iwai [CXT_FIXUP_TOSHIBA_P105] = { 32906dcbadefSTakashi Iwai .type = HDA_FIXUP_PINS, 32916dcbadefSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 32926dcbadefSTakashi Iwai { 0x10, 0x961701f0 }, /* speaker/hp */ 32936dcbadefSTakashi Iwai { 0x12, 0x02a1901e }, /* ext mic */ 32946dcbadefSTakashi Iwai { 0x14, 0x95a70110 }, /* int mic */ 32956dcbadefSTakashi Iwai {} 32966dcbadefSTakashi Iwai }, 32976dcbadefSTakashi Iwai }, 3298e5eac90dSTakashi Iwai [CXT_FIXUP_HP_530] = { 3299e5eac90dSTakashi Iwai .type = HDA_FIXUP_PINS, 3300e5eac90dSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 3301e5eac90dSTakashi Iwai { 0x12, 0x90a60160 }, /* int mic */ 3302e5eac90dSTakashi Iwai {} 3303e5eac90dSTakashi Iwai }, 3304e5eac90dSTakashi Iwai .chained = true, 3305e5eac90dSTakashi Iwai .chain_id = CXT_FIXUP_CAP_MIX_AMP, 3306e5eac90dSTakashi Iwai }, 3307*ea30e7dfSTakashi Iwai [CXT_FIXUP_CAP_MIX_AMP_5047] = { 3308*ea30e7dfSTakashi Iwai .type = HDA_FIXUP_FUNC, 3309*ea30e7dfSTakashi Iwai .v.func = cxt_fixup_cap_mix_amp_5047, 3310*ea30e7dfSTakashi Iwai }, 3311ad7725d3STakashi Iwai }; 3312ad7725d3STakashi Iwai 3313ad7725d3STakashi Iwai static const struct snd_pci_quirk cxt5045_fixups[] = { 3314e5eac90dSTakashi Iwai SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530), 33156dcbadefSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105), 3316ad7725d3STakashi Iwai /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 3317ad7725d3STakashi Iwai * really bad sound over 0dB on NID 0x17. 3318ad7725d3STakashi Iwai */ 3319ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP), 3320ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP), 3321ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP), 3322ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP), 3323ad7725d3STakashi Iwai {} 3324ad7725d3STakashi Iwai }; 3325ad7725d3STakashi Iwai 3326ad7725d3STakashi Iwai static const struct hda_model_fixup cxt5045_fixup_models[] = { 3327ad7725d3STakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" }, 33286dcbadefSTakashi Iwai { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" }, 3329e5eac90dSTakashi Iwai { .id = CXT_FIXUP_HP_530, .name = "hp-530" }, 3330ad7725d3STakashi Iwai {} 3331e92d4b08STakashi Iwai }; 3332e92d4b08STakashi Iwai 3333*ea30e7dfSTakashi Iwai static const struct snd_pci_quirk cxt5047_fixups[] = { 3334*ea30e7dfSTakashi Iwai /* HP laptops have really bad sound over 0 dB on NID 0x10. 3335*ea30e7dfSTakashi Iwai */ 3336*ea30e7dfSTakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047), 3337*ea30e7dfSTakashi Iwai {} 3338*ea30e7dfSTakashi Iwai }; 3339*ea30e7dfSTakashi Iwai 3340*ea30e7dfSTakashi Iwai static const struct hda_model_fixup cxt5047_fixup_models[] = { 3341*ea30e7dfSTakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" }, 3342*ea30e7dfSTakashi Iwai {} 3343*ea30e7dfSTakashi Iwai }; 3344*ea30e7dfSTakashi Iwai 3345d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3346e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3347e92d4b08STakashi Iwai {} 3348e92d4b08STakashi Iwai }; 3349e92d4b08STakashi Iwai 3350a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5051_fixup_models[] = { 3351a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" }, 3352a2dd933dSTakashi Iwai {} 3353a2dd933dSTakashi Iwai }; 3354a2dd933dSTakashi Iwai 3355d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 335663a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 33574a437044STakashi Iwai SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), 3358e4c3bce2SDavid Henningsson SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), 33593a00c660STakashi Iwai SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO), 3360d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3361d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3362d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3363d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3364d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 3365a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 336688d57606SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), 336718dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3368e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3369b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 33702fd3f170SHui Wang SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), 3371239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3372239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3373f2e5731dSTakashi Iwai {} 3374f2e5731dSTakashi Iwai }; 3375f2e5731dSTakashi Iwai 3376a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5066_fixup_models[] = { 3377a2dd933dSTakashi Iwai { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" }, 3378a2dd933dSTakashi Iwai { .id = CXT_FIXUP_GPIO1, .name = "gpio1" }, 3379a2dd933dSTakashi Iwai { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" }, 3380a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" }, 3381a2dd933dSTakashi Iwai { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" }, 3382a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" }, 33833a00c660STakashi Iwai { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" }, 3384a2dd933dSTakashi Iwai {} 3385a2dd933dSTakashi Iwai }; 3386a2dd933dSTakashi Iwai 33873868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 33883868137eSTakashi Iwai * can be created (bko#42825) 33893868137eSTakashi Iwai */ 33903868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 33913868137eSTakashi Iwai { 33923868137eSTakashi Iwai static hda_nid_t out_nids[] = { 33933868137eSTakashi Iwai 0x10, 0x11, 0 33943868137eSTakashi Iwai }; 33953868137eSTakashi Iwai hda_nid_t *p; 33963868137eSTakashi Iwai 33973868137eSTakashi Iwai for (p = out_nids; *p; p++) 33983868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 33993868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 34003868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 34013868137eSTakashi Iwai } 34023868137eSTakashi Iwai 3403f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3404f2e5731dSTakashi Iwai { 3405f2e5731dSTakashi Iwai struct conexant_spec *spec; 3406f2e5731dSTakashi Iwai int err; 3407f2e5731dSTakashi Iwai 34081f8458a2STakashi Iwai printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 34091f8458a2STakashi Iwai codec->chip_name); 34101f8458a2STakashi Iwai 3411f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3412f2e5731dSTakashi Iwai if (!spec) 3413f2e5731dSTakashi Iwai return -ENOMEM; 3414aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3415f2e5731dSTakashi Iwai codec->spec = spec; 3416e92d4b08STakashi Iwai 3417aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3418aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3419ff359b14STakashi Iwai spec->gen.own_eapd_ctl = 1; 3420ff359b14STakashi Iwai if (spec->dynamic_eapd) 3421aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3422e92d4b08STakashi Iwai 34236b452142STakashi Iwai switch (codec->vendor_id) { 34246b452142STakashi Iwai case 0x14f15045: 34254f32456eSMichael Karcher codec->single_adc_amp = 1; 3426ad7725d3STakashi Iwai snd_hda_pick_fixup(codec, cxt5045_fixup_models, 3427ad7725d3STakashi Iwai cxt5045_fixups, cxt_fixups); 34286b452142STakashi Iwai break; 3429164a7adaSTakashi Iwai case 0x14f15047: 3430164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 3431164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 3432*ea30e7dfSTakashi Iwai snd_hda_pick_fixup(codec, cxt5047_fixup_models, 3433*ea30e7dfSTakashi Iwai cxt5047_fixups, cxt_fixups); 3434164a7adaSTakashi Iwai break; 34353868137eSTakashi Iwai case 0x14f15051: 34363868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 343751969d62SMichael Karcher codec->pin_amp_workaround = 1; 3438a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5051_fixup_models, 3439a2dd933dSTakashi Iwai cxt5051_fixups, cxt_fixups); 34403868137eSTakashi Iwai break; 344151969d62SMichael Karcher default: 344251969d62SMichael Karcher codec->pin_amp_workaround = 1; 3443a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5066_fixup_models, 3444a2dd933dSTakashi Iwai cxt5066_fixups, cxt_fixups); 344523d30f28STakashi Iwai break; 34466b452142STakashi Iwai } 34476b452142STakashi Iwai 3448f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3449f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3450f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3451f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3452f29735cbSTakashi Iwai * not good to expose it blindly. 3453527c73baSTakashi Iwai */ 3454f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3455f29735cbSTakashi Iwai case 0x103c: 3456aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3457f29735cbSTakashi Iwai break; 3458f29735cbSTakashi Iwai } 3459527c73baSTakashi Iwai 3460aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3461aed523f1STakashi Iwai 3462e4c3bce2SDavid Henningsson err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 3463e4c3bce2SDavid Henningsson spec->parse_flags); 346422ce5f74STakashi Iwai if (err < 0) 3465aed523f1STakashi Iwai goto error; 3466aed523f1STakashi Iwai 3467aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3468aed523f1STakashi Iwai if (err < 0) 3469aed523f1STakashi Iwai goto error; 3470aed523f1STakashi Iwai 3471f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 34724f2864a4STakashi Iwai 34734f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 34744f2864a4STakashi Iwai * which falls into the single-cmd mode. 34754f2864a4STakashi Iwai * Better to make reset, then. 34764f2864a4STakashi Iwai */ 34774f2864a4STakashi Iwai if (!codec->bus->sync_write) { 34784f2864a4STakashi Iwai snd_printd("hda_codec: " 34794f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 34804f2864a4STakashi Iwai codec->bus->sync_write = 1; 34814f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 34824f2864a4STakashi Iwai } 34834f2864a4STakashi Iwai 3484e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 3485e4c3bce2SDavid Henningsson 3486f2e5731dSTakashi Iwai return 0; 3487aed523f1STakashi Iwai 3488aed523f1STakashi Iwai error: 348908cf680cSDavid Henningsson cx_auto_free(codec); 3490aed523f1STakashi Iwai return err; 3491f2e5731dSTakashi Iwai } 3492f2e5731dSTakashi Iwai 3493bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3494bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3495bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3496bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3497bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3498bf92d1d5STakashi Iwai #endif 3499bf92d1d5STakashi Iwai 3500f2e5731dSTakashi Iwai /* 3501461e2c78STakashi Iwai */ 3502461e2c78STakashi Iwai 350334cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 350482f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 350582f30040STobin Davis .patch = patch_cxt5045 }, 350682f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 350782f30040STobin Davis .patch = patch_cxt5047 }, 3508461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3509461e2c78STakashi Iwai .patch = patch_cxt5051 }, 35100fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 35110fb67e98SDaniel Drake .patch = patch_cxt5066 }, 351295a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 351395a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3514850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3515850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 35167b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 35177b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3518f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3519f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 35206da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 35216da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3522f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3523f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3524f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3525f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3526f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3527f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3528f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3529f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3530f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3531f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3532f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3533f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3534f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3535f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3536f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3537f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 35382d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 35392d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35402d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 35412d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35422d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 35432d825fd8STakashi Iwai .patch = patch_conexant_auto }, 354442c364acSTakashi Iwai { .id = 0x14f15113, .name = "CX20755", 354542c364acSTakashi Iwai .patch = patch_conexant_auto }, 354642c364acSTakashi Iwai { .id = 0x14f15114, .name = "CX20756", 354742c364acSTakashi Iwai .patch = patch_conexant_auto }, 354842c364acSTakashi Iwai { .id = 0x14f15115, .name = "CX20757", 354942c364acSTakashi Iwai .patch = patch_conexant_auto }, 35508f42d769STakashi Iwai { .id = 0x14f151d7, .name = "CX20952", 35518f42d769STakashi Iwai .patch = patch_conexant_auto }, 3552c9b443d4STobin Davis {} /* terminator */ 3553c9b443d4STobin Davis }; 35541289e9e8STakashi Iwai 35551289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 35561289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 35571289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 35580fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 355995a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3560850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 35617b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3562f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 35636da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3564f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3565f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3566f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3567f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3568f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3569f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3570f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3571f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 35722d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 35732d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 35742d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 357542c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113"); 357642c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114"); 357742c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115"); 35788f42d769STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f151d7"); 35791289e9e8STakashi Iwai 35801289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 35811289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 35821289e9e8STakashi Iwai 35831289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 35841289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 35851289e9e8STakashi Iwai .owner = THIS_MODULE, 35861289e9e8STakashi Iwai }; 35871289e9e8STakashi Iwai 35881289e9e8STakashi Iwai static int __init patch_conexant_init(void) 35891289e9e8STakashi Iwai { 35901289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 35911289e9e8STakashi Iwai } 35921289e9e8STakashi Iwai 35931289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 35941289e9e8STakashi Iwai { 35951289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 35961289e9e8STakashi Iwai } 35971289e9e8STakashi Iwai 35981289e9e8STakashi Iwai module_init(patch_conexant_init) 35991289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3600