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> 26da155d5bSPaul Gortmaker #include <linux/module.h> 27c9b443d4STobin Davis #include <sound/core.h> 28bc7a166dSUlrich Dangel #include <sound/jack.h> 29bc7a166dSUlrich Dangel 30c9b443d4STobin Davis #include "hda_codec.h" 31c9b443d4STobin Davis #include "hda_local.h" 3223d30f28STakashi Iwai #include "hda_auto_parser.h" 33c0f8faf0SEinar Rünkaru #include "hda_beep.h" 341835a0f9STakashi Iwai #include "hda_jack.h" 35aed523f1STakashi Iwai #include "hda_generic.h" 36c9b443d4STobin Davis 373760bc74STakashi Iwai #undef ENABLE_CXT_STATIC_QUIRKS 38c9b443d4STobin Davis 39c9b443d4STobin Davis #define CXT_PIN_DIR_IN 0x00 40c9b443d4STobin Davis #define CXT_PIN_DIR_OUT 0x01 41c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT 0x02 42c9b443d4STobin Davis #define CXT_PIN_DIR_IN_NOMICBIAS 0x03 43c9b443d4STobin Davis #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04 44c9b443d4STobin Davis 45c9b443d4STobin Davis #define CONEXANT_HP_EVENT 0x37 46c9b443d4STobin Davis #define CONEXANT_MIC_EVENT 0x38 4703697e2aSTakashi Iwai #define CONEXANT_LINE_EVENT 0x39 48c9b443d4STobin Davis 49bc7a166dSUlrich Dangel /* Conexant 5051 specific */ 50c9b443d4STobin Davis 51ecda0cffSTakashi Iwai #define CXT5051_SPDIF_OUT 0x12 52bc7a166dSUlrich Dangel #define CXT5051_PORTB_EVENT 0x38 53bc7a166dSUlrich Dangel #define CXT5051_PORTC_EVENT 0x39 54bc7a166dSUlrich Dangel 55faddaa5dSTakashi Iwai #define AUTO_MIC_PORTB (1 << 1) 56faddaa5dSTakashi Iwai #define AUTO_MIC_PORTC (1 << 2) 57bc7a166dSUlrich Dangel 58c9b443d4STobin Davis struct conexant_spec { 5923d30f28STakashi Iwai struct hda_gen_spec gen; 60c9b443d4STobin Davis 61bf92d1d5STakashi Iwai unsigned int beep_amp; 62bf92d1d5STakashi Iwai 63bf92d1d5STakashi Iwai /* extra EAPD pins */ 64bf92d1d5STakashi Iwai unsigned int num_eapds; 65bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 66ff359b14STakashi Iwai bool dynamic_eapd; 67bf92d1d5STakashi Iwai 68e4c3bce2SDavid Henningsson unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 69e4c3bce2SDavid Henningsson 703a00c660STakashi Iwai /* OPLC XO specific */ 713a00c660STakashi Iwai bool recording; 723a00c660STakashi Iwai bool dc_enable; 733a00c660STakashi Iwai unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */ 743a00c660STakashi Iwai struct nid_path *dc_mode_path; 753a00c660STakashi Iwai 76bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 7734cbe3a6STakashi Iwai const struct snd_kcontrol_new *mixers[5]; 78c9b443d4STobin Davis int num_mixers; 79dd5746a8STakashi Iwai hda_nid_t vmaster_nid; 80c9b443d4STobin Davis 81c9b443d4STobin Davis const struct hda_verb *init_verbs[5]; /* initialization verbs 82c9b443d4STobin Davis * don't forget NULL 83c9b443d4STobin Davis * termination! 84c9b443d4STobin Davis */ 85c9b443d4STobin Davis unsigned int num_init_verbs; 86c9b443d4STobin Davis 87c9b443d4STobin Davis /* playback */ 88c9b443d4STobin Davis struct hda_multi_out multiout; /* playback set-up 89c9b443d4STobin Davis * max_channels, dacs must be set 90c9b443d4STobin Davis * dig_out_nid and hp_nid are optional 91c9b443d4STobin Davis */ 92c9b443d4STobin Davis unsigned int cur_eapd; 9382f30040STobin Davis unsigned int hp_present; 9403697e2aSTakashi Iwai unsigned int line_present; 95faddaa5dSTakashi Iwai unsigned int auto_mic; 96c9b443d4STobin Davis 97c9b443d4STobin Davis /* capture */ 98c9b443d4STobin Davis unsigned int num_adc_nids; 9934cbe3a6STakashi Iwai const hda_nid_t *adc_nids; 100c9b443d4STobin Davis hda_nid_t dig_in_nid; /* digital-in NID; optional */ 101c9b443d4STobin Davis 102461e2c78STakashi Iwai unsigned int cur_adc_idx; 103461e2c78STakashi Iwai hda_nid_t cur_adc; 104461e2c78STakashi Iwai unsigned int cur_adc_stream_tag; 105461e2c78STakashi Iwai unsigned int cur_adc_format; 106461e2c78STakashi Iwai 1076764bcefSTakashi Iwai const struct hda_pcm_stream *capture_stream; 1086764bcefSTakashi Iwai 109c9b443d4STobin Davis /* capture source */ 110c9b443d4STobin Davis const struct hda_input_mux *input_mux; 11134cbe3a6STakashi Iwai const hda_nid_t *capsrc_nids; 112c9b443d4STobin Davis unsigned int cur_mux[3]; 113c9b443d4STobin Davis 114c9b443d4STobin Davis /* channel model */ 115c9b443d4STobin Davis const struct hda_channel_mode *channel_mode; 116c9b443d4STobin Davis int num_channel_mode; 117c9b443d4STobin Davis 118c9b443d4STobin Davis /* PCM information */ 119c9b443d4STobin Davis struct hda_pcm pcm_rec[2]; /* used in build_pcms() */ 120c9b443d4STobin Davis 121c9b443d4STobin Davis unsigned int spdif_route; 122c9b443d4STobin Davis 1230fb67e98SDaniel Drake unsigned int port_d_mode; 124f2e5731dSTakashi Iwai unsigned int dell_automute:1; 125cfd3d8dcSGreg Alexander unsigned int dell_vostro:1; 126cfd3d8dcSGreg Alexander unsigned int ideapad:1; 1277b2bfdbcSJens Taprogge unsigned int thinkpad:1; 128048e78a5SDavid Henningsson unsigned int hp_laptop:1; 129a1d6906eSDavid Henningsson unsigned int asus:1; 1306764bcefSTakashi Iwai 131c4cfe66cSDaniel Drake unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 132bf92d1d5STakashi Iwai #endif /* ENABLE_CXT_STATIC_QUIRKS */ 133c9b443d4STobin Davis }; 134c9b443d4STobin Davis 135bf92d1d5STakashi Iwai 136bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 1377504b6cdSTakashi Iwai static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 1387504b6cdSTakashi Iwai int idx, int dir) 1397504b6cdSTakashi Iwai { 1407504b6cdSTakashi Iwai spec->gen.beep_nid = nid; 1417504b6cdSTakashi Iwai spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 1427504b6cdSTakashi Iwai } 143bf92d1d5STakashi Iwai /* additional beep mixers; the actual parameters are overwritten at build */ 144bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 145bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 146bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 147bf92d1d5STakashi Iwai { } /* end */ 148bf92d1d5STakashi Iwai }; 149bf92d1d5STakashi Iwai 150bf92d1d5STakashi Iwai /* create beep controls if needed */ 151bf92d1d5STakashi Iwai static int add_beep_ctls(struct hda_codec *codec) 152bf92d1d5STakashi Iwai { 153bf92d1d5STakashi Iwai struct conexant_spec *spec = codec->spec; 154bf92d1d5STakashi Iwai int err; 155bf92d1d5STakashi Iwai 156bf92d1d5STakashi Iwai if (spec->beep_amp) { 157bf92d1d5STakashi Iwai const struct snd_kcontrol_new *knew; 158bf92d1d5STakashi Iwai for (knew = cxt_beep_mixer; knew->name; knew++) { 159bf92d1d5STakashi Iwai struct snd_kcontrol *kctl; 160bf92d1d5STakashi Iwai kctl = snd_ctl_new1(knew, codec); 161bf92d1d5STakashi Iwai if (!kctl) 162bf92d1d5STakashi Iwai return -ENOMEM; 163bf92d1d5STakashi Iwai kctl->private_value = spec->beep_amp; 164bf92d1d5STakashi Iwai err = snd_hda_ctl_add(codec, 0, kctl); 165bf92d1d5STakashi Iwai if (err < 0) 166bf92d1d5STakashi Iwai return err; 167bf92d1d5STakashi Iwai } 168bf92d1d5STakashi Iwai } 169bf92d1d5STakashi Iwai return 0; 170bf92d1d5STakashi Iwai } 171bf92d1d5STakashi Iwai #else 172bf92d1d5STakashi Iwai #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 173bf92d1d5STakashi Iwai #define add_beep_ctls(codec) 0 174bf92d1d5STakashi Iwai #endif 175bf92d1d5STakashi Iwai 176bf92d1d5STakashi Iwai 177bf92d1d5STakashi Iwai #ifdef ENABLE_CXT_STATIC_QUIRKS 178c9b443d4STobin Davis static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, 179c9b443d4STobin Davis struct hda_codec *codec, 180c9b443d4STobin Davis struct snd_pcm_substream *substream) 181c9b443d4STobin Davis { 182c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 1839a08160bSTakashi Iwai return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 1849a08160bSTakashi Iwai hinfo); 185c9b443d4STobin Davis } 186c9b443d4STobin Davis 187c9b443d4STobin Davis static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 188c9b443d4STobin Davis struct hda_codec *codec, 189c9b443d4STobin Davis unsigned int stream_tag, 190c9b443d4STobin Davis unsigned int format, 191c9b443d4STobin Davis struct snd_pcm_substream *substream) 192c9b443d4STobin Davis { 193c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 194c9b443d4STobin Davis return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 195c9b443d4STobin Davis stream_tag, 196c9b443d4STobin Davis format, substream); 197c9b443d4STobin Davis } 198c9b443d4STobin Davis 199c9b443d4STobin Davis static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 200c9b443d4STobin Davis struct hda_codec *codec, 201c9b443d4STobin Davis struct snd_pcm_substream *substream) 202c9b443d4STobin Davis { 203c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 204c9b443d4STobin Davis return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 205c9b443d4STobin Davis } 206c9b443d4STobin Davis 207c9b443d4STobin Davis /* 208c9b443d4STobin Davis * Digital out 209c9b443d4STobin Davis */ 210c9b443d4STobin Davis static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 211c9b443d4STobin Davis struct hda_codec *codec, 212c9b443d4STobin Davis struct snd_pcm_substream *substream) 213c9b443d4STobin Davis { 214c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 215c9b443d4STobin Davis return snd_hda_multi_out_dig_open(codec, &spec->multiout); 216c9b443d4STobin Davis } 217c9b443d4STobin Davis 218c9b443d4STobin Davis static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 219c9b443d4STobin Davis struct hda_codec *codec, 220c9b443d4STobin Davis struct snd_pcm_substream *substream) 221c9b443d4STobin Davis { 222c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 223c9b443d4STobin Davis return snd_hda_multi_out_dig_close(codec, &spec->multiout); 224c9b443d4STobin Davis } 225c9b443d4STobin Davis 2266b97eb45STakashi Iwai static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2276b97eb45STakashi Iwai struct hda_codec *codec, 2286b97eb45STakashi Iwai unsigned int stream_tag, 2296b97eb45STakashi Iwai unsigned int format, 2306b97eb45STakashi Iwai struct snd_pcm_substream *substream) 2316b97eb45STakashi Iwai { 2326b97eb45STakashi Iwai struct conexant_spec *spec = codec->spec; 2336b97eb45STakashi Iwai return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2346b97eb45STakashi Iwai stream_tag, 2356b97eb45STakashi Iwai format, substream); 2366b97eb45STakashi Iwai } 2376b97eb45STakashi Iwai 238c9b443d4STobin Davis /* 239c9b443d4STobin Davis * Analog capture 240c9b443d4STobin Davis */ 241c9b443d4STobin Davis static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 242c9b443d4STobin Davis struct hda_codec *codec, 243c9b443d4STobin Davis unsigned int stream_tag, 244c9b443d4STobin Davis unsigned int format, 245c9b443d4STobin Davis struct snd_pcm_substream *substream) 246c9b443d4STobin Davis { 247c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 248c9b443d4STobin Davis snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 249c9b443d4STobin Davis stream_tag, 0, format); 250c9b443d4STobin Davis return 0; 251c9b443d4STobin Davis } 252c9b443d4STobin Davis 253c9b443d4STobin Davis static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 254c9b443d4STobin Davis struct hda_codec *codec, 255c9b443d4STobin Davis struct snd_pcm_substream *substream) 256c9b443d4STobin Davis { 257c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 258888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 259c9b443d4STobin Davis return 0; 260c9b443d4STobin Davis } 261c9b443d4STobin Davis 262c9b443d4STobin Davis 263c9b443d4STobin Davis 26434cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_playback = { 265c9b443d4STobin Davis .substreams = 1, 266c9b443d4STobin Davis .channels_min = 2, 267c9b443d4STobin Davis .channels_max = 2, 268c9b443d4STobin Davis .nid = 0, /* fill later */ 269c9b443d4STobin Davis .ops = { 270c9b443d4STobin Davis .open = conexant_playback_pcm_open, 271c9b443d4STobin Davis .prepare = conexant_playback_pcm_prepare, 272c9b443d4STobin Davis .cleanup = conexant_playback_pcm_cleanup 273c9b443d4STobin Davis }, 274c9b443d4STobin Davis }; 275c9b443d4STobin Davis 27634cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_analog_capture = { 277c9b443d4STobin Davis .substreams = 1, 278c9b443d4STobin Davis .channels_min = 2, 279c9b443d4STobin Davis .channels_max = 2, 280c9b443d4STobin Davis .nid = 0, /* fill later */ 281c9b443d4STobin Davis .ops = { 282c9b443d4STobin Davis .prepare = conexant_capture_pcm_prepare, 283c9b443d4STobin Davis .cleanup = conexant_capture_pcm_cleanup 284c9b443d4STobin Davis }, 285c9b443d4STobin Davis }; 286c9b443d4STobin Davis 287c9b443d4STobin Davis 28834cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_playback = { 289c9b443d4STobin Davis .substreams = 1, 290c9b443d4STobin Davis .channels_min = 2, 291c9b443d4STobin Davis .channels_max = 2, 292c9b443d4STobin Davis .nid = 0, /* fill later */ 293c9b443d4STobin Davis .ops = { 294c9b443d4STobin Davis .open = conexant_dig_playback_pcm_open, 2956b97eb45STakashi Iwai .close = conexant_dig_playback_pcm_close, 2966b97eb45STakashi Iwai .prepare = conexant_dig_playback_pcm_prepare 297c9b443d4STobin Davis }, 298c9b443d4STobin Davis }; 299c9b443d4STobin Davis 30034cbe3a6STakashi Iwai static const struct hda_pcm_stream conexant_pcm_digital_capture = { 301c9b443d4STobin Davis .substreams = 1, 302c9b443d4STobin Davis .channels_min = 2, 303c9b443d4STobin Davis .channels_max = 2, 304c9b443d4STobin Davis /* NID is set in alc_build_pcms */ 305c9b443d4STobin Davis }; 306c9b443d4STobin Davis 307461e2c78STakashi Iwai static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 308461e2c78STakashi Iwai struct hda_codec *codec, 309461e2c78STakashi Iwai unsigned int stream_tag, 310461e2c78STakashi Iwai unsigned int format, 311461e2c78STakashi Iwai struct snd_pcm_substream *substream) 312461e2c78STakashi Iwai { 313461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 314461e2c78STakashi Iwai spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; 315461e2c78STakashi Iwai spec->cur_adc_stream_tag = stream_tag; 316461e2c78STakashi Iwai spec->cur_adc_format = format; 317461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 318461e2c78STakashi Iwai return 0; 319461e2c78STakashi Iwai } 320461e2c78STakashi Iwai 321461e2c78STakashi Iwai static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 322461e2c78STakashi Iwai struct hda_codec *codec, 323461e2c78STakashi Iwai struct snd_pcm_substream *substream) 324461e2c78STakashi Iwai { 325461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 326888afa15STakashi Iwai snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 327461e2c78STakashi Iwai spec->cur_adc = 0; 328461e2c78STakashi Iwai return 0; 329461e2c78STakashi Iwai } 330461e2c78STakashi Iwai 33134cbe3a6STakashi Iwai static const struct hda_pcm_stream cx5051_pcm_analog_capture = { 332461e2c78STakashi Iwai .substreams = 1, 333461e2c78STakashi Iwai .channels_min = 2, 334461e2c78STakashi Iwai .channels_max = 2, 335461e2c78STakashi Iwai .nid = 0, /* fill later */ 336461e2c78STakashi Iwai .ops = { 337461e2c78STakashi Iwai .prepare = cx5051_capture_pcm_prepare, 338461e2c78STakashi Iwai .cleanup = cx5051_capture_pcm_cleanup 339461e2c78STakashi Iwai }, 340461e2c78STakashi Iwai }; 341461e2c78STakashi Iwai 342c9b443d4STobin Davis static int conexant_build_pcms(struct hda_codec *codec) 343c9b443d4STobin Davis { 344c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 345c9b443d4STobin Davis struct hda_pcm *info = spec->pcm_rec; 346c9b443d4STobin Davis 347c9b443d4STobin Davis codec->num_pcms = 1; 348c9b443d4STobin Davis codec->pcm_info = info; 349c9b443d4STobin Davis 350c9b443d4STobin Davis info->name = "CONEXANT Analog"; 351c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback; 352c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 353c9b443d4STobin Davis spec->multiout.max_channels; 354c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 355c9b443d4STobin Davis spec->multiout.dac_nids[0]; 3566764bcefSTakashi Iwai if (spec->capture_stream) 3576764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = *spec->capture_stream; 3586764bcefSTakashi Iwai else { 359461e2c78STakashi Iwai if (codec->vendor_id == 0x14f15051) 360461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 361461e2c78STakashi Iwai cx5051_pcm_analog_capture; 3626764bcefSTakashi Iwai else { 363461e2c78STakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE] = 364461e2c78STakashi Iwai conexant_pcm_analog_capture; 3656764bcefSTakashi Iwai info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 3666764bcefSTakashi Iwai spec->num_adc_nids; 3676764bcefSTakashi Iwai } 3686764bcefSTakashi Iwai } 369c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 370c9b443d4STobin Davis 371c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 372c9b443d4STobin Davis info++; 373c9b443d4STobin Davis codec->num_pcms++; 374c9b443d4STobin Davis info->name = "Conexant Digital"; 3757ba72ba1STakashi Iwai info->pcm_type = HDA_PCM_TYPE_SPDIF; 376c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 377c9b443d4STobin Davis conexant_pcm_digital_playback; 378c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 379c9b443d4STobin Davis spec->multiout.dig_out_nid; 380c9b443d4STobin Davis if (spec->dig_in_nid) { 381c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE] = 382c9b443d4STobin Davis conexant_pcm_digital_capture; 383c9b443d4STobin Davis info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 384c9b443d4STobin Davis spec->dig_in_nid; 385c9b443d4STobin Davis } 386c9b443d4STobin Davis } 387c9b443d4STobin Davis 388c9b443d4STobin Davis return 0; 389c9b443d4STobin Davis } 390c9b443d4STobin Davis 391c9b443d4STobin Davis static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol, 392c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 393c9b443d4STobin Davis { 394c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 395c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 396c9b443d4STobin Davis 397c9b443d4STobin Davis return snd_hda_input_mux_info(spec->input_mux, uinfo); 398c9b443d4STobin Davis } 399c9b443d4STobin Davis 400c9b443d4STobin Davis static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol, 401c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 402c9b443d4STobin Davis { 403c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 404c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 405c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 406c9b443d4STobin Davis 407c9b443d4STobin Davis ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 408c9b443d4STobin Davis return 0; 409c9b443d4STobin Davis } 410c9b443d4STobin Davis 411c9b443d4STobin Davis static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, 412c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 413c9b443d4STobin Davis { 414c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 415c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 416c9b443d4STobin Davis unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 417c9b443d4STobin Davis 418c9b443d4STobin Davis return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 419c9b443d4STobin Davis spec->capsrc_nids[adc_idx], 420c9b443d4STobin Davis &spec->cur_mux[adc_idx]); 421c9b443d4STobin Davis } 422c9b443d4STobin Davis 4234d7fbdbcSTakashi Iwai static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, 4244d7fbdbcSTakashi Iwai unsigned int power_state) 4254d7fbdbcSTakashi Iwai { 4264d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D3) 4274d7fbdbcSTakashi Iwai msleep(100); 4284d7fbdbcSTakashi Iwai snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, 4294d7fbdbcSTakashi Iwai power_state); 4304d7fbdbcSTakashi Iwai /* partial workaround for "azx_get_response timeout" */ 4314d7fbdbcSTakashi Iwai if (power_state == AC_PWRST_D0) 4324d7fbdbcSTakashi Iwai msleep(10); 4339419ab6bSTakashi Iwai snd_hda_codec_set_power_to_all(codec, fg, power_state); 4344d7fbdbcSTakashi Iwai } 4354d7fbdbcSTakashi Iwai 436c9b443d4STobin Davis static int conexant_init(struct hda_codec *codec) 437c9b443d4STobin Davis { 438c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 439c9b443d4STobin Davis int i; 440c9b443d4STobin Davis 441c9b443d4STobin Davis for (i = 0; i < spec->num_init_verbs; i++) 442c9b443d4STobin Davis snd_hda_sequence_write(codec, spec->init_verbs[i]); 443c9b443d4STobin Davis return 0; 444c9b443d4STobin Davis } 445c9b443d4STobin Davis 446c9b443d4STobin Davis static void conexant_free(struct hda_codec *codec) 447c9b443d4STobin Davis { 448ee48df57STakashi Iwai struct conexant_spec *spec = codec->spec; 449c0f8faf0SEinar Rünkaru snd_hda_detach_beep_device(codec); 450ee48df57STakashi Iwai kfree(spec); 451c9b443d4STobin Davis } 452c9b443d4STobin Davis 45334cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt_capture_mixers[] = { 454b880c74aSTakashi Iwai { 455b880c74aSTakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 456b880c74aSTakashi Iwai .name = "Capture Source", 457b880c74aSTakashi Iwai .info = conexant_mux_enum_info, 458b880c74aSTakashi Iwai .get = conexant_mux_enum_get, 459b880c74aSTakashi Iwai .put = conexant_mux_enum_put 460b880c74aSTakashi Iwai }, 461b880c74aSTakashi Iwai {} 462b880c74aSTakashi Iwai }; 463b880c74aSTakashi Iwai 4649322ca54STakashi Iwai static const char * const slave_pfxs[] = { 465f37bc7a8STakashi Iwai "Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE", 466dd5746a8STakashi Iwai NULL 467dd5746a8STakashi Iwai }; 468dd5746a8STakashi Iwai 469c9b443d4STobin Davis static int conexant_build_controls(struct hda_codec *codec) 470c9b443d4STobin Davis { 471c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 472c9b443d4STobin Davis unsigned int i; 473c9b443d4STobin Davis int err; 474c9b443d4STobin Davis 475c9b443d4STobin Davis for (i = 0; i < spec->num_mixers; i++) { 476c9b443d4STobin Davis err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 477c9b443d4STobin Davis if (err < 0) 478c9b443d4STobin Davis return err; 479c9b443d4STobin Davis } 480c9b443d4STobin Davis if (spec->multiout.dig_out_nid) { 481c9b443d4STobin Davis err = snd_hda_create_spdif_out_ctls(codec, 48274b654c9SStephen Warren spec->multiout.dig_out_nid, 483c9b443d4STobin Davis spec->multiout.dig_out_nid); 484c9b443d4STobin Davis if (err < 0) 485c9b443d4STobin Davis return err; 4869a08160bSTakashi Iwai err = snd_hda_create_spdif_share_sw(codec, 4879a08160bSTakashi Iwai &spec->multiout); 4889a08160bSTakashi Iwai if (err < 0) 4899a08160bSTakashi Iwai return err; 4909a08160bSTakashi Iwai spec->multiout.share_spdif = 1; 491c9b443d4STobin Davis } 492c9b443d4STobin Davis if (spec->dig_in_nid) { 493c9b443d4STobin Davis err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 494c9b443d4STobin Davis if (err < 0) 495c9b443d4STobin Davis return err; 496c9b443d4STobin Davis } 497dd5746a8STakashi Iwai 498dd5746a8STakashi Iwai /* if we have no master control, let's create it */ 499dd5746a8STakashi Iwai if (spec->vmaster_nid && 500dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 501dd5746a8STakashi Iwai unsigned int vmaster_tlv[4]; 502dd5746a8STakashi Iwai snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 503dd5746a8STakashi Iwai HDA_OUTPUT, vmaster_tlv); 504dd5746a8STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5059322ca54STakashi Iwai vmaster_tlv, slave_pfxs, 5069322ca54STakashi Iwai "Playback Volume"); 507dd5746a8STakashi Iwai if (err < 0) 508dd5746a8STakashi Iwai return err; 509dd5746a8STakashi Iwai } 510dd5746a8STakashi Iwai if (spec->vmaster_nid && 511dd5746a8STakashi Iwai !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 512aed523f1STakashi Iwai err = snd_hda_add_vmaster(codec, "Master Playback Switch", 5139322ca54STakashi Iwai NULL, slave_pfxs, 514aed523f1STakashi Iwai "Playback Switch"); 515dd5746a8STakashi Iwai if (err < 0) 516dd5746a8STakashi Iwai return err; 517dd5746a8STakashi Iwai } 518dd5746a8STakashi Iwai 519b880c74aSTakashi Iwai if (spec->input_mux) { 520b880c74aSTakashi Iwai err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); 521b880c74aSTakashi Iwai if (err < 0) 522b880c74aSTakashi Iwai return err; 523b880c74aSTakashi Iwai } 524b880c74aSTakashi Iwai 525aed523f1STakashi Iwai err = add_beep_ctls(codec); 5263507e2a8STakashi Iwai if (err < 0) 5273507e2a8STakashi Iwai return err; 5283507e2a8STakashi Iwai 529c9b443d4STobin Davis return 0; 530c9b443d4STobin Davis } 531c9b443d4STobin Davis 53234cbe3a6STakashi Iwai static const struct hda_codec_ops conexant_patch_ops = { 533c9b443d4STobin Davis .build_controls = conexant_build_controls, 534c9b443d4STobin Davis .build_pcms = conexant_build_pcms, 535c9b443d4STobin Davis .init = conexant_init, 536c9b443d4STobin Davis .free = conexant_free, 5374d7fbdbcSTakashi Iwai .set_power_state = conexant_set_power, 538c9b443d4STobin Davis }; 539c9b443d4STobin Davis 5406764bcefSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec); 541c9b443d4STobin Davis /* 542c9b443d4STobin Davis * EAPD control 543c9b443d4STobin Davis * the private value = nid | (invert << 8) 544c9b443d4STobin Davis */ 545c9b443d4STobin Davis 546a5ce8890STakashi Iwai #define cxt_eapd_info snd_ctl_boolean_mono_info 547c9b443d4STobin Davis 54882f30040STobin Davis static int cxt_eapd_get(struct snd_kcontrol *kcontrol, 549c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 550c9b443d4STobin Davis { 551c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 552c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 553c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 554c9b443d4STobin Davis if (invert) 555c9b443d4STobin Davis ucontrol->value.integer.value[0] = !spec->cur_eapd; 556c9b443d4STobin Davis else 557c9b443d4STobin Davis ucontrol->value.integer.value[0] = spec->cur_eapd; 558c9b443d4STobin Davis return 0; 55982f30040STobin Davis 560c9b443d4STobin Davis } 561c9b443d4STobin Davis 56282f30040STobin Davis static int cxt_eapd_put(struct snd_kcontrol *kcontrol, 563c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 564c9b443d4STobin Davis { 565c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 566c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 567c9b443d4STobin Davis int invert = (kcontrol->private_value >> 8) & 1; 568c9b443d4STobin Davis hda_nid_t nid = kcontrol->private_value & 0xff; 569c9b443d4STobin Davis unsigned int eapd; 57082f30040STobin Davis 57168ea7b2fSTakashi Iwai eapd = !!ucontrol->value.integer.value[0]; 572c9b443d4STobin Davis if (invert) 573c9b443d4STobin Davis eapd = !eapd; 57482beb8fdSTakashi Iwai if (eapd == spec->cur_eapd) 575c9b443d4STobin Davis return 0; 57682f30040STobin Davis 577c9b443d4STobin Davis spec->cur_eapd = eapd; 57882beb8fdSTakashi Iwai snd_hda_codec_write_cache(codec, nid, 579c9b443d4STobin Davis 0, AC_VERB_SET_EAPD_BTLENABLE, 580c9b443d4STobin Davis eapd ? 0x02 : 0x00); 581c9b443d4STobin Davis return 1; 582c9b443d4STobin Davis } 583c9b443d4STobin Davis 58486d72bdfSTakashi Iwai /* controls for test mode */ 58586d72bdfSTakashi Iwai #ifdef CONFIG_SND_DEBUG 58686d72bdfSTakashi Iwai 58782f30040STobin Davis #define CXT_EAPD_SWITCH(xname, nid, mask) \ 58882f30040STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 58982f30040STobin Davis .info = cxt_eapd_info, \ 59082f30040STobin Davis .get = cxt_eapd_get, \ 59182f30040STobin Davis .put = cxt_eapd_put, \ 59282f30040STobin Davis .private_value = nid | (mask<<16) } 59382f30040STobin Davis 59482f30040STobin Davis 59582f30040STobin Davis 596c9b443d4STobin Davis static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol, 597c9b443d4STobin Davis struct snd_ctl_elem_info *uinfo) 598c9b443d4STobin Davis { 599c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 600c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 601c9b443d4STobin Davis return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 602c9b443d4STobin Davis spec->num_channel_mode); 603c9b443d4STobin Davis } 604c9b443d4STobin Davis 605c9b443d4STobin Davis static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol, 606c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 607c9b443d4STobin Davis { 608c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 609c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 610c9b443d4STobin Davis return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 611c9b443d4STobin Davis spec->num_channel_mode, 612c9b443d4STobin Davis spec->multiout.max_channels); 613c9b443d4STobin Davis } 614c9b443d4STobin Davis 615c9b443d4STobin Davis static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol, 616c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 617c9b443d4STobin Davis { 618c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 619c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 620c9b443d4STobin Davis int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 621c9b443d4STobin Davis spec->num_channel_mode, 622c9b443d4STobin Davis &spec->multiout.max_channels); 623c9b443d4STobin Davis return err; 624c9b443d4STobin Davis } 625c9b443d4STobin Davis 626c9b443d4STobin Davis #define CXT_PIN_MODE(xname, nid, dir) \ 627c9b443d4STobin Davis { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 628c9b443d4STobin Davis .info = conexant_ch_mode_info, \ 629c9b443d4STobin Davis .get = conexant_ch_mode_get, \ 630c9b443d4STobin Davis .put = conexant_ch_mode_put, \ 631c9b443d4STobin Davis .private_value = nid | (dir<<16) } 632c9b443d4STobin Davis 63386d72bdfSTakashi Iwai #endif /* CONFIG_SND_DEBUG */ 63486d72bdfSTakashi Iwai 635c9b443d4STobin Davis /* Conexant 5045 specific */ 636c9b443d4STobin Davis 63734cbe3a6STakashi Iwai static const hda_nid_t cxt5045_dac_nids[1] = { 0x19 }; 63834cbe3a6STakashi Iwai static const hda_nid_t cxt5045_adc_nids[1] = { 0x1a }; 63934cbe3a6STakashi Iwai static const hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a }; 640cbef9789STakashi Iwai #define CXT5045_SPDIF_OUT 0x18 641c9b443d4STobin Davis 64234cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5045_modes[1] = { 6435cd57529STobin Davis { 2, NULL }, 6445cd57529STobin Davis }; 645c9b443d4STobin Davis 64634cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source = { 647c9b443d4STobin Davis .num_items = 2, 648c9b443d4STobin Davis .items = { 6493edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6503edbbb9eSMichael Karcher { "Mic", 0x2 }, 651c9b443d4STobin Davis } 652c9b443d4STobin Davis }; 653c9b443d4STobin Davis 65434cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_capture_source_benq = { 655e6e03daeSMichael Karcher .num_items = 4, 6565218c892SJiang Zhe .items = { 6573edbbb9eSMichael Karcher { "Internal Mic", 0x1 }, 6583edbbb9eSMichael Karcher { "Mic", 0x2 }, 6593edbbb9eSMichael Karcher { "Line", 0x3 }, 66022e14130SLukasz Marcinowski { "Mixer", 0x0 }, 6615218c892SJiang Zhe } 6625218c892SJiang Zhe }; 6635218c892SJiang Zhe 664c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 665c9b443d4STobin Davis static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 666c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 667c9b443d4STobin Davis { 668c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 669c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 67082f30040STobin Davis unsigned int bits; 671c9b443d4STobin Davis 67282f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 673c9b443d4STobin Davis return 0; 674c9b443d4STobin Davis 67582f30040STobin Davis /* toggle internal speakers mute depending of presence of 67682f30040STobin Davis * the headphone jack 67782f30040STobin Davis */ 67847fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 67947fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 68047fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 6817f29673bSTobin Davis 68247fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 68347fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0, 68447fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 685c9b443d4STobin Davis return 1; 686c9b443d4STobin Davis } 687c9b443d4STobin Davis 688c9b443d4STobin Davis /* bind volumes of both NID 0x10 and 0x11 */ 68934cbe3a6STakashi Iwai static const struct hda_bind_ctls cxt5045_hp_bind_master_vol = { 690cca3b371STakashi Iwai .ops = &snd_hda_bind_vol, 691cca3b371STakashi Iwai .values = { 692cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT), 693cca3b371STakashi Iwai HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), 694cca3b371STakashi Iwai 0 695cca3b371STakashi Iwai }, 696cca3b371STakashi Iwai }; 697c9b443d4STobin Davis 6987f29673bSTobin Davis /* toggle input of built-in and mic jack appropriately */ 6997f29673bSTobin Davis static void cxt5045_hp_automic(struct hda_codec *codec) 7007f29673bSTobin Davis { 70134cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 7027f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7037f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7047f29673bSTobin Davis {} 7057f29673bSTobin Davis }; 70634cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 7077f29673bSTobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 7087f29673bSTobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 7097f29673bSTobin Davis {} 7107f29673bSTobin Davis }; 7117f29673bSTobin Davis unsigned int present; 7127f29673bSTobin Davis 713d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x12); 7147f29673bSTobin Davis if (present) 7157f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_on); 7167f29673bSTobin Davis else 7177f29673bSTobin Davis snd_hda_sequence_write(codec, mic_jack_off); 7187f29673bSTobin Davis } 7197f29673bSTobin Davis 720c9b443d4STobin Davis 721c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 722c9b443d4STobin Davis static void cxt5045_hp_automute(struct hda_codec *codec) 723c9b443d4STobin Davis { 72482f30040STobin Davis struct conexant_spec *spec = codec->spec; 725dd87da1cSTobin Davis unsigned int bits; 726c9b443d4STobin Davis 727d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x11); 728dd87da1cSTobin Davis 72947fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 73047fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0, 73147fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 732c9b443d4STobin Davis } 733c9b443d4STobin Davis 734c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 735c9b443d4STobin Davis static void cxt5045_hp_unsol_event(struct hda_codec *codec, 736c9b443d4STobin Davis unsigned int res) 737c9b443d4STobin Davis { 738c9b443d4STobin Davis res >>= 26; 739c9b443d4STobin Davis switch (res) { 740c9b443d4STobin Davis case CONEXANT_HP_EVENT: 741c9b443d4STobin Davis cxt5045_hp_automute(codec); 742c9b443d4STobin Davis break; 7437f29673bSTobin Davis case CONEXANT_MIC_EVENT: 7447f29673bSTobin Davis cxt5045_hp_automic(codec); 7457f29673bSTobin Davis break; 7467f29673bSTobin Davis 747c9b443d4STobin Davis } 748c9b443d4STobin Davis } 749c9b443d4STobin Davis 75034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_mixers[] = { 751cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT), 752cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 753c8229c38STakashi Iwai HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT), 754c8229c38STakashi Iwai HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT), 75528c4edb7SDavid Henningsson HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x1, HDA_INPUT), 75628c4edb7SDavid Henningsson HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x1, HDA_INPUT), 7578607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x2, HDA_INPUT), 7588607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x2, HDA_INPUT), 759cca3b371STakashi Iwai HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol), 760c9b443d4STobin Davis { 761c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 762c9b443d4STobin Davis .name = "Master Playback Switch", 76382f30040STobin Davis .info = cxt_eapd_info, 76482f30040STobin Davis .get = cxt_eapd_get, 765c9b443d4STobin Davis .put = cxt5045_hp_master_sw_put, 76682f30040STobin Davis .private_value = 0x10, 767c9b443d4STobin Davis }, 768c9b443d4STobin Davis 769c9b443d4STobin Davis {} 770c9b443d4STobin Davis }; 771c9b443d4STobin Davis 77234cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_benq_mixers[] = { 7733edbbb9eSMichael Karcher HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x3, HDA_INPUT), 7743edbbb9eSMichael Karcher HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x3, HDA_INPUT), 77522e14130SLukasz Marcinowski 7765218c892SJiang Zhe {} 7775218c892SJiang Zhe }; 7785218c892SJiang Zhe 77934cbe3a6STakashi Iwai static const struct hda_verb cxt5045_init_verbs[] = { 780c9b443d4STobin Davis /* Line in, Mic */ 7814090dffbSTakashi Iwai {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 7827f29673bSTobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 783c9b443d4STobin Davis /* HP, Amp */ 784c8229c38STakashi Iwai {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 785c8229c38STakashi Iwai {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 78682f30040STobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 787c8229c38STakashi Iwai {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 788c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 789c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 790c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 791c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 792c8229c38STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 79328c4edb7SDavid Henningsson /* Record selector: Internal mic */ 7947f29673bSTobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL,0x1}, 79582f30040STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 796c9b443d4STobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 797c9b443d4STobin Davis /* SPDIF route: PCM */ 798cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 799c9b443d4STobin Davis { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 800c9b443d4STobin Davis /* EAPD */ 80182f30040STobin Davis {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 802c9b443d4STobin Davis { } /* end */ 803c9b443d4STobin Davis }; 804c9b443d4STobin Davis 80534cbe3a6STakashi Iwai static const struct hda_verb cxt5045_benq_init_verbs[] = { 80628c4edb7SDavid Henningsson /* Internal Mic, Mic */ 8075218c892SJiang Zhe {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8085218c892SJiang Zhe {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 8095218c892SJiang Zhe /* Line In,HP, Amp */ 8105218c892SJiang Zhe {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8115218c892SJiang Zhe {0x10, AC_VERB_SET_CONNECT_SEL, 0x1}, 8125218c892SJiang Zhe {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 8135218c892SJiang Zhe {0x11, AC_VERB_SET_CONNECT_SEL, 0x1}, 8145218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8155218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8165218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 8175218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 8185218c892SJiang Zhe {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 81928c4edb7SDavid Henningsson /* Record selector: Internal mic */ 8205218c892SJiang Zhe {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1}, 8215218c892SJiang Zhe {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 8225218c892SJiang Zhe AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 8235218c892SJiang Zhe /* SPDIF route: PCM */ 824cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 8255218c892SJiang Zhe {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 8265218c892SJiang Zhe /* EAPD */ 8275218c892SJiang Zhe {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 8285218c892SJiang Zhe { } /* end */ 8295218c892SJiang Zhe }; 8307f29673bSTobin Davis 83134cbe3a6STakashi Iwai static const struct hda_verb cxt5045_hp_sense_init_verbs[] = { 8327f29673bSTobin Davis /* pin sensing on HP jack */ 8337f29673bSTobin Davis {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 834d3091fadSTakashi Iwai { } /* end */ 8357f29673bSTobin Davis }; 8367f29673bSTobin Davis 83734cbe3a6STakashi Iwai static const struct hda_verb cxt5045_mic_sense_init_verbs[] = { 8387f29673bSTobin Davis /* pin sensing on HP jack */ 8397f29673bSTobin Davis {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 840d3091fadSTakashi Iwai { } /* end */ 8417f29673bSTobin Davis }; 8427f29673bSTobin Davis 843c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 844c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 845c9b443d4STobin Davis * configuration. 846c9b443d4STobin Davis */ 84734cbe3a6STakashi Iwai static const struct hda_input_mux cxt5045_test_capture_source = { 848c9b443d4STobin Davis .num_items = 5, 849c9b443d4STobin Davis .items = { 850c9b443d4STobin Davis { "MIXER", 0x0 }, 851c9b443d4STobin Davis { "MIC1 pin", 0x1 }, 852c9b443d4STobin Davis { "LINE1 pin", 0x2 }, 853c9b443d4STobin Davis { "HP-OUT pin", 0x3 }, 854c9b443d4STobin Davis { "CD pin", 0x4 }, 855c9b443d4STobin Davis }, 856c9b443d4STobin Davis }; 857c9b443d4STobin Davis 85834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5045_test_mixer[] = { 859c9b443d4STobin Davis 860c9b443d4STobin Davis /* Output controls */ 861c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 862c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 863250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT Playback Volume", 0x11, 0x0, HDA_OUTPUT), 864250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT Playback Switch", 0x11, 0x0, HDA_OUTPUT), 865250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x12, 0x0, HDA_OUTPUT), 866250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 Playback Switch", 0x12, 0x0, HDA_OUTPUT), 867c9b443d4STobin Davis 868c9b443d4STobin Davis /* Modes for retasking pin widgets */ 869c9b443d4STobin Davis CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 870c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT), 871c9b443d4STobin Davis 87282f30040STobin Davis /* EAPD Switch Control */ 87382f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 87482f30040STobin Davis 875c9b443d4STobin Davis /* Loopback mixer controls */ 876c9b443d4STobin Davis 877250f3274SMichael Karcher HDA_CODEC_VOLUME("PCM Volume", 0x17, 0x0, HDA_INPUT), 878250f3274SMichael Karcher HDA_CODEC_MUTE("PCM Switch", 0x17, 0x0, HDA_INPUT), 879250f3274SMichael Karcher HDA_CODEC_VOLUME("MIC1 pin Volume", 0x17, 0x1, HDA_INPUT), 880250f3274SMichael Karcher HDA_CODEC_MUTE("MIC1 pin Switch", 0x17, 0x1, HDA_INPUT), 881250f3274SMichael Karcher HDA_CODEC_VOLUME("LINE1 pin Volume", 0x17, 0x2, HDA_INPUT), 882250f3274SMichael Karcher HDA_CODEC_MUTE("LINE1 pin Switch", 0x17, 0x2, HDA_INPUT), 883250f3274SMichael Karcher HDA_CODEC_VOLUME("HP-OUT pin Volume", 0x17, 0x3, HDA_INPUT), 884250f3274SMichael Karcher HDA_CODEC_MUTE("HP-OUT pin Switch", 0x17, 0x3, HDA_INPUT), 885250f3274SMichael Karcher HDA_CODEC_VOLUME("CD pin Volume", 0x17, 0x4, HDA_INPUT), 886250f3274SMichael Karcher HDA_CODEC_MUTE("CD pin Switch", 0x17, 0x4, HDA_INPUT), 887c9b443d4STobin Davis { 888c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 889c9b443d4STobin Davis .name = "Input Source", 890c9b443d4STobin Davis .info = conexant_mux_enum_info, 891c9b443d4STobin Davis .get = conexant_mux_enum_get, 892c9b443d4STobin Davis .put = conexant_mux_enum_put, 893c9b443d4STobin Davis }, 894fb3409e7STobin Davis /* Audio input controls */ 895cbf2d28eSMichael Karcher HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT), 896cbf2d28eSMichael Karcher HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT), 897c9b443d4STobin Davis { } /* end */ 898c9b443d4STobin Davis }; 899c9b443d4STobin Davis 90034cbe3a6STakashi Iwai static const struct hda_verb cxt5045_test_init_verbs[] = { 9017f29673bSTobin Davis /* Set connections */ 9027f29673bSTobin Davis { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9037f29673bSTobin Davis { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 }, 9047f29673bSTobin Davis { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 }, 905c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 906c9b443d4STobin Davis {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9077f29673bSTobin Davis {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 908c9b443d4STobin Davis 909c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 910c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 911c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 912c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 913c9b443d4STobin Davis * control. 914c9b443d4STobin Davis */ 915cbef9789STakashi Iwai {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 916cbef9789STakashi Iwai {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 917c9b443d4STobin Davis 918c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 919c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 920c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 921c9b443d4STobin Davis * input/output buffers as needed. 922c9b443d4STobin Davis */ 923c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 924c9b443d4STobin Davis {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 925c9b443d4STobin Davis 926c9b443d4STobin Davis /* Mute capture amp left and right */ 927c9b443d4STobin Davis {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 928c9b443d4STobin Davis 929c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 930c9b443d4STobin Davis * pin) 931c9b443d4STobin Davis */ 932250f3274SMichael Karcher {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, 933250f3274SMichael Karcher {0x17, AC_VERB_SET_CONNECT_SEL, 0x01}, 934c9b443d4STobin Davis 935c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 936250f3274SMichael Karcher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer */ 937c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */ 938c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */ 939c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */ 940c9b443d4STobin Davis {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 941c9b443d4STobin Davis 942c9b443d4STobin Davis { } 943c9b443d4STobin Davis }; 944c9b443d4STobin Davis #endif 945c9b443d4STobin Davis 946c9b443d4STobin Davis 947c9b443d4STobin Davis /* initialize jack-sensing, too */ 948c9b443d4STobin Davis static int cxt5045_init(struct hda_codec *codec) 949c9b443d4STobin Davis { 950c9b443d4STobin Davis conexant_init(codec); 951c9b443d4STobin Davis cxt5045_hp_automute(codec); 952c9b443d4STobin Davis return 0; 953c9b443d4STobin Davis } 954c9b443d4STobin Davis 955c9b443d4STobin Davis 956c9b443d4STobin Davis enum { 95715908c36SMarc Boucher CXT5045_LAPTOP_HPSENSE, 95815908c36SMarc Boucher CXT5045_LAPTOP_MICSENSE, 95915908c36SMarc Boucher CXT5045_LAPTOP_HPMICSENSE, 9605218c892SJiang Zhe CXT5045_BENQ, 961c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 962c9b443d4STobin Davis CXT5045_TEST, 963c9b443d4STobin Davis #endif 9641f8458a2STakashi Iwai CXT5045_AUTO, 965f5fcc13cSTakashi Iwai CXT5045_MODELS 966c9b443d4STobin Davis }; 967c9b443d4STobin Davis 968ea734963STakashi Iwai static const char * const cxt5045_models[CXT5045_MODELS] = { 96915908c36SMarc Boucher [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense", 97015908c36SMarc Boucher [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 97115908c36SMarc Boucher [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 9725218c892SJiang Zhe [CXT5045_BENQ] = "benq", 973c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 974f5fcc13cSTakashi Iwai [CXT5045_TEST] = "test", 975c9b443d4STobin Davis #endif 9761f8458a2STakashi Iwai [CXT5045_AUTO] = "auto", 977f5fcc13cSTakashi Iwai }; 978c9b443d4STobin Davis 97934cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 9805218c892SJiang Zhe SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 98115908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 98215908c36SMarc Boucher SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 9839e464154STakashi Iwai SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505", 9849e464154STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 98515908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 98615908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 98715908c36SMarc Boucher SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 988dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell", 989dea0a509STakashi Iwai CXT5045_LAPTOP_HPMICSENSE), 99015908c36SMarc Boucher SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 991c9b443d4STobin Davis {} 992c9b443d4STobin Davis }; 993c9b443d4STobin Davis 994c9b443d4STobin Davis static int patch_cxt5045(struct hda_codec *codec) 995c9b443d4STobin Davis { 996c9b443d4STobin Davis struct conexant_spec *spec; 997c9b443d4STobin Davis int board_config; 998c9b443d4STobin Davis 9991f8458a2STakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 10001f8458a2STakashi Iwai cxt5045_models, 10011f8458a2STakashi Iwai cxt5045_cfg_tbl); 10021f8458a2STakashi Iwai if (board_config < 0) 1003c82693dbSTakashi Iwai board_config = CXT5045_AUTO; /* model=auto as default */ 10041f8458a2STakashi Iwai if (board_config == CXT5045_AUTO) 10051f8458a2STakashi Iwai return patch_conexant_auto(codec); 10061f8458a2STakashi Iwai 1007c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1008c9b443d4STobin Davis if (!spec) 1009c9b443d4STobin Davis return -ENOMEM; 1010c9b443d4STobin Davis codec->spec = spec; 10114f32456eSMichael Karcher codec->single_adc_amp = 1; 1012c9b443d4STobin Davis 1013c9b443d4STobin Davis spec->multiout.max_channels = 2; 1014c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1015c9b443d4STobin Davis spec->multiout.dac_nids = cxt5045_dac_nids; 1016c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT; 1017c9b443d4STobin Davis spec->num_adc_nids = 1; 1018c9b443d4STobin Davis spec->adc_nids = cxt5045_adc_nids; 1019c9b443d4STobin Davis spec->capsrc_nids = cxt5045_capsrc_nids; 1020c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1021c9b443d4STobin Davis spec->num_mixers = 1; 1022c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1023c9b443d4STobin Davis spec->num_init_verbs = 1; 1024c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_init_verbs; 1025c9b443d4STobin Davis spec->spdif_route = 0; 10263507e2a8STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); 10273507e2a8STakashi Iwai spec->channel_mode = cxt5045_modes; 10285cd57529STobin Davis 10293507e2a8STakashi Iwai set_beep_amp(spec, 0x16, 0, 1); 1030c9b443d4STobin Davis 1031c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1032c9b443d4STobin Davis 1033c9b443d4STobin Davis switch (board_config) { 103415908c36SMarc Boucher case CXT5045_LAPTOP_HPSENSE: 10357f29673bSTobin Davis codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 1036c9b443d4STobin Davis spec->input_mux = &cxt5045_capture_source; 1037c9b443d4STobin Davis spec->num_init_verbs = 2; 10387f29673bSTobin Davis spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 10397f29673bSTobin Davis spec->mixers[0] = cxt5045_mixers; 10407f29673bSTobin Davis codec->patch_ops.init = cxt5045_init; 10417f29673bSTobin Davis break; 104215908c36SMarc Boucher case CXT5045_LAPTOP_MICSENSE: 104386376df6STakashi Iwai codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10447f29673bSTobin Davis spec->input_mux = &cxt5045_capture_source; 10457f29673bSTobin Davis spec->num_init_verbs = 2; 10467f29673bSTobin Davis spec->init_verbs[1] = cxt5045_mic_sense_init_verbs; 1047c9b443d4STobin Davis spec->mixers[0] = cxt5045_mixers; 1048c9b443d4STobin Davis codec->patch_ops.init = cxt5045_init; 1049c9b443d4STobin Davis break; 105015908c36SMarc Boucher default: 105115908c36SMarc Boucher case CXT5045_LAPTOP_HPMICSENSE: 105215908c36SMarc Boucher codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 105315908c36SMarc Boucher spec->input_mux = &cxt5045_capture_source; 105415908c36SMarc Boucher spec->num_init_verbs = 3; 105515908c36SMarc Boucher spec->init_verbs[1] = cxt5045_hp_sense_init_verbs; 105615908c36SMarc Boucher spec->init_verbs[2] = cxt5045_mic_sense_init_verbs; 105715908c36SMarc Boucher spec->mixers[0] = cxt5045_mixers; 105815908c36SMarc Boucher codec->patch_ops.init = cxt5045_init; 105915908c36SMarc Boucher break; 10605218c892SJiang Zhe case CXT5045_BENQ: 10615218c892SJiang Zhe codec->patch_ops.unsol_event = cxt5045_hp_unsol_event; 10625218c892SJiang Zhe spec->input_mux = &cxt5045_capture_source_benq; 10635218c892SJiang Zhe spec->num_init_verbs = 1; 10645218c892SJiang Zhe spec->init_verbs[0] = cxt5045_benq_init_verbs; 10655218c892SJiang Zhe spec->mixers[0] = cxt5045_mixers; 10665218c892SJiang Zhe spec->mixers[1] = cxt5045_benq_mixers; 10675218c892SJiang Zhe spec->num_mixers = 2; 10685218c892SJiang Zhe codec->patch_ops.init = cxt5045_init; 10695218c892SJiang Zhe break; 1070c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1071c9b443d4STobin Davis case CXT5045_TEST: 1072c9b443d4STobin Davis spec->input_mux = &cxt5045_test_capture_source; 1073c9b443d4STobin Davis spec->mixers[0] = cxt5045_test_mixer; 1074c9b443d4STobin Davis spec->init_verbs[0] = cxt5045_test_init_verbs; 107515908c36SMarc Boucher break; 107615908c36SMarc Boucher 1077c9b443d4STobin Davis #endif 1078c9b443d4STobin Davis } 107948ecb7e8STakashi Iwai 1080031005f7STakashi Iwai switch (codec->subsystem_id >> 16) { 1081031005f7STakashi Iwai case 0x103c: 10828f0f5ff6SDaniel T Chen case 0x1631: 10830b587fc4SDaniel T Chen case 0x1734: 10840ebf9e36SDaniel T Chen case 0x17aa: 10850ebf9e36SDaniel T Chen /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 10860ebf9e36SDaniel T Chen * really bad sound over 0dB on NID 0x17. Fix max PCM level to 10870ebf9e36SDaniel T Chen * 0 dB (originally it has 0x2b steps with 0dB offset 0x14) 108848ecb7e8STakashi Iwai */ 108948ecb7e8STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 109048ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 109148ecb7e8STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 109248ecb7e8STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 109348ecb7e8STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 1094031005f7STakashi Iwai break; 1095031005f7STakashi Iwai } 109648ecb7e8STakashi Iwai 10973507e2a8STakashi Iwai if (spec->beep_amp) 1098a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 10993507e2a8STakashi Iwai 1100c9b443d4STobin Davis return 0; 1101c9b443d4STobin Davis } 1102c9b443d4STobin Davis 1103c9b443d4STobin Davis 1104c9b443d4STobin Davis /* Conexant 5047 specific */ 110582f30040STobin Davis #define CXT5047_SPDIF_OUT 0x11 1106c9b443d4STobin Davis 110734cbe3a6STakashi Iwai static const hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */ 110834cbe3a6STakashi Iwai static const hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 110934cbe3a6STakashi Iwai static const hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1110c9b443d4STobin Davis 111134cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5047_modes[1] = { 11125cd57529STobin Davis { 2, NULL }, 11135cd57529STobin Davis }; 1114c9b443d4STobin Davis 111534cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_toshiba_capture_source = { 111682f30040STobin Davis .num_items = 2, 111782f30040STobin Davis .items = { 111882f30040STobin Davis { "ExtMic", 0x2 }, 111982f30040STobin Davis { "Line-In", 0x1 }, 1120c9b443d4STobin Davis } 1121c9b443d4STobin Davis }; 1122c9b443d4STobin Davis 1123c9b443d4STobin Davis /* turn on/off EAPD (+ mute HP) as a master switch */ 1124c9b443d4STobin Davis static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1125c9b443d4STobin Davis struct snd_ctl_elem_value *ucontrol) 1126c9b443d4STobin Davis { 1127c9b443d4STobin Davis struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1128c9b443d4STobin Davis struct conexant_spec *spec = codec->spec; 112982f30040STobin Davis unsigned int bits; 1130c9b443d4STobin Davis 113182f30040STobin Davis if (!cxt_eapd_put(kcontrol, ucontrol)) 1132c9b443d4STobin Davis return 0; 1133c9b443d4STobin Davis 113482f30040STobin Davis /* toggle internal speakers mute depending of presence of 113582f30040STobin Davis * the headphone jack 113682f30040STobin Davis */ 113747fd830aSTakashi Iwai bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 11383b7523fcSTakashi Iwai /* NOTE: Conexat codec needs the index for *OUTPUT* amp of 11393b7523fcSTakashi Iwai * pin widgets unlike other codecs. In this case, we need to 11403b7523fcSTakashi Iwai * set index 0x01 for the volume from the mixer amp 0x19. 11413b7523fcSTakashi Iwai */ 11425d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 114347fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 114447fd830aSTakashi Iwai bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 114547fd830aSTakashi Iwai snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 114647fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1147c9b443d4STobin Davis return 1; 1148c9b443d4STobin Davis } 1149c9b443d4STobin Davis 1150c9b443d4STobin Davis /* mute internal speaker if HP is plugged */ 1151c9b443d4STobin Davis static void cxt5047_hp_automute(struct hda_codec *codec) 1152c9b443d4STobin Davis { 115382f30040STobin Davis struct conexant_spec *spec = codec->spec; 1154dd87da1cSTobin Davis unsigned int bits; 1155c9b443d4STobin Davis 1156d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x13); 1157dd87da1cSTobin Davis 115847fd830aSTakashi Iwai bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 11593b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 11605d75bc55SGregorio Guidi snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01, 116147fd830aSTakashi Iwai HDA_AMP_MUTE, bits); 1162c9b443d4STobin Davis } 1163c9b443d4STobin Davis 1164c9b443d4STobin Davis /* toggle input of built-in and mic jack appropriately */ 1165c9b443d4STobin Davis static void cxt5047_hp_automic(struct hda_codec *codec) 1166c9b443d4STobin Davis { 116734cbe3a6STakashi Iwai static const struct hda_verb mic_jack_on[] = { 11689f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11699f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1170c9b443d4STobin Davis {} 1171c9b443d4STobin Davis }; 117234cbe3a6STakashi Iwai static const struct hda_verb mic_jack_off[] = { 11739f113e0eSMarc Boucher {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11749f113e0eSMarc Boucher {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1175c9b443d4STobin Davis {} 1176c9b443d4STobin Davis }; 1177c9b443d4STobin Davis unsigned int present; 1178c9b443d4STobin Davis 1179d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x15); 1180c9b443d4STobin Davis if (present) 1181c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_on); 1182c9b443d4STobin Davis else 1183c9b443d4STobin Davis snd_hda_sequence_write(codec, mic_jack_off); 1184c9b443d4STobin Davis } 1185c9b443d4STobin Davis 1186c9b443d4STobin Davis /* unsolicited event for HP jack sensing */ 1187c9b443d4STobin Davis static void cxt5047_hp_unsol_event(struct hda_codec *codec, 1188c9b443d4STobin Davis unsigned int res) 1189c9b443d4STobin Davis { 11909f113e0eSMarc Boucher switch (res >> 26) { 1191c9b443d4STobin Davis case CONEXANT_HP_EVENT: 1192c9b443d4STobin Davis cxt5047_hp_automute(codec); 1193c9b443d4STobin Davis break; 1194c9b443d4STobin Davis case CONEXANT_MIC_EVENT: 1195c9b443d4STobin Davis cxt5047_hp_automic(codec); 1196c9b443d4STobin Davis break; 1197c9b443d4STobin Davis } 1198c9b443d4STobin Davis } 1199c9b443d4STobin Davis 120034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_base_mixers[] = { 1201df481e41STakashi Iwai HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), 1202df481e41STakashi Iwai HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), 12035f99f86aSDavid Henningsson HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 1204c9b443d4STobin Davis HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1205c9b443d4STobin Davis HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1206c9b443d4STobin Davis HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1207c9b443d4STobin Davis HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 120882f30040STobin Davis { 120982f30040STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 121082f30040STobin Davis .name = "Master Playback Switch", 121182f30040STobin Davis .info = cxt_eapd_info, 121282f30040STobin Davis .get = cxt_eapd_get, 1213c9b443d4STobin Davis .put = cxt5047_hp_master_sw_put, 1214c9b443d4STobin Davis .private_value = 0x13, 1215c9b443d4STobin Davis }, 1216c9b443d4STobin Davis 1217c9b443d4STobin Davis {} 1218c9b443d4STobin Davis }; 1219c9b443d4STobin Davis 122034cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { 12213b7523fcSTakashi Iwai /* See the note in cxt5047_hp_master_sw_put */ 12225d75bc55SGregorio Guidi HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT), 1223df481e41STakashi Iwai HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1224df481e41STakashi Iwai {} 1225df481e41STakashi Iwai }; 1226df481e41STakashi Iwai 122734cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { 1228c9b443d4STobin Davis HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1229c9b443d4STobin Davis { } /* end */ 1230c9b443d4STobin Davis }; 1231c9b443d4STobin Davis 123234cbe3a6STakashi Iwai static const struct hda_verb cxt5047_init_verbs[] = { 1233c9b443d4STobin Davis /* Line in, Mic, Built-in Mic */ 1234c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1235c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1236c9b443d4STobin Davis {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 12377f29673bSTobin Davis /* HP, Speaker */ 1238b7589cebSTobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 12395b3a7440STakashi Iwai {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */ 12405b3a7440STakashi Iwai {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */ 12417f29673bSTobin Davis /* Record selector: Mic */ 12427f29673bSTobin Davis {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 12437f29673bSTobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 12447f29673bSTobin Davis AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 12457f29673bSTobin Davis {0x1A, AC_VERB_SET_CONNECT_SEL,0x02}, 1246c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1247c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00}, 1248c9b443d4STobin Davis {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, 1249c9b443d4STobin Davis AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03}, 1250c9b443d4STobin Davis /* SPDIF route: PCM */ 1251c9b443d4STobin Davis { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 125282f30040STobin Davis /* Enable unsolicited events */ 125382f30040STobin Davis {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 125482f30040STobin Davis {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1255c9b443d4STobin Davis { } /* end */ 1256c9b443d4STobin Davis }; 1257c9b443d4STobin Davis 1258c9b443d4STobin Davis /* configuration for Toshiba Laptops */ 125934cbe3a6STakashi Iwai static const struct hda_verb cxt5047_toshiba_init_verbs[] = { 12603b628867STakashi Iwai {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */ 1261c9b443d4STobin Davis {} 1262c9b443d4STobin Davis }; 1263c9b443d4STobin Davis 1264c9b443d4STobin Davis /* Test configuration for debugging, modelled after the ALC260 test 1265c9b443d4STobin Davis * configuration. 1266c9b443d4STobin Davis */ 1267c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 126834cbe3a6STakashi Iwai static const struct hda_input_mux cxt5047_test_capture_source = { 126982f30040STobin Davis .num_items = 4, 1270c9b443d4STobin Davis .items = { 127182f30040STobin Davis { "LINE1 pin", 0x0 }, 127282f30040STobin Davis { "MIC1 pin", 0x1 }, 127382f30040STobin Davis { "MIC2 pin", 0x2 }, 127482f30040STobin Davis { "CD pin", 0x3 }, 1275c9b443d4STobin Davis }, 1276c9b443d4STobin Davis }; 1277c9b443d4STobin Davis 127834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5047_test_mixer[] = { 1279c9b443d4STobin Davis 1280c9b443d4STobin Davis /* Output only controls */ 128182f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT), 128282f30040STobin Davis HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT), 128382f30040STobin Davis HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT), 128482f30040STobin Davis HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT), 1285c9b443d4STobin Davis HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1286c9b443d4STobin Davis HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1287c9b443d4STobin Davis HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1288c9b443d4STobin Davis HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT), 128982f30040STobin Davis HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT), 129082f30040STobin Davis HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), 129182f30040STobin Davis HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT), 129282f30040STobin Davis HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1293c9b443d4STobin Davis 1294c9b443d4STobin Davis /* Modes for retasking pin widgets */ 1295c9b443d4STobin Davis CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT), 1296c9b443d4STobin Davis CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT), 1297c9b443d4STobin Davis 129882f30040STobin Davis /* EAPD Switch Control */ 129982f30040STobin Davis CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0), 130082f30040STobin Davis 1301c9b443d4STobin Davis /* Loopback mixer controls */ 130282f30040STobin Davis HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT), 130382f30040STobin Davis HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT), 130482f30040STobin Davis HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT), 130582f30040STobin Davis HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT), 130682f30040STobin Davis HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT), 130782f30040STobin Davis HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT), 130882f30040STobin Davis HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT), 130982f30040STobin Davis HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT), 1310c9b443d4STobin Davis 131182f30040STobin Davis HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT), 131282f30040STobin Davis HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT), 131382f30040STobin Davis HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT), 131482f30040STobin Davis HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT), 131582f30040STobin Davis HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT), 131682f30040STobin Davis HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT), 131782f30040STobin Davis HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT), 131882f30040STobin Davis HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT), 1319c9b443d4STobin Davis { 1320c9b443d4STobin Davis .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1321c9b443d4STobin Davis .name = "Input Source", 1322c9b443d4STobin Davis .info = conexant_mux_enum_info, 1323c9b443d4STobin Davis .get = conexant_mux_enum_get, 1324c9b443d4STobin Davis .put = conexant_mux_enum_put, 1325c9b443d4STobin Davis }, 1326854206b0STakashi Iwai HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT), 13279f113e0eSMarc Boucher 1328c9b443d4STobin Davis { } /* end */ 1329c9b443d4STobin Davis }; 1330c9b443d4STobin Davis 133134cbe3a6STakashi Iwai static const struct hda_verb cxt5047_test_init_verbs[] = { 1332c9b443d4STobin Davis /* Enable retasking pins as output, initially without power amp */ 1333c9b443d4STobin Davis {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1334c9b443d4STobin Davis {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1335c9b443d4STobin Davis {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1336c9b443d4STobin Davis 1337c9b443d4STobin Davis /* Disable digital (SPDIF) pins initially, but users can enable 1338c9b443d4STobin Davis * them via a mixer switch. In the case of SPDIF-out, this initverb 1339c9b443d4STobin Davis * payload also sets the generation to 0, output to be in "consumer" 1340c9b443d4STobin Davis * PCM format, copyright asserted, no pre-emphasis and no validity 1341c9b443d4STobin Davis * control. 1342c9b443d4STobin Davis */ 1343c9b443d4STobin Davis {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0}, 1344c9b443d4STobin Davis 1345c9b443d4STobin Davis /* Ensure mic1, mic2, line1 pin widgets take input from the 1346c9b443d4STobin Davis * OUT1 sum bus when acting as an output. 1347c9b443d4STobin Davis */ 1348c9b443d4STobin Davis {0x1a, AC_VERB_SET_CONNECT_SEL, 0}, 1349c9b443d4STobin Davis {0x1b, AC_VERB_SET_CONNECT_SEL, 0}, 1350c9b443d4STobin Davis 1351c9b443d4STobin Davis /* Start with output sum widgets muted and their output gains at min */ 1352c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1353c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1354c9b443d4STobin Davis 1355c9b443d4STobin Davis /* Unmute retasking pin widget output buffers since the default 1356c9b443d4STobin Davis * state appears to be output. As the pin mode is changed by the 1357c9b443d4STobin Davis * user the pin mode control will take care of enabling the pin's 1358c9b443d4STobin Davis * input/output buffers as needed. 1359c9b443d4STobin Davis */ 1360c9b443d4STobin Davis {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1361c9b443d4STobin Davis {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1362c9b443d4STobin Davis {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1363c9b443d4STobin Davis 1364c9b443d4STobin Davis /* Mute capture amp left and right */ 1365c9b443d4STobin Davis {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1366c9b443d4STobin Davis 1367c9b443d4STobin Davis /* Set ADC connection select to match default mixer setting (mic1 1368c9b443d4STobin Davis * pin) 1369c9b443d4STobin Davis */ 1370c9b443d4STobin Davis {0x12, AC_VERB_SET_CONNECT_SEL, 0x00}, 1371c9b443d4STobin Davis 1372c9b443d4STobin Davis /* Mute all inputs to mixer widget (even unconnected ones) */ 1373c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 1374c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 1375c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 1376c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 1377c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 1378c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 1379c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 1380c9b443d4STobin Davis {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 1381c9b443d4STobin Davis 1382c9b443d4STobin Davis { } 1383c9b443d4STobin Davis }; 1384c9b443d4STobin Davis #endif 1385c9b443d4STobin Davis 1386c9b443d4STobin Davis 1387c9b443d4STobin Davis /* initialize jack-sensing, too */ 1388c9b443d4STobin Davis static int cxt5047_hp_init(struct hda_codec *codec) 1389c9b443d4STobin Davis { 1390c9b443d4STobin Davis conexant_init(codec); 1391c9b443d4STobin Davis cxt5047_hp_automute(codec); 1392c9b443d4STobin Davis return 0; 1393c9b443d4STobin Davis } 1394c9b443d4STobin Davis 1395c9b443d4STobin Davis 1396c9b443d4STobin Davis enum { 1397f5fcc13cSTakashi Iwai CXT5047_LAPTOP, /* Laptops w/o EAPD support */ 1398f5fcc13cSTakashi Iwai CXT5047_LAPTOP_HP, /* Some HP laptops */ 1399f5fcc13cSTakashi Iwai CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */ 1400c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1401c9b443d4STobin Davis CXT5047_TEST, 1402c9b443d4STobin Davis #endif 1403fa5dadcbSTakashi Iwai CXT5047_AUTO, 1404f5fcc13cSTakashi Iwai CXT5047_MODELS 1405c9b443d4STobin Davis }; 1406c9b443d4STobin Davis 1407ea734963STakashi Iwai static const char * const cxt5047_models[CXT5047_MODELS] = { 1408f5fcc13cSTakashi Iwai [CXT5047_LAPTOP] = "laptop", 1409f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_HP] = "laptop-hp", 1410f5fcc13cSTakashi Iwai [CXT5047_LAPTOP_EAPD] = "laptop-eapd", 1411c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1412f5fcc13cSTakashi Iwai [CXT5047_TEST] = "test", 1413c9b443d4STobin Davis #endif 1414fa5dadcbSTakashi Iwai [CXT5047_AUTO] = "auto", 1415f5fcc13cSTakashi Iwai }; 1416c9b443d4STobin Davis 141734cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1418ac3e3741STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1419dea0a509STakashi Iwai SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series", 1420dea0a509STakashi Iwai CXT5047_LAPTOP), 1421f5fcc13cSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1422c9b443d4STobin Davis {} 1423c9b443d4STobin Davis }; 1424c9b443d4STobin Davis 1425c9b443d4STobin Davis static int patch_cxt5047(struct hda_codec *codec) 1426c9b443d4STobin Davis { 1427c9b443d4STobin Davis struct conexant_spec *spec; 1428c9b443d4STobin Davis int board_config; 1429c9b443d4STobin Davis 1430fa5dadcbSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, 1431fa5dadcbSTakashi Iwai cxt5047_models, 1432fa5dadcbSTakashi Iwai cxt5047_cfg_tbl); 1433fa5dadcbSTakashi Iwai if (board_config < 0) 1434c82693dbSTakashi Iwai board_config = CXT5047_AUTO; /* model=auto as default */ 1435fa5dadcbSTakashi Iwai if (board_config == CXT5047_AUTO) 1436fa5dadcbSTakashi Iwai return patch_conexant_auto(codec); 1437fa5dadcbSTakashi Iwai 1438c9b443d4STobin Davis spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1439c9b443d4STobin Davis if (!spec) 1440c9b443d4STobin Davis return -ENOMEM; 1441c9b443d4STobin Davis codec->spec = spec; 14429421f954STakashi Iwai codec->pin_amp_workaround = 1; 1443c9b443d4STobin Davis 1444c9b443d4STobin Davis spec->multiout.max_channels = 2; 1445c9b443d4STobin Davis spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1446c9b443d4STobin Davis spec->multiout.dac_nids = cxt5047_dac_nids; 1447c9b443d4STobin Davis spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT; 1448c9b443d4STobin Davis spec->num_adc_nids = 1; 1449c9b443d4STobin Davis spec->adc_nids = cxt5047_adc_nids; 1450c9b443d4STobin Davis spec->capsrc_nids = cxt5047_capsrc_nids; 1451c9b443d4STobin Davis spec->num_mixers = 1; 1452df481e41STakashi Iwai spec->mixers[0] = cxt5047_base_mixers; 1453c9b443d4STobin Davis spec->num_init_verbs = 1; 1454c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_init_verbs; 1455c9b443d4STobin Davis spec->spdif_route = 0; 14565cd57529STobin Davis spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes), 14575cd57529STobin Davis spec->channel_mode = cxt5047_modes, 1458c9b443d4STobin Davis 1459c9b443d4STobin Davis codec->patch_ops = conexant_patch_ops; 1460c9b443d4STobin Davis 1461c9b443d4STobin Davis switch (board_config) { 1462c9b443d4STobin Davis case CXT5047_LAPTOP: 1463df481e41STakashi Iwai spec->num_mixers = 2; 1464df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1465df481e41STakashi Iwai codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1466c9b443d4STobin Davis break; 1467c9b443d4STobin Davis case CXT5047_LAPTOP_HP: 1468df481e41STakashi Iwai spec->num_mixers = 2; 1469df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_only_mixers; 1470fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1471c9b443d4STobin Davis codec->patch_ops.init = cxt5047_hp_init; 1472c9b443d4STobin Davis break; 1473c9b443d4STobin Davis case CXT5047_LAPTOP_EAPD: 147482f30040STobin Davis spec->input_mux = &cxt5047_toshiba_capture_source; 1475df481e41STakashi Iwai spec->num_mixers = 2; 1476df481e41STakashi Iwai spec->mixers[1] = cxt5047_hp_spk_mixers; 1477c9b443d4STobin Davis spec->num_init_verbs = 2; 1478c9b443d4STobin Davis spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1479fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1480c9b443d4STobin Davis break; 1481c9b443d4STobin Davis #ifdef CONFIG_SND_DEBUG 1482c9b443d4STobin Davis case CXT5047_TEST: 1483c9b443d4STobin Davis spec->input_mux = &cxt5047_test_capture_source; 1484c9b443d4STobin Davis spec->mixers[0] = cxt5047_test_mixer; 1485c9b443d4STobin Davis spec->init_verbs[0] = cxt5047_test_init_verbs; 1486fb3409e7STobin Davis codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1487c9b443d4STobin Davis #endif 1488c9b443d4STobin Davis } 1489dd5746a8STakashi Iwai spec->vmaster_nid = 0x13; 1490025f206cSDaniel T Chen 1491025f206cSDaniel T Chen switch (codec->subsystem_id >> 16) { 1492025f206cSDaniel T Chen case 0x103c: 1493025f206cSDaniel T Chen /* HP laptops have really bad sound over 0 dB on NID 0x10. 1494025f206cSDaniel T Chen * Fix max PCM level to 0 dB (originally it has 0x1e steps 1495025f206cSDaniel T Chen * with 0 dB offset 0x17) 1496025f206cSDaniel T Chen */ 1497025f206cSDaniel T Chen snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 1498025f206cSDaniel T Chen (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 1499025f206cSDaniel T Chen (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 1500025f206cSDaniel T Chen (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 1501025f206cSDaniel T Chen (1 << AC_AMPCAP_MUTE_SHIFT)); 1502025f206cSDaniel T Chen break; 1503025f206cSDaniel T Chen } 1504025f206cSDaniel T Chen 1505c9b443d4STobin Davis return 0; 1506c9b443d4STobin Davis } 1507c9b443d4STobin Davis 1508461e2c78STakashi Iwai /* Conexant 5051 specific */ 150934cbe3a6STakashi Iwai static const hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 151034cbe3a6STakashi Iwai static const hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1511461e2c78STakashi Iwai 151234cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5051_modes[1] = { 1513461e2c78STakashi Iwai { 2, NULL }, 1514461e2c78STakashi Iwai }; 1515461e2c78STakashi Iwai 1516461e2c78STakashi Iwai static void cxt5051_update_speaker(struct hda_codec *codec) 1517461e2c78STakashi Iwai { 1518461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1519461e2c78STakashi Iwai unsigned int pinctl; 152023d2df5bSTakashi Iwai /* headphone pin */ 152123d2df5bSTakashi Iwai pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; 1522cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x16, pinctl); 152323d2df5bSTakashi Iwai /* speaker pin */ 1524461e2c78STakashi Iwai pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 1525cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1a, pinctl); 1526a80581d0SJustin P. Mattock /* on ideapad there is an additional speaker (subwoofer) to mute */ 1527f7154de2SHerton Ronaldo Krzesinski if (spec->ideapad) 1528cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(codec, 0x1b, pinctl); 1529461e2c78STakashi Iwai } 1530461e2c78STakashi Iwai 1531461e2c78STakashi Iwai /* turn on/off EAPD (+ mute HP) as a master switch */ 1532461e2c78STakashi Iwai static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol, 1533461e2c78STakashi Iwai struct snd_ctl_elem_value *ucontrol) 1534461e2c78STakashi Iwai { 1535461e2c78STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1536461e2c78STakashi Iwai 1537461e2c78STakashi Iwai if (!cxt_eapd_put(kcontrol, ucontrol)) 1538461e2c78STakashi Iwai return 0; 1539461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1540461e2c78STakashi Iwai return 1; 1541461e2c78STakashi Iwai } 1542461e2c78STakashi Iwai 1543461e2c78STakashi Iwai /* toggle input of built-in and mic jack appropriately */ 1544461e2c78STakashi Iwai static void cxt5051_portb_automic(struct hda_codec *codec) 1545461e2c78STakashi Iwai { 154679d7d533STakashi Iwai struct conexant_spec *spec = codec->spec; 1547461e2c78STakashi Iwai unsigned int present; 1548461e2c78STakashi Iwai 1549faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTB)) 155079d7d533STakashi Iwai return; 1551d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x17); 1552461e2c78STakashi Iwai snd_hda_codec_write(codec, 0x14, 0, 1553461e2c78STakashi Iwai AC_VERB_SET_CONNECT_SEL, 1554461e2c78STakashi Iwai present ? 0x01 : 0x00); 1555461e2c78STakashi Iwai } 1556461e2c78STakashi Iwai 1557461e2c78STakashi Iwai /* switch the current ADC according to the jack state */ 1558461e2c78STakashi Iwai static void cxt5051_portc_automic(struct hda_codec *codec) 1559461e2c78STakashi Iwai { 1560461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1561461e2c78STakashi Iwai unsigned int present; 1562461e2c78STakashi Iwai hda_nid_t new_adc; 1563461e2c78STakashi Iwai 1564faddaa5dSTakashi Iwai if (!(spec->auto_mic & AUTO_MIC_PORTC)) 156579d7d533STakashi Iwai return; 1566d56757abSTakashi Iwai present = snd_hda_jack_detect(codec, 0x18); 1567461e2c78STakashi Iwai if (present) 1568461e2c78STakashi Iwai spec->cur_adc_idx = 1; 1569461e2c78STakashi Iwai else 1570461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1571461e2c78STakashi Iwai new_adc = spec->adc_nids[spec->cur_adc_idx]; 1572461e2c78STakashi Iwai if (spec->cur_adc && spec->cur_adc != new_adc) { 1573461e2c78STakashi Iwai /* stream is running, let's swap the current ADC */ 1574f0cea797STakashi Iwai __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1575461e2c78STakashi Iwai spec->cur_adc = new_adc; 1576461e2c78STakashi Iwai snd_hda_codec_setup_stream(codec, new_adc, 1577461e2c78STakashi Iwai spec->cur_adc_stream_tag, 0, 1578461e2c78STakashi Iwai spec->cur_adc_format); 1579461e2c78STakashi Iwai } 1580461e2c78STakashi Iwai } 1581461e2c78STakashi Iwai 1582461e2c78STakashi Iwai /* mute internal speaker if HP is plugged */ 1583461e2c78STakashi Iwai static void cxt5051_hp_automute(struct hda_codec *codec) 1584461e2c78STakashi Iwai { 1585461e2c78STakashi Iwai struct conexant_spec *spec = codec->spec; 1586461e2c78STakashi Iwai 1587d56757abSTakashi Iwai spec->hp_present = snd_hda_jack_detect(codec, 0x16); 1588461e2c78STakashi Iwai cxt5051_update_speaker(codec); 1589461e2c78STakashi Iwai } 1590461e2c78STakashi Iwai 1591461e2c78STakashi Iwai /* unsolicited event for HP jack sensing */ 1592461e2c78STakashi Iwai static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1593461e2c78STakashi Iwai unsigned int res) 1594461e2c78STakashi Iwai { 1595461e2c78STakashi Iwai switch (res >> 26) { 1596461e2c78STakashi Iwai case CONEXANT_HP_EVENT: 1597461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1598461e2c78STakashi Iwai break; 1599461e2c78STakashi Iwai case CXT5051_PORTB_EVENT: 1600461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1601461e2c78STakashi Iwai break; 1602461e2c78STakashi Iwai case CXT5051_PORTC_EVENT: 1603461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1604461e2c78STakashi Iwai break; 1605461e2c78STakashi Iwai } 1606461e2c78STakashi Iwai } 1607461e2c78STakashi Iwai 160834cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { 1609461e2c78STakashi Iwai HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1610461e2c78STakashi Iwai { 1611461e2c78STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1612461e2c78STakashi Iwai .name = "Master Playback Switch", 1613461e2c78STakashi Iwai .info = cxt_eapd_info, 1614461e2c78STakashi Iwai .get = cxt_eapd_get, 1615461e2c78STakashi Iwai .put = cxt5051_hp_master_sw_put, 1616461e2c78STakashi Iwai .private_value = 0x1a, 1617461e2c78STakashi Iwai }, 16182c7a3fb3STakashi Iwai {} 16192c7a3fb3STakashi Iwai }; 1620461e2c78STakashi Iwai 162134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_capture_mixers[] = { 16222c7a3fb3STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 16232c7a3fb3STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16248607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16258607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1626c40bd914SDavid Henningsson HDA_CODEC_VOLUME("Dock Mic Volume", 0x15, 0x00, HDA_INPUT), 1627c40bd914SDavid Henningsson HDA_CODEC_MUTE("Dock Mic Switch", 0x15, 0x00, HDA_INPUT), 1628461e2c78STakashi Iwai {} 1629461e2c78STakashi Iwai }; 1630461e2c78STakashi Iwai 163134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_mixers[] = { 1632461e2c78STakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1633461e2c78STakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16348607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x15, 0x00, HDA_INPUT), 16358607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x15, 0x00, HDA_INPUT), 1636461e2c78STakashi Iwai {} 1637461e2c78STakashi Iwai }; 1638461e2c78STakashi Iwai 163934cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { 16404e4ac600STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), 16414e4ac600STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), 164279d7d533STakashi Iwai {} 164379d7d533STakashi Iwai }; 164479d7d533STakashi Iwai 164534cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_f700_mixers[] = { 16465f6c3de6STakashi Iwai HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), 16475f6c3de6STakashi Iwai HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), 1648cd9d95a5SKen Prox {} 1649cd9d95a5SKen Prox }; 1650cd9d95a5SKen Prox 165134cbe3a6STakashi Iwai static const struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { 1652faddaa5dSTakashi Iwai HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), 1653faddaa5dSTakashi Iwai HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), 16548607f7c4SDavid Henningsson HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 16558607f7c4SDavid Henningsson HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1656faddaa5dSTakashi Iwai {} 1657faddaa5dSTakashi Iwai }; 1658faddaa5dSTakashi Iwai 165934cbe3a6STakashi Iwai static const struct hda_verb cxt5051_init_verbs[] = { 1660461e2c78STakashi Iwai /* Line in, Mic */ 1661461e2c78STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1662461e2c78STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1663461e2c78STakashi Iwai {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1664461e2c78STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1665461e2c78STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1666461e2c78STakashi Iwai {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1667461e2c78STakashi Iwai /* SPK */ 1668461e2c78STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1669461e2c78STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1670461e2c78STakashi Iwai /* HP, Amp */ 1671461e2c78STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1672461e2c78STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1673461e2c78STakashi Iwai /* DAC1 */ 1674461e2c78STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 167528c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1676461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1677461e2c78STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1678461e2c78STakashi Iwai {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44}, 1679461e2c78STakashi Iwai /* SPDIF route: PCM */ 16801965c441SPierre-Louis Bossart {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1681461e2c78STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1682461e2c78STakashi Iwai /* EAPD */ 1683461e2c78STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1684461e2c78STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1685461e2c78STakashi Iwai { } /* end */ 1686461e2c78STakashi Iwai }; 1687461e2c78STakashi Iwai 168834cbe3a6STakashi Iwai static const struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { 168979d7d533STakashi Iwai /* Line in, Mic */ 169079d7d533STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 169179d7d533STakashi Iwai {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 169279d7d533STakashi Iwai {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 169379d7d533STakashi Iwai {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 169479d7d533STakashi Iwai /* SPK */ 169579d7d533STakashi Iwai {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 169679d7d533STakashi Iwai {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 169779d7d533STakashi Iwai /* HP, Amp */ 169879d7d533STakashi Iwai {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 169979d7d533STakashi Iwai {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 170079d7d533STakashi Iwai /* DAC1 */ 170179d7d533STakashi Iwai {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 170228c4edb7SDavid Henningsson /* Record selector: Internal mic */ 170379d7d533STakashi Iwai {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 170479d7d533STakashi Iwai {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 170579d7d533STakashi Iwai /* SPDIF route: PCM */ 170679d7d533STakashi Iwai {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 170779d7d533STakashi Iwai /* EAPD */ 170879d7d533STakashi Iwai {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 170979d7d533STakashi Iwai {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 171079d7d533STakashi Iwai { } /* end */ 171179d7d533STakashi Iwai }; 171279d7d533STakashi Iwai 171334cbe3a6STakashi Iwai static const struct hda_verb cxt5051_f700_init_verbs[] = { 1714cd9d95a5SKen Prox /* Line in, Mic */ 171530ed7ed1STakashi Iwai {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1716cd9d95a5SKen Prox {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1717cd9d95a5SKen Prox {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1718cd9d95a5SKen Prox {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1719cd9d95a5SKen Prox /* SPK */ 1720cd9d95a5SKen Prox {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1721cd9d95a5SKen Prox {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1722cd9d95a5SKen Prox /* HP, Amp */ 1723cd9d95a5SKen Prox {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1724cd9d95a5SKen Prox {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1725cd9d95a5SKen Prox /* DAC1 */ 1726cd9d95a5SKen Prox {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 172728c4edb7SDavid Henningsson /* Record selector: Internal mic */ 1728cd9d95a5SKen Prox {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1729cd9d95a5SKen Prox {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1730cd9d95a5SKen Prox /* SPDIF route: PCM */ 1731cd9d95a5SKen Prox {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1732cd9d95a5SKen Prox /* EAPD */ 1733cd9d95a5SKen Prox {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1734cd9d95a5SKen Prox {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1735cd9d95a5SKen Prox { } /* end */ 1736cd9d95a5SKen Prox }; 1737cd9d95a5SKen Prox 17386953e552STakashi Iwai static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, 17396953e552STakashi Iwai unsigned int event) 17406953e552STakashi Iwai { 17416953e552STakashi Iwai snd_hda_codec_write(codec, nid, 0, 17426953e552STakashi Iwai AC_VERB_SET_UNSOLICITED_ENABLE, 17436953e552STakashi Iwai AC_USRSP_EN | event); 17446953e552STakashi Iwai } 17456953e552STakashi Iwai 174634cbe3a6STakashi Iwai static const struct hda_verb cxt5051_ideapad_init_verbs[] = { 1747f7154de2SHerton Ronaldo Krzesinski /* Subwoofer */ 1748f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1749f7154de2SHerton Ronaldo Krzesinski {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1750f7154de2SHerton Ronaldo Krzesinski { } /* end */ 1751f7154de2SHerton Ronaldo Krzesinski }; 1752f7154de2SHerton Ronaldo Krzesinski 1753461e2c78STakashi Iwai /* initialize jack-sensing, too */ 1754461e2c78STakashi Iwai static int cxt5051_init(struct hda_codec *codec) 1755461e2c78STakashi Iwai { 17566953e552STakashi Iwai struct conexant_spec *spec = codec->spec; 17576953e552STakashi Iwai 1758461e2c78STakashi Iwai conexant_init(codec); 17596953e552STakashi Iwai 17606953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTB) 17616953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); 17626953e552STakashi Iwai if (spec->auto_mic & AUTO_MIC_PORTC) 17636953e552STakashi Iwai cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); 17646953e552STakashi Iwai 1765461e2c78STakashi Iwai if (codec->patch_ops.unsol_event) { 1766461e2c78STakashi Iwai cxt5051_hp_automute(codec); 1767461e2c78STakashi Iwai cxt5051_portb_automic(codec); 1768461e2c78STakashi Iwai cxt5051_portc_automic(codec); 1769461e2c78STakashi Iwai } 1770461e2c78STakashi Iwai return 0; 1771461e2c78STakashi Iwai } 1772461e2c78STakashi Iwai 1773461e2c78STakashi Iwai 1774461e2c78STakashi Iwai enum { 1775461e2c78STakashi Iwai CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1776461e2c78STakashi Iwai CXT5051_HP, /* no docking */ 177779d7d533STakashi Iwai CXT5051_HP_DV6736, /* HP without mic switch */ 1778cd9d95a5SKen Prox CXT5051_F700, /* HP Compaq Presario F700 */ 1779faddaa5dSTakashi Iwai CXT5051_TOSHIBA, /* Toshiba M300 & co */ 1780f7154de2SHerton Ronaldo Krzesinski CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ 17816764bcefSTakashi Iwai CXT5051_AUTO, /* auto-parser */ 1782461e2c78STakashi Iwai CXT5051_MODELS 1783461e2c78STakashi Iwai }; 1784461e2c78STakashi Iwai 1785ea734963STakashi Iwai static const char *const cxt5051_models[CXT5051_MODELS] = { 1786461e2c78STakashi Iwai [CXT5051_LAPTOP] = "laptop", 1787461e2c78STakashi Iwai [CXT5051_HP] = "hp", 178879d7d533STakashi Iwai [CXT5051_HP_DV6736] = "hp-dv6736", 17895f6c3de6STakashi Iwai [CXT5051_F700] = "hp-700", 1790faddaa5dSTakashi Iwai [CXT5051_TOSHIBA] = "toshiba", 1791f7154de2SHerton Ronaldo Krzesinski [CXT5051_IDEAPAD] = "ideapad", 17926764bcefSTakashi Iwai [CXT5051_AUTO] = "auto", 1793461e2c78STakashi Iwai }; 1794461e2c78STakashi Iwai 179534cbe3a6STakashi Iwai static const struct snd_pci_quirk cxt5051_cfg_tbl[] = { 179679d7d533STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), 17971812e67cSTony Vroon SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), 17985f6c3de6STakashi Iwai SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1799faddaa5dSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), 1800461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1801461e2c78STakashi Iwai CXT5051_LAPTOP), 1802461e2c78STakashi Iwai SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1803f7154de2SHerton Ronaldo Krzesinski SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), 1804461e2c78STakashi Iwai {} 1805461e2c78STakashi Iwai }; 1806461e2c78STakashi Iwai 1807461e2c78STakashi Iwai static int patch_cxt5051(struct hda_codec *codec) 1808461e2c78STakashi Iwai { 1809461e2c78STakashi Iwai struct conexant_spec *spec; 1810461e2c78STakashi Iwai int board_config; 1811461e2c78STakashi Iwai 18126764bcefSTakashi Iwai board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 18136764bcefSTakashi Iwai cxt5051_models, 18146764bcefSTakashi Iwai cxt5051_cfg_tbl); 18156764bcefSTakashi Iwai if (board_config < 0) 1816c82693dbSTakashi Iwai board_config = CXT5051_AUTO; /* model=auto as default */ 18171f8458a2STakashi Iwai if (board_config == CXT5051_AUTO) 18186764bcefSTakashi Iwai return patch_conexant_auto(codec); 18196764bcefSTakashi Iwai 1820461e2c78STakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1821461e2c78STakashi Iwai if (!spec) 1822461e2c78STakashi Iwai return -ENOMEM; 1823461e2c78STakashi Iwai codec->spec = spec; 18249421f954STakashi Iwai codec->pin_amp_workaround = 1; 1825461e2c78STakashi Iwai 1826461e2c78STakashi Iwai codec->patch_ops = conexant_patch_ops; 1827461e2c78STakashi Iwai codec->patch_ops.init = cxt5051_init; 1828461e2c78STakashi Iwai 1829461e2c78STakashi Iwai spec->multiout.max_channels = 2; 1830461e2c78STakashi Iwai spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids); 1831461e2c78STakashi Iwai spec->multiout.dac_nids = cxt5051_dac_nids; 1832461e2c78STakashi Iwai spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; 1833461e2c78STakashi Iwai spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ 1834461e2c78STakashi Iwai spec->adc_nids = cxt5051_adc_nids; 18352c7a3fb3STakashi Iwai spec->num_mixers = 2; 18362c7a3fb3STakashi Iwai spec->mixers[0] = cxt5051_capture_mixers; 18372c7a3fb3STakashi Iwai spec->mixers[1] = cxt5051_playback_mixers; 1838461e2c78STakashi Iwai spec->num_init_verbs = 1; 1839461e2c78STakashi Iwai spec->init_verbs[0] = cxt5051_init_verbs; 1840461e2c78STakashi Iwai spec->spdif_route = 0; 1841461e2c78STakashi Iwai spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes); 1842461e2c78STakashi Iwai spec->channel_mode = cxt5051_modes; 1843461e2c78STakashi Iwai spec->cur_adc = 0; 1844461e2c78STakashi Iwai spec->cur_adc_idx = 0; 1845461e2c78STakashi Iwai 18463507e2a8STakashi Iwai set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); 18473507e2a8STakashi Iwai 184879d7d533STakashi Iwai codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 184979d7d533STakashi Iwai 1850faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; 1851461e2c78STakashi Iwai switch (board_config) { 1852461e2c78STakashi Iwai case CXT5051_HP: 1853461e2c78STakashi Iwai spec->mixers[0] = cxt5051_hp_mixers; 1854461e2c78STakashi Iwai break; 185579d7d533STakashi Iwai case CXT5051_HP_DV6736: 185679d7d533STakashi Iwai spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; 185779d7d533STakashi Iwai spec->mixers[0] = cxt5051_hp_dv6736_mixers; 1858faddaa5dSTakashi Iwai spec->auto_mic = 0; 185979d7d533STakashi Iwai break; 1860cd9d95a5SKen Prox case CXT5051_F700: 1861cd9d95a5SKen Prox spec->init_verbs[0] = cxt5051_f700_init_verbs; 1862cd9d95a5SKen Prox spec->mixers[0] = cxt5051_f700_mixers; 1863faddaa5dSTakashi Iwai spec->auto_mic = 0; 1864faddaa5dSTakashi Iwai break; 1865faddaa5dSTakashi Iwai case CXT5051_TOSHIBA: 1866faddaa5dSTakashi Iwai spec->mixers[0] = cxt5051_toshiba_mixers; 1867faddaa5dSTakashi Iwai spec->auto_mic = AUTO_MIC_PORTB; 1868cd9d95a5SKen Prox break; 1869f7154de2SHerton Ronaldo Krzesinski case CXT5051_IDEAPAD: 1870f7154de2SHerton Ronaldo Krzesinski spec->init_verbs[spec->num_init_verbs++] = 1871f7154de2SHerton Ronaldo Krzesinski cxt5051_ideapad_init_verbs; 1872f7154de2SHerton Ronaldo Krzesinski spec->ideapad = 1; 1873f7154de2SHerton Ronaldo Krzesinski break; 1874461e2c78STakashi Iwai } 1875461e2c78STakashi Iwai 18763507e2a8STakashi Iwai if (spec->beep_amp) 1877a86b1a2cSTakashi Iwai snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 18783507e2a8STakashi Iwai 1879461e2c78STakashi Iwai return 0; 1880461e2c78STakashi Iwai } 1881461e2c78STakashi Iwai 18820fb67e98SDaniel Drake /* Conexant 5066 specific */ 18830fb67e98SDaniel Drake 188434cbe3a6STakashi Iwai static const hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; 188534cbe3a6STakashi Iwai static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; 188634cbe3a6STakashi Iwai static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 188734cbe3a6STakashi Iwai static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 18880fb67e98SDaniel Drake 188934cbe3a6STakashi Iwai static const struct hda_channel_mode cxt5066_modes[1] = { 18900fb67e98SDaniel Drake { 2, NULL }, 18910fb67e98SDaniel Drake }; 18920fb67e98SDaniel Drake 1893a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_A (1 << 0) 1894a3de8ab8STakashi Iwai #define HP_PRESENT_PORT_D (1 << 1) 1895a3de8ab8STakashi Iwai #define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A) 1896a3de8ab8STakashi Iwai #define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D) 1897a3de8ab8STakashi Iwai 18980fb67e98SDaniel Drake static void cxt5066_update_speaker(struct hda_codec *codec) 18990fb67e98SDaniel Drake { 19000fb67e98SDaniel Drake struct conexant_spec *spec = codec->spec; 19010fb67e98SDaniel Drake unsigned int pinctl; 19020fb67e98SDaniel Drake 1903*4e76a883STakashi Iwai codec_dbg(codec, 1904*4e76a883STakashi Iwai "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) { 1973*4e76a883STakashi Iwai codec_dbg(codec, "CXT5066: external microphone detected\n"); 197495a618bdSEinar Rünkaru snd_hda_sequence_write(codec, ext_mic_present); 197595a618bdSEinar Rünkaru } else { 1976*4e76a883STakashi Iwai codec_dbg(codec, "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) { 2001*4e76a883STakashi Iwai codec_dbg(codec, "CXT5066: external microphone detected\n"); 2002cfd3d8dcSGreg Alexander snd_hda_sequence_write(codec, ext_mic_present); 2003cfd3d8dcSGreg Alexander } else { 2004*4e76a883STakashi Iwai codec_dbg(codec, "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); 2016*4e76a883STakashi Iwai codec_dbg(codec, "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); 2028*4e76a883STakashi Iwai codec_dbg(codec, "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) { 2067*4e76a883STakashi Iwai codec_dbg(codec, "CXT5066: external microphone detected\n"); 20687b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, ext_mic_present); 20697b2bfdbcSJens Taprogge } else if (dock_present) { 2070*4e76a883STakashi Iwai codec_dbg(codec, "CXT5066: dock microphone detected\n"); 20717b2bfdbcSJens Taprogge snd_hda_sequence_write(codec, dock_mic_present); 20727b2bfdbcSJens Taprogge } else { 2073*4e76a883STakashi Iwai codec_dbg(codec, "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; 2092*4e76a883STakashi Iwai codec_dbg(codec, "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 { 2117*4e76a883STakashi Iwai codec_dbg(codec, "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 { 2513*4e76a883STakashi Iwai codec_dbg(codec, "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 28018a02c0ccSTakashi Iwai #define cx_auto_free snd_hda_gen_free 280208cf680cSDavid Henningsson 280334cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 2804f2e5731dSTakashi Iwai .build_controls = cx_auto_build_controls, 2805aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 2806ff359b14STakashi Iwai .init = cx_auto_init, 280708cf680cSDavid Henningsson .free = cx_auto_free, 280829adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 2809164a7adaSTakashi Iwai #ifdef CONFIG_PM 2810164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 2811164a7adaSTakashi Iwai #endif 2812f2e5731dSTakashi Iwai }; 2813f2e5731dSTakashi Iwai 2814e92d4b08STakashi Iwai /* 2815e92d4b08STakashi Iwai * pin fix-up 2816e92d4b08STakashi Iwai */ 281718dcd304SDavid Henningsson enum { 281818dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 2819d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 2820239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 2821239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 282218dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 2823239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 2824e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC_PIN, 2825e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC, 28264a437044STakashi Iwai CXT_FIXUP_GPIO1, 282708cf680cSDavid Henningsson CXT_FIXUP_THINKPAD_ACPI, 28283a00c660STakashi Iwai CXT_FIXUP_OLPC_XO, 2829ad7725d3STakashi Iwai CXT_FIXUP_CAP_MIX_AMP, 28306dcbadefSTakashi Iwai CXT_FIXUP_TOSHIBA_P105, 2831e5eac90dSTakashi Iwai CXT_FIXUP_HP_530, 2832ea30e7dfSTakashi Iwai CXT_FIXUP_CAP_MIX_AMP_5047, 283318dcd304SDavid Henningsson }; 283418dcd304SDavid Henningsson 2835b317b032STakashi Iwai /* for hda_fixup_thinkpad_acpi() */ 2836b317b032STakashi Iwai #include "thinkpad_helper.c" 283708cf680cSDavid Henningsson 283823d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 283923d30f28STakashi Iwai const struct hda_fixup *fix, int action) 2840e92d4b08STakashi Iwai { 284118dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 2842aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 2843e92d4b08STakashi Iwai } 2844e92d4b08STakashi Iwai 2845239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 2846239fb862SHuacai Chen const struct hda_fixup *fix, int action) 2847239fb862SHuacai Chen { 2848239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 2849239fb862SHuacai Chen return; 2850239fb862SHuacai Chen 2851239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 2852239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 2853239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 2854239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 2855239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 2856239fb862SHuacai Chen } 2857239fb862SHuacai Chen 2858e4c3bce2SDavid Henningsson static void cxt_update_headset_mode(struct hda_codec *codec) 2859e4c3bce2SDavid Henningsson { 2860e4c3bce2SDavid Henningsson /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ 2861e4c3bce2SDavid Henningsson int i; 2862e4c3bce2SDavid Henningsson bool mic_mode = false; 2863e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 2864e4c3bce2SDavid Henningsson struct auto_pin_cfg *cfg = &spec->gen.autocfg; 2865e4c3bce2SDavid Henningsson 2866e4c3bce2SDavid Henningsson hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; 2867e4c3bce2SDavid Henningsson 2868e4c3bce2SDavid Henningsson for (i = 0; i < cfg->num_inputs; i++) 2869e4c3bce2SDavid Henningsson if (cfg->inputs[i].pin == mux_pin) { 2870e4c3bce2SDavid Henningsson mic_mode = !!cfg->inputs[i].is_headphone_mic; 2871e4c3bce2SDavid Henningsson break; 2872e4c3bce2SDavid Henningsson } 2873e4c3bce2SDavid Henningsson 2874e4c3bce2SDavid Henningsson if (mic_mode) { 2875e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ 2876e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = false; 2877e4c3bce2SDavid Henningsson } else { 2878e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ 2879e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); 2880e4c3bce2SDavid Henningsson } 2881e4c3bce2SDavid Henningsson 2882e4c3bce2SDavid Henningsson snd_hda_gen_update_outputs(codec); 2883e4c3bce2SDavid Henningsson } 2884e4c3bce2SDavid Henningsson 2885e4c3bce2SDavid Henningsson static void cxt_update_headset_mode_hook(struct hda_codec *codec, 28867fe30711STakashi Iwai struct snd_kcontrol *kcontrol, 2887e4c3bce2SDavid Henningsson struct snd_ctl_elem_value *ucontrol) 2888e4c3bce2SDavid Henningsson { 2889e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 2890e4c3bce2SDavid Henningsson } 2891e4c3bce2SDavid Henningsson 2892e4c3bce2SDavid Henningsson static void cxt_fixup_headphone_mic(struct hda_codec *codec, 2893e4c3bce2SDavid Henningsson const struct hda_fixup *fix, int action) 2894e4c3bce2SDavid Henningsson { 2895e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 2896e4c3bce2SDavid Henningsson 2897e4c3bce2SDavid Henningsson switch (action) { 2898e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PRE_PROBE: 2899e4c3bce2SDavid Henningsson spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; 2900e4c3bce2SDavid Henningsson break; 2901e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PROBE: 2902e4c3bce2SDavid Henningsson spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; 2903e4c3bce2SDavid Henningsson spec->gen.automute_hook = cxt_update_headset_mode; 2904e4c3bce2SDavid Henningsson break; 2905e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_INIT: 2906e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 2907e4c3bce2SDavid Henningsson break; 2908e4c3bce2SDavid Henningsson } 2909e4c3bce2SDavid Henningsson } 2910e4c3bce2SDavid Henningsson 29113a00c660STakashi Iwai /* OPLC XO 1.5 fixup */ 29123a00c660STakashi Iwai 29133a00c660STakashi Iwai /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 29143a00c660STakashi Iwai * through the microphone jack. 29153a00c660STakashi Iwai * When the user enables this through a mixer switch, both internal and 29163a00c660STakashi Iwai * external microphones are disabled. Gain is fixed at 0dB. In this mode, 29173a00c660STakashi Iwai * we also allow the bias to be configured through a separate mixer 29183a00c660STakashi Iwai * control. */ 29193a00c660STakashi Iwai 29203a00c660STakashi Iwai #define update_mic_pin(codec, nid, val) \ 29213a00c660STakashi Iwai snd_hda_codec_update_cache(codec, nid, 0, \ 29223a00c660STakashi Iwai AC_VERB_SET_PIN_WIDGET_CONTROL, val) 29233a00c660STakashi Iwai 29243a00c660STakashi Iwai static const struct hda_input_mux olpc_xo_dc_bias = { 29253a00c660STakashi Iwai .num_items = 3, 29263a00c660STakashi Iwai .items = { 29273a00c660STakashi Iwai { "Off", PIN_IN }, 29283a00c660STakashi Iwai { "50%", PIN_VREF50 }, 29293a00c660STakashi Iwai { "80%", PIN_VREF80 }, 29303a00c660STakashi Iwai }, 29313a00c660STakashi Iwai }; 29323a00c660STakashi Iwai 29333a00c660STakashi Iwai static void olpc_xo_update_mic_boost(struct hda_codec *codec) 29343a00c660STakashi Iwai { 29353a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 29363a00c660STakashi Iwai int ch, val; 29373a00c660STakashi Iwai 29383a00c660STakashi Iwai for (ch = 0; ch < 2; ch++) { 29393a00c660STakashi Iwai val = AC_AMP_SET_OUTPUT | 29403a00c660STakashi Iwai (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT); 29413a00c660STakashi Iwai if (!spec->dc_enable) 29423a00c660STakashi Iwai val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0); 29433a00c660STakashi Iwai snd_hda_codec_write(codec, 0x17, 0, 29443a00c660STakashi Iwai AC_VERB_SET_AMP_GAIN_MUTE, val); 29453a00c660STakashi Iwai } 29463a00c660STakashi Iwai } 29473a00c660STakashi Iwai 29483a00c660STakashi Iwai static void olpc_xo_update_mic_pins(struct hda_codec *codec) 29493a00c660STakashi Iwai { 29503a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 29513a00c660STakashi Iwai int cur_input, val; 29523a00c660STakashi Iwai struct nid_path *path; 29533a00c660STakashi Iwai 29543a00c660STakashi Iwai cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]]; 29553a00c660STakashi Iwai 29563a00c660STakashi Iwai /* Set up mic pins for port-B, C and F dynamically as the recording 29573a00c660STakashi Iwai * LED is turned on/off by these pin controls 29583a00c660STakashi Iwai */ 29593a00c660STakashi Iwai if (!spec->dc_enable) { 29603a00c660STakashi Iwai /* disable DC bias path and pin for port F */ 29613a00c660STakashi Iwai update_mic_pin(codec, 0x1e, 0); 29623a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, false, false); 29633a00c660STakashi Iwai 29643a00c660STakashi Iwai /* update port B (ext mic) and C (int mic) */ 29653a00c660STakashi Iwai /* OLPC defers mic widget control until when capture is 29663a00c660STakashi Iwai * started because the microphone LED comes on as soon as 29673a00c660STakashi Iwai * these settings are put in place. if we did this before 29683a00c660STakashi Iwai * recording, it would give the false indication that 29693a00c660STakashi Iwai * recording is happening when it is not. 29703a00c660STakashi Iwai */ 29713a00c660STakashi Iwai update_mic_pin(codec, 0x1a, spec->recording ? 29723a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1a) : 0); 29733a00c660STakashi Iwai update_mic_pin(codec, 0x1b, spec->recording ? 29743a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1b) : 0); 29753a00c660STakashi Iwai /* enable normal mic path */ 29763a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 29773a00c660STakashi Iwai if (path) 29783a00c660STakashi Iwai snd_hda_activate_path(codec, path, true, false); 29793a00c660STakashi Iwai } else { 29803a00c660STakashi Iwai /* disable normal mic path */ 29813a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 29823a00c660STakashi Iwai if (path) 29833a00c660STakashi Iwai snd_hda_activate_path(codec, path, false, false); 29843a00c660STakashi Iwai 29853a00c660STakashi Iwai /* Even though port F is the DC input, the bias is controlled 29863a00c660STakashi Iwai * on port B. We also leave that port as an active input (but 29873a00c660STakashi Iwai * unselected) in DC mode just in case that is necessary to 29883a00c660STakashi Iwai * make the bias setting take effect. 29893a00c660STakashi Iwai */ 29903a00c660STakashi Iwai if (spec->recording) 29913a00c660STakashi Iwai val = olpc_xo_dc_bias.items[spec->dc_input_bias].index; 29923a00c660STakashi Iwai else 29933a00c660STakashi Iwai val = 0; 29943a00c660STakashi Iwai update_mic_pin(codec, 0x1a, val); 29953a00c660STakashi Iwai update_mic_pin(codec, 0x1b, 0); 29963a00c660STakashi Iwai /* enable DC bias path and pin */ 29973a00c660STakashi Iwai update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0); 29983a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, true, false); 29993a00c660STakashi Iwai } 30003a00c660STakashi Iwai } 30013a00c660STakashi Iwai 30023a00c660STakashi Iwai /* mic_autoswitch hook */ 30033a00c660STakashi Iwai static void olpc_xo_automic(struct hda_codec *codec, struct hda_jack_tbl *jack) 30043a00c660STakashi Iwai { 30053a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30063a00c660STakashi Iwai int saved_cached_write = codec->cached_write; 30073a00c660STakashi Iwai 30083a00c660STakashi Iwai codec->cached_write = 1; 30093a00c660STakashi Iwai /* in DC mode, we don't handle automic */ 30103a00c660STakashi Iwai if (!spec->dc_enable) 30113a00c660STakashi Iwai snd_hda_gen_mic_autoswitch(codec, jack); 30123a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30133a00c660STakashi Iwai snd_hda_codec_flush_cache(codec); 30143a00c660STakashi Iwai codec->cached_write = saved_cached_write; 30153a00c660STakashi Iwai if (spec->dc_enable) 30163a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 30173a00c660STakashi Iwai } 30183a00c660STakashi Iwai 30193a00c660STakashi Iwai /* pcm_capture hook */ 30203a00c660STakashi Iwai static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo, 30213a00c660STakashi Iwai struct hda_codec *codec, 30223a00c660STakashi Iwai struct snd_pcm_substream *substream, 30233a00c660STakashi Iwai int action) 30243a00c660STakashi Iwai { 30253a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30263a00c660STakashi Iwai 30273a00c660STakashi Iwai /* toggle spec->recording flag and update mic pins accordingly 30283a00c660STakashi Iwai * for turning on/off LED 30293a00c660STakashi Iwai */ 30303a00c660STakashi Iwai switch (action) { 30313a00c660STakashi Iwai case HDA_GEN_PCM_ACT_PREPARE: 30323a00c660STakashi Iwai spec->recording = 1; 30333a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30343a00c660STakashi Iwai break; 30353a00c660STakashi Iwai case HDA_GEN_PCM_ACT_CLEANUP: 30363a00c660STakashi Iwai spec->recording = 0; 30373a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30383a00c660STakashi Iwai break; 30393a00c660STakashi Iwai } 30403a00c660STakashi Iwai } 30413a00c660STakashi Iwai 30423a00c660STakashi Iwai static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol, 30433a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30443a00c660STakashi Iwai { 30453a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30463a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30473a00c660STakashi Iwai ucontrol->value.integer.value[0] = spec->dc_enable; 30483a00c660STakashi Iwai return 0; 30493a00c660STakashi Iwai } 30503a00c660STakashi Iwai 30513a00c660STakashi Iwai static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol, 30523a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30533a00c660STakashi Iwai { 30543a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30553a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30563a00c660STakashi Iwai int dc_enable = !!ucontrol->value.integer.value[0]; 30573a00c660STakashi Iwai 30583a00c660STakashi Iwai if (dc_enable == spec->dc_enable) 30593a00c660STakashi Iwai return 0; 30603a00c660STakashi Iwai 30613a00c660STakashi Iwai spec->dc_enable = dc_enable; 30623a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30633a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 30643a00c660STakashi Iwai return 1; 30653a00c660STakashi Iwai } 30663a00c660STakashi Iwai 30673a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 30683a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30693a00c660STakashi Iwai { 30703a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30713a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30723a00c660STakashi Iwai ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 30733a00c660STakashi Iwai return 0; 30743a00c660STakashi Iwai } 30753a00c660STakashi Iwai 30763a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 30773a00c660STakashi Iwai struct snd_ctl_elem_info *uinfo) 30783a00c660STakashi Iwai { 30793a00c660STakashi Iwai return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo); 30803a00c660STakashi Iwai } 30813a00c660STakashi Iwai 30823a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 30833a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 30843a00c660STakashi Iwai { 30853a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 30863a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 30873a00c660STakashi Iwai const struct hda_input_mux *imux = &olpc_xo_dc_bias; 30883a00c660STakashi Iwai unsigned int idx; 30893a00c660STakashi Iwai 30903a00c660STakashi Iwai idx = ucontrol->value.enumerated.item[0]; 30913a00c660STakashi Iwai if (idx >= imux->num_items) 30923a00c660STakashi Iwai idx = imux->num_items - 1; 30933a00c660STakashi Iwai if (spec->dc_input_bias == idx) 30943a00c660STakashi Iwai return 0; 30953a00c660STakashi Iwai 30963a00c660STakashi Iwai spec->dc_input_bias = idx; 30973a00c660STakashi Iwai if (spec->dc_enable) 30983a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 30993a00c660STakashi Iwai return 1; 31003a00c660STakashi Iwai } 31013a00c660STakashi Iwai 31023a00c660STakashi Iwai static const struct snd_kcontrol_new olpc_xo_mixers[] = { 31033a00c660STakashi Iwai { 31043a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 31053a00c660STakashi Iwai .name = "DC Mode Enable Switch", 31063a00c660STakashi Iwai .info = snd_ctl_boolean_mono_info, 31073a00c660STakashi Iwai .get = olpc_xo_dc_mode_get, 31083a00c660STakashi Iwai .put = olpc_xo_dc_mode_put, 31093a00c660STakashi Iwai }, 31103a00c660STakashi Iwai { 31113a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 31123a00c660STakashi Iwai .name = "DC Input Bias Enum", 31133a00c660STakashi Iwai .info = olpc_xo_dc_bias_enum_info, 31143a00c660STakashi Iwai .get = olpc_xo_dc_bias_enum_get, 31153a00c660STakashi Iwai .put = olpc_xo_dc_bias_enum_put, 31163a00c660STakashi Iwai }, 31173a00c660STakashi Iwai {} 31183a00c660STakashi Iwai }; 31193a00c660STakashi Iwai 31203a00c660STakashi Iwai /* overriding mic boost put callback; update mic boost volume only when 31213a00c660STakashi Iwai * DC mode is disabled 31223a00c660STakashi Iwai */ 31233a00c660STakashi Iwai static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol, 31243a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 31253a00c660STakashi Iwai { 31263a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 31273a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 31283a00c660STakashi Iwai int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); 31293a00c660STakashi Iwai if (ret > 0 && spec->dc_enable) 31303a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 31313a00c660STakashi Iwai return ret; 31323a00c660STakashi Iwai } 31333a00c660STakashi Iwai 31343a00c660STakashi Iwai static void cxt_fixup_olpc_xo(struct hda_codec *codec, 31353a00c660STakashi Iwai const struct hda_fixup *fix, int action) 31363a00c660STakashi Iwai { 31373a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 31383a00c660STakashi Iwai int i; 31393a00c660STakashi Iwai 31403a00c660STakashi Iwai if (action != HDA_FIXUP_ACT_PROBE) 31413a00c660STakashi Iwai return; 31423a00c660STakashi Iwai 31433a00c660STakashi Iwai spec->gen.mic_autoswitch_hook = olpc_xo_automic; 31443a00c660STakashi Iwai spec->gen.pcm_capture_hook = olpc_xo_capture_hook; 31453a00c660STakashi Iwai spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0); 31463a00c660STakashi Iwai 31473a00c660STakashi Iwai snd_hda_add_new_ctls(codec, olpc_xo_mixers); 31483a00c660STakashi Iwai 31493a00c660STakashi Iwai /* OLPC's microphone port is DC coupled for use with external sensors, 31503a00c660STakashi Iwai * therefore we use a 50% mic bias in order to center the input signal 31513a00c660STakashi Iwai * with the DC input range of the codec. 31523a00c660STakashi Iwai */ 31533a00c660STakashi Iwai snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50); 31543a00c660STakashi Iwai 31553a00c660STakashi Iwai /* override mic boost control */ 31563a00c660STakashi Iwai for (i = 0; i < spec->gen.kctls.used; i++) { 31573a00c660STakashi Iwai struct snd_kcontrol_new *kctl = 31583a00c660STakashi Iwai snd_array_elem(&spec->gen.kctls, i); 31593a00c660STakashi Iwai if (!strcmp(kctl->name, "Mic Boost Volume")) { 31603a00c660STakashi Iwai kctl->put = olpc_xo_mic_boost_put; 31613a00c660STakashi Iwai break; 31623a00c660STakashi Iwai } 31633a00c660STakashi Iwai } 31643a00c660STakashi Iwai } 31653a00c660STakashi Iwai 3166ad7725d3STakashi Iwai /* 3167ad7725d3STakashi Iwai * Fix max input level on mixer widget to 0dB 3168ad7725d3STakashi Iwai * (originally it has 0x2b steps with 0dB offset 0x14) 3169ad7725d3STakashi Iwai */ 3170ad7725d3STakashi Iwai static void cxt_fixup_cap_mix_amp(struct hda_codec *codec, 3171ad7725d3STakashi Iwai const struct hda_fixup *fix, int action) 3172ad7725d3STakashi Iwai { 3173ad7725d3STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 3174ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 3175ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3176ad7725d3STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3177ad7725d3STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 3178ad7725d3STakashi Iwai } 3179e4c3bce2SDavid Henningsson 3180ea30e7dfSTakashi Iwai /* 3181ea30e7dfSTakashi Iwai * Fix max input level on mixer widget to 0dB 3182ea30e7dfSTakashi Iwai * (originally it has 0x1e steps with 0 dB offset 0x17) 3183ea30e7dfSTakashi Iwai */ 3184ea30e7dfSTakashi Iwai static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec, 3185ea30e7dfSTakashi Iwai const struct hda_fixup *fix, int action) 3186ea30e7dfSTakashi Iwai { 3187ea30e7dfSTakashi Iwai snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 3188ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 3189ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 3190ea30e7dfSTakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 3191ea30e7dfSTakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 3192ea30e7dfSTakashi Iwai } 3193ea30e7dfSTakashi Iwai 3194d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 319523d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3196e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 3197e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 3198e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 31993e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 3200e92d4b08STakashi Iwai {} 3201e92d4b08STakashi Iwai }; 3202e92d4b08STakashi Iwai 3203d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 320423d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 3205d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 3206d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 3207d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 3208d70f3632STakashi Iwai {} 3209e92d4b08STakashi Iwai }; 3210e92d4b08STakashi Iwai 3211239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 3212239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 3213239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 3214239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 3215239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 3216239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 3217239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 3218239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 3219239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 3220239fb862SHuacai Chen {} 3221239fb862SHuacai Chen }; 3222239fb862SHuacai Chen 322323d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 322423d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 322523d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 322623d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 322723d30f28STakashi Iwai }, 322823d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 322923d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 323023d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 323108cf680cSDavid Henningsson .chained = true, 323208cf680cSDavid Henningsson .chain_id = CXT_FIXUP_THINKPAD_ACPI, 323323d30f28STakashi Iwai }, 3234239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 3235239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3236239fb862SHuacai Chen .chained = true, 3237239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 3238239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3239239fb862SHuacai Chen }, 3240239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 3241239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 3242239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 3243239fb862SHuacai Chen }, 324423d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 324523d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 324623d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 324723d30f28STakashi Iwai }, 3248239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 3249239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 3250239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 3251239fb862SHuacai Chen }, 3252e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC_PIN] = { 3253e4c3bce2SDavid Henningsson .type = HDA_FIXUP_PINS, 3254e4c3bce2SDavid Henningsson .chained = true, 3255e4c3bce2SDavid Henningsson .chain_id = CXT_FIXUP_HEADPHONE_MIC, 3256e4c3bce2SDavid Henningsson .v.pins = (const struct hda_pintbl[]) { 3257e4c3bce2SDavid Henningsson { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ 3258e4c3bce2SDavid Henningsson { } 3259e4c3bce2SDavid Henningsson } 3260e4c3bce2SDavid Henningsson }, 3261e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC] = { 3262e4c3bce2SDavid Henningsson .type = HDA_FIXUP_FUNC, 3263e4c3bce2SDavid Henningsson .v.func = cxt_fixup_headphone_mic, 3264e4c3bce2SDavid Henningsson }, 32654a437044STakashi Iwai [CXT_FIXUP_GPIO1] = { 32664a437044STakashi Iwai .type = HDA_FIXUP_VERBS, 32674a437044STakashi Iwai .v.verbs = (const struct hda_verb[]) { 32684a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, 32694a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, 32704a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, 32714a437044STakashi Iwai { } 32724a437044STakashi Iwai }, 32734a437044STakashi Iwai }, 327408cf680cSDavid Henningsson [CXT_FIXUP_THINKPAD_ACPI] = { 327508cf680cSDavid Henningsson .type = HDA_FIXUP_FUNC, 3276b317b032STakashi Iwai .v.func = hda_fixup_thinkpad_acpi, 327708cf680cSDavid Henningsson }, 32783a00c660STakashi Iwai [CXT_FIXUP_OLPC_XO] = { 32793a00c660STakashi Iwai .type = HDA_FIXUP_FUNC, 32803a00c660STakashi Iwai .v.func = cxt_fixup_olpc_xo, 32813a00c660STakashi Iwai }, 3282ad7725d3STakashi Iwai [CXT_FIXUP_CAP_MIX_AMP] = { 3283ad7725d3STakashi Iwai .type = HDA_FIXUP_FUNC, 3284ad7725d3STakashi Iwai .v.func = cxt_fixup_cap_mix_amp, 3285ad7725d3STakashi Iwai }, 32866dcbadefSTakashi Iwai [CXT_FIXUP_TOSHIBA_P105] = { 32876dcbadefSTakashi Iwai .type = HDA_FIXUP_PINS, 32886dcbadefSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 32896dcbadefSTakashi Iwai { 0x10, 0x961701f0 }, /* speaker/hp */ 32906dcbadefSTakashi Iwai { 0x12, 0x02a1901e }, /* ext mic */ 32916dcbadefSTakashi Iwai { 0x14, 0x95a70110 }, /* int mic */ 32926dcbadefSTakashi Iwai {} 32936dcbadefSTakashi Iwai }, 32946dcbadefSTakashi Iwai }, 3295e5eac90dSTakashi Iwai [CXT_FIXUP_HP_530] = { 3296e5eac90dSTakashi Iwai .type = HDA_FIXUP_PINS, 3297e5eac90dSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 3298e5eac90dSTakashi Iwai { 0x12, 0x90a60160 }, /* int mic */ 3299e5eac90dSTakashi Iwai {} 3300e5eac90dSTakashi Iwai }, 3301e5eac90dSTakashi Iwai .chained = true, 3302e5eac90dSTakashi Iwai .chain_id = CXT_FIXUP_CAP_MIX_AMP, 3303e5eac90dSTakashi Iwai }, 3304ea30e7dfSTakashi Iwai [CXT_FIXUP_CAP_MIX_AMP_5047] = { 3305ea30e7dfSTakashi Iwai .type = HDA_FIXUP_FUNC, 3306ea30e7dfSTakashi Iwai .v.func = cxt_fixup_cap_mix_amp_5047, 3307ea30e7dfSTakashi Iwai }, 3308ad7725d3STakashi Iwai }; 3309ad7725d3STakashi Iwai 3310ad7725d3STakashi Iwai static const struct snd_pci_quirk cxt5045_fixups[] = { 3311e5eac90dSTakashi Iwai SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530), 33126dcbadefSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105), 3313ad7725d3STakashi Iwai /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 3314ad7725d3STakashi Iwai * really bad sound over 0dB on NID 0x17. 3315ad7725d3STakashi Iwai */ 3316ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP), 3317ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP), 3318ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP), 3319ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP), 3320ad7725d3STakashi Iwai {} 3321ad7725d3STakashi Iwai }; 3322ad7725d3STakashi Iwai 3323ad7725d3STakashi Iwai static const struct hda_model_fixup cxt5045_fixup_models[] = { 3324ad7725d3STakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" }, 33256dcbadefSTakashi Iwai { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" }, 3326e5eac90dSTakashi Iwai { .id = CXT_FIXUP_HP_530, .name = "hp-530" }, 3327ad7725d3STakashi Iwai {} 3328e92d4b08STakashi Iwai }; 3329e92d4b08STakashi Iwai 3330ea30e7dfSTakashi Iwai static const struct snd_pci_quirk cxt5047_fixups[] = { 3331ea30e7dfSTakashi Iwai /* HP laptops have really bad sound over 0 dB on NID 0x10. 3332ea30e7dfSTakashi Iwai */ 3333ea30e7dfSTakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047), 3334ea30e7dfSTakashi Iwai {} 3335ea30e7dfSTakashi Iwai }; 3336ea30e7dfSTakashi Iwai 3337ea30e7dfSTakashi Iwai static const struct hda_model_fixup cxt5047_fixup_models[] = { 3338ea30e7dfSTakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" }, 3339ea30e7dfSTakashi Iwai {} 3340ea30e7dfSTakashi Iwai }; 3341ea30e7dfSTakashi Iwai 3342d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 3343e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 3344e92d4b08STakashi Iwai {} 3345e92d4b08STakashi Iwai }; 3346e92d4b08STakashi Iwai 3347a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5051_fixup_models[] = { 3348a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" }, 3349a2dd933dSTakashi Iwai {} 3350a2dd933dSTakashi Iwai }; 3351a2dd933dSTakashi Iwai 3352d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 335363a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 33544a437044STakashi Iwai SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), 3355e4c3bce2SDavid Henningsson SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), 33563a00c660STakashi Iwai SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO), 3357d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3358d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3359d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3360d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 3361d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 3362a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 336388d57606SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), 336418dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 3365e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 3366b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 33672fd3f170SHui Wang SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), 3368239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 3369239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 3370f2e5731dSTakashi Iwai {} 3371f2e5731dSTakashi Iwai }; 3372f2e5731dSTakashi Iwai 3373a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5066_fixup_models[] = { 3374a2dd933dSTakashi Iwai { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" }, 3375a2dd933dSTakashi Iwai { .id = CXT_FIXUP_GPIO1, .name = "gpio1" }, 3376a2dd933dSTakashi Iwai { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" }, 3377a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" }, 3378a2dd933dSTakashi Iwai { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" }, 3379a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" }, 33803a00c660STakashi Iwai { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" }, 3381a2dd933dSTakashi Iwai {} 3382a2dd933dSTakashi Iwai }; 3383a2dd933dSTakashi Iwai 33843868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 33853868137eSTakashi Iwai * can be created (bko#42825) 33863868137eSTakashi Iwai */ 33873868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 33883868137eSTakashi Iwai { 33893868137eSTakashi Iwai static hda_nid_t out_nids[] = { 33903868137eSTakashi Iwai 0x10, 0x11, 0 33913868137eSTakashi Iwai }; 33923868137eSTakashi Iwai hda_nid_t *p; 33933868137eSTakashi Iwai 33943868137eSTakashi Iwai for (p = out_nids; *p; p++) 33953868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 33963868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 33973868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 33983868137eSTakashi Iwai } 33993868137eSTakashi Iwai 3400f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 3401f2e5731dSTakashi Iwai { 3402f2e5731dSTakashi Iwai struct conexant_spec *spec; 3403f2e5731dSTakashi Iwai int err; 3404f2e5731dSTakashi Iwai 3405*4e76a883STakashi Iwai codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name); 34061f8458a2STakashi Iwai 3407f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3408f2e5731dSTakashi Iwai if (!spec) 3409f2e5731dSTakashi Iwai return -ENOMEM; 3410aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 3411f2e5731dSTakashi Iwai codec->spec = spec; 3412e92d4b08STakashi Iwai 3413aed523f1STakashi Iwai cx_auto_parse_beep(codec); 3414aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 3415ff359b14STakashi Iwai spec->gen.own_eapd_ctl = 1; 3416ff359b14STakashi Iwai if (spec->dynamic_eapd) 3417aed523f1STakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 3418e92d4b08STakashi Iwai 34196b452142STakashi Iwai switch (codec->vendor_id) { 34206b452142STakashi Iwai case 0x14f15045: 34214f32456eSMichael Karcher codec->single_adc_amp = 1; 342270540e24STakashi Iwai spec->gen.mixer_nid = 0x17; 3423d50ce6c0STakashi Iwai spec->gen.add_stereo_mix_input = 1; 3424ad7725d3STakashi Iwai snd_hda_pick_fixup(codec, cxt5045_fixup_models, 3425ad7725d3STakashi Iwai cxt5045_fixups, cxt_fixups); 34266b452142STakashi Iwai break; 3427164a7adaSTakashi Iwai case 0x14f15047: 3428164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 3429164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 3430d50ce6c0STakashi Iwai spec->gen.add_stereo_mix_input = 1; 3431ea30e7dfSTakashi Iwai snd_hda_pick_fixup(codec, cxt5047_fixup_models, 3432ea30e7dfSTakashi Iwai cxt5047_fixups, cxt_fixups); 3433164a7adaSTakashi Iwai break; 34343868137eSTakashi Iwai case 0x14f15051: 34353868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 343651969d62SMichael Karcher codec->pin_amp_workaround = 1; 3437a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5051_fixup_models, 3438a2dd933dSTakashi Iwai cxt5051_fixups, cxt_fixups); 34393868137eSTakashi Iwai break; 344051969d62SMichael Karcher default: 344151969d62SMichael Karcher codec->pin_amp_workaround = 1; 3442a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5066_fixup_models, 3443a2dd933dSTakashi Iwai cxt5066_fixups, cxt_fixups); 344423d30f28STakashi Iwai break; 34456b452142STakashi Iwai } 34466b452142STakashi Iwai 3447f29735cbSTakashi Iwai /* Show mute-led control only on HP laptops 3448f29735cbSTakashi Iwai * This is a sort of white-list: on HP laptops, EAPD corresponds 3449f29735cbSTakashi Iwai * only to the mute-LED without actualy amp function. Meanwhile, 3450f29735cbSTakashi Iwai * others may use EAPD really as an amp switch, so it might be 3451f29735cbSTakashi Iwai * not good to expose it blindly. 3452527c73baSTakashi Iwai */ 3453f29735cbSTakashi Iwai switch (codec->subsystem_id >> 16) { 3454f29735cbSTakashi Iwai case 0x103c: 3455aed523f1STakashi Iwai spec->gen.vmaster_mute_enum = 1; 3456f29735cbSTakashi Iwai break; 3457f29735cbSTakashi Iwai } 3458527c73baSTakashi Iwai 3459aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 3460aed523f1STakashi Iwai 3461e4c3bce2SDavid Henningsson err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 3462e4c3bce2SDavid Henningsson spec->parse_flags); 346322ce5f74STakashi Iwai if (err < 0) 3464aed523f1STakashi Iwai goto error; 3465aed523f1STakashi Iwai 3466aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 3467aed523f1STakashi Iwai if (err < 0) 3468aed523f1STakashi Iwai goto error; 3469aed523f1STakashi Iwai 3470f2e5731dSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 34714f2864a4STakashi Iwai 34724f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 34734f2864a4STakashi Iwai * which falls into the single-cmd mode. 34744f2864a4STakashi Iwai * Better to make reset, then. 34754f2864a4STakashi Iwai */ 34764f2864a4STakashi Iwai if (!codec->bus->sync_write) { 3477*4e76a883STakashi Iwai codec_info(codec, 34784f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 34794f2864a4STakashi Iwai codec->bus->sync_write = 1; 34804f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 34814f2864a4STakashi Iwai } 34824f2864a4STakashi Iwai 3483e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 3484e4c3bce2SDavid Henningsson 3485f2e5731dSTakashi Iwai return 0; 3486aed523f1STakashi Iwai 3487aed523f1STakashi Iwai error: 348808cf680cSDavid Henningsson cx_auto_free(codec); 3489aed523f1STakashi Iwai return err; 3490f2e5731dSTakashi Iwai } 3491f2e5731dSTakashi Iwai 3492bf92d1d5STakashi Iwai #ifndef ENABLE_CXT_STATIC_QUIRKS 3493bf92d1d5STakashi Iwai #define patch_cxt5045 patch_conexant_auto 3494bf92d1d5STakashi Iwai #define patch_cxt5047 patch_conexant_auto 3495bf92d1d5STakashi Iwai #define patch_cxt5051 patch_conexant_auto 3496bf92d1d5STakashi Iwai #define patch_cxt5066 patch_conexant_auto 3497bf92d1d5STakashi Iwai #endif 3498bf92d1d5STakashi Iwai 3499f2e5731dSTakashi Iwai /* 3500461e2c78STakashi Iwai */ 3501461e2c78STakashi Iwai 350234cbe3a6STakashi Iwai static const struct hda_codec_preset snd_hda_preset_conexant[] = { 350382f30040STobin Davis { .id = 0x14f15045, .name = "CX20549 (Venice)", 350482f30040STobin Davis .patch = patch_cxt5045 }, 350582f30040STobin Davis { .id = 0x14f15047, .name = "CX20551 (Waikiki)", 350682f30040STobin Davis .patch = patch_cxt5047 }, 3507461e2c78STakashi Iwai { .id = 0x14f15051, .name = "CX20561 (Hermosa)", 3508461e2c78STakashi Iwai .patch = patch_cxt5051 }, 35090fb67e98SDaniel Drake { .id = 0x14f15066, .name = "CX20582 (Pebble)", 35100fb67e98SDaniel Drake .patch = patch_cxt5066 }, 351195a618bdSEinar Rünkaru { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", 351295a618bdSEinar Rünkaru .patch = patch_cxt5066 }, 3513850eab9dSTakashi Iwai { .id = 0x14f15068, .name = "CX20584", 3514850eab9dSTakashi Iwai .patch = patch_cxt5066 }, 35157b2bfdbcSJens Taprogge { .id = 0x14f15069, .name = "CX20585", 35167b2bfdbcSJens Taprogge .patch = patch_cxt5066 }, 3517f0ca89b0SDavid Henningsson { .id = 0x14f1506c, .name = "CX20588", 3518f0ca89b0SDavid Henningsson .patch = patch_cxt5066 }, 35196da8b516SDavid Henningsson { .id = 0x14f1506e, .name = "CX20590", 35206da8b516SDavid Henningsson .patch = patch_cxt5066 }, 3521f2e5731dSTakashi Iwai { .id = 0x14f15097, .name = "CX20631", 3522f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3523f2e5731dSTakashi Iwai { .id = 0x14f15098, .name = "CX20632", 3524f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3525f2e5731dSTakashi Iwai { .id = 0x14f150a1, .name = "CX20641", 3526f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3527f2e5731dSTakashi Iwai { .id = 0x14f150a2, .name = "CX20642", 3528f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3529f2e5731dSTakashi Iwai { .id = 0x14f150ab, .name = "CX20651", 3530f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3531f2e5731dSTakashi Iwai { .id = 0x14f150ac, .name = "CX20652", 3532f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3533f2e5731dSTakashi Iwai { .id = 0x14f150b8, .name = "CX20664", 3534f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 3535f2e5731dSTakashi Iwai { .id = 0x14f150b9, .name = "CX20665", 3536f2e5731dSTakashi Iwai .patch = patch_conexant_auto }, 35372d825fd8STakashi Iwai { .id = 0x14f1510f, .name = "CX20751/2", 35382d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35392d825fd8STakashi Iwai { .id = 0x14f15110, .name = "CX20751/2", 35402d825fd8STakashi Iwai .patch = patch_conexant_auto }, 35412d825fd8STakashi Iwai { .id = 0x14f15111, .name = "CX20753/4", 35422d825fd8STakashi Iwai .patch = patch_conexant_auto }, 354342c364acSTakashi Iwai { .id = 0x14f15113, .name = "CX20755", 354442c364acSTakashi Iwai .patch = patch_conexant_auto }, 354542c364acSTakashi Iwai { .id = 0x14f15114, .name = "CX20756", 354642c364acSTakashi Iwai .patch = patch_conexant_auto }, 354742c364acSTakashi Iwai { .id = 0x14f15115, .name = "CX20757", 354842c364acSTakashi Iwai .patch = patch_conexant_auto }, 35498f42d769STakashi Iwai { .id = 0x14f151d7, .name = "CX20952", 35508f42d769STakashi Iwai .patch = patch_conexant_auto }, 3551c9b443d4STobin Davis {} /* terminator */ 3552c9b443d4STobin Davis }; 35531289e9e8STakashi Iwai 35541289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15045"); 35551289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15047"); 35561289e9e8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15051"); 35570fb67e98SDaniel Drake MODULE_ALIAS("snd-hda-codec-id:14f15066"); 355895a618bdSEinar Rünkaru MODULE_ALIAS("snd-hda-codec-id:14f15067"); 3559850eab9dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15068"); 35607b2bfdbcSJens Taprogge MODULE_ALIAS("snd-hda-codec-id:14f15069"); 3561f0ca89b0SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506c"); 35626da8b516SDavid Henningsson MODULE_ALIAS("snd-hda-codec-id:14f1506e"); 3563f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15097"); 3564f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15098"); 3565f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a1"); 3566f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150a2"); 3567f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ab"); 3568f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150ac"); 3569f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b8"); 3570f2e5731dSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f150b9"); 35712d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f1510f"); 35722d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15110"); 35732d825fd8STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15111"); 357442c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15113"); 357542c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15114"); 357642c364acSTakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f15115"); 35778f42d769STakashi Iwai MODULE_ALIAS("snd-hda-codec-id:14f151d7"); 35781289e9e8STakashi Iwai 35791289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 35801289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 35811289e9e8STakashi Iwai 35821289e9e8STakashi Iwai static struct hda_codec_preset_list conexant_list = { 35831289e9e8STakashi Iwai .preset = snd_hda_preset_conexant, 35841289e9e8STakashi Iwai .owner = THIS_MODULE, 35851289e9e8STakashi Iwai }; 35861289e9e8STakashi Iwai 35871289e9e8STakashi Iwai static int __init patch_conexant_init(void) 35881289e9e8STakashi Iwai { 35891289e9e8STakashi Iwai return snd_hda_add_codec_preset(&conexant_list); 35901289e9e8STakashi Iwai } 35911289e9e8STakashi Iwai 35921289e9e8STakashi Iwai static void __exit patch_conexant_exit(void) 35931289e9e8STakashi Iwai { 35941289e9e8STakashi Iwai snd_hda_delete_codec_preset(&conexant_list); 35951289e9e8STakashi Iwai } 35961289e9e8STakashi Iwai 35971289e9e8STakashi Iwai module_init(patch_conexant_init) 35981289e9e8STakashi Iwai module_exit(patch_conexant_exit) 3599