1d0fa1179SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2c9b443d4STobin Davis /* 3c9b443d4STobin Davis * HD audio interface patch for Conexant HDA audio codec 4c9b443d4STobin Davis * 5c9b443d4STobin Davis * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com> 6c9b443d4STobin Davis * Takashi Iwai <tiwai@suse.de> 7c9b443d4STobin Davis * Tobin Davis <tdavis@dsl-only.net> 8c9b443d4STobin Davis */ 9c9b443d4STobin Davis 10c9b443d4STobin Davis #include <linux/init.h> 11c9b443d4STobin Davis #include <linux/delay.h> 12c9b443d4STobin Davis #include <linux/slab.h> 13da155d5bSPaul Gortmaker #include <linux/module.h> 14c9b443d4STobin Davis #include <sound/core.h> 15bc7a166dSUlrich Dangel #include <sound/jack.h> 16bc7a166dSUlrich Dangel 17be57bfffSPierre-Louis Bossart #include <sound/hda_codec.h> 18c9b443d4STobin Davis #include "hda_local.h" 1923d30f28STakashi Iwai #include "hda_auto_parser.h" 20c0f8faf0SEinar Rünkaru #include "hda_beep.h" 211835a0f9STakashi Iwai #include "hda_jack.h" 22aed523f1STakashi Iwai #include "hda_generic.h" 23c9b443d4STobin Davis 24c9b443d4STobin Davis struct conexant_spec { 2523d30f28STakashi Iwai struct hda_gen_spec gen; 26c9b443d4STobin Davis 27bf92d1d5STakashi Iwai /* extra EAPD pins */ 28bf92d1d5STakashi Iwai unsigned int num_eapds; 29bf92d1d5STakashi Iwai hda_nid_t eapds[4]; 30ff359b14STakashi Iwai bool dynamic_eapd; 313542aed7STakashi Iwai hda_nid_t mute_led_eapd; 32bf92d1d5STakashi Iwai 33e4c3bce2SDavid Henningsson unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 34e4c3bce2SDavid Henningsson 353a00c660STakashi Iwai /* OPLC XO specific */ 363a00c660STakashi Iwai bool recording; 373a00c660STakashi Iwai bool dc_enable; 383a00c660STakashi Iwai unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */ 393a00c660STakashi Iwai struct nid_path *dc_mode_path; 405cd5b1bdSJerónimo Borque 415cd5b1bdSJerónimo Borque int mute_led_polarity; 425cd5b1bdSJerónimo Borque unsigned int gpio_led; 435cd5b1bdSJerónimo Borque unsigned int gpio_mute_led_mask; 445cd5b1bdSJerónimo Borque unsigned int gpio_mic_led_mask; 455cd5b1bdSJerónimo Borque 46c9b443d4STobin Davis }; 47c9b443d4STobin Davis 48bf92d1d5STakashi Iwai 49bf92d1d5STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP 5051e19ca5STakashi Iwai /* additional beep mixers; private_value will be overwritten */ 51bf92d1d5STakashi Iwai static const struct snd_kcontrol_new cxt_beep_mixer[] = { 52bf92d1d5STakashi Iwai HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), 53bf92d1d5STakashi Iwai HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), 54bf92d1d5STakashi Iwai }; 55bf92d1d5STakashi Iwai 5651e19ca5STakashi Iwai static int set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, 5751e19ca5STakashi Iwai int idx, int dir) 58bf92d1d5STakashi Iwai { 5951e19ca5STakashi Iwai struct snd_kcontrol_new *knew; 6051e19ca5STakashi Iwai unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); 6151e19ca5STakashi Iwai int i; 62bf92d1d5STakashi Iwai 6351e19ca5STakashi Iwai spec->gen.beep_nid = nid; 6451e19ca5STakashi Iwai for (i = 0; i < ARRAY_SIZE(cxt_beep_mixer); i++) { 6551e19ca5STakashi Iwai knew = snd_hda_gen_add_kctl(&spec->gen, NULL, 6651e19ca5STakashi Iwai &cxt_beep_mixer[i]); 6751e19ca5STakashi Iwai if (!knew) 68bf92d1d5STakashi Iwai return -ENOMEM; 6951e19ca5STakashi Iwai knew->private_value = beep_amp; 70bf92d1d5STakashi Iwai } 71bf92d1d5STakashi Iwai return 0; 72bf92d1d5STakashi Iwai } 73bf92d1d5STakashi Iwai 7451e19ca5STakashi Iwai static int cx_auto_parse_beep(struct hda_codec *codec) 75f2e5731dSTakashi Iwai { 76f2e5731dSTakashi Iwai struct conexant_spec *spec = codec->spec; 777639a06cSTakashi Iwai hda_nid_t nid; 78f2e5731dSTakashi Iwai 797639a06cSTakashi Iwai for_each_hda_codec_node(nid, codec) 8051e19ca5STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) 8151e19ca5STakashi Iwai return set_beep_amp(spec, nid, 0, HDA_OUTPUT); 8251e19ca5STakashi Iwai return 0; 83f2e5731dSTakashi Iwai } 84f2e5731dSTakashi Iwai #else 8551e19ca5STakashi Iwai #define cx_auto_parse_beep(codec) 0 86f2e5731dSTakashi Iwai #endif 87f2e5731dSTakashi Iwai 8851e19ca5STakashi Iwai /* 8951e19ca5STakashi Iwai * Automatic parser for CX20641 & co 9051e19ca5STakashi Iwai */ 9151e19ca5STakashi Iwai 92254f2968STakashi Iwai /* parse EAPDs */ 9319110595STakashi Iwai static void cx_auto_parse_eapd(struct hda_codec *codec) 9419110595STakashi Iwai { 9519110595STakashi Iwai struct conexant_spec *spec = codec->spec; 967639a06cSTakashi Iwai hda_nid_t nid; 9719110595STakashi Iwai 987639a06cSTakashi Iwai for_each_hda_codec_node(nid, codec) { 9919110595STakashi Iwai if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 10019110595STakashi Iwai continue; 10119110595STakashi Iwai if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) 10219110595STakashi Iwai continue; 10319110595STakashi Iwai spec->eapds[spec->num_eapds++] = nid; 10419110595STakashi Iwai if (spec->num_eapds >= ARRAY_SIZE(spec->eapds)) 10519110595STakashi Iwai break; 10619110595STakashi Iwai } 107254f2968STakashi Iwai 108254f2968STakashi Iwai /* NOTE: below is a wild guess; if we have more than two EAPDs, 109254f2968STakashi Iwai * it's a new chip, where EAPDs are supposed to be associated to 110254f2968STakashi Iwai * pins, and we can control EAPD per pin. 111254f2968STakashi Iwai * OTOH, if only one or two EAPDs are found, it's an old chip, 112254f2968STakashi Iwai * thus it might control over all pins. 113254f2968STakashi Iwai */ 114aed523f1STakashi Iwai if (spec->num_eapds > 2) 115ff359b14STakashi Iwai spec->dynamic_eapd = 1; 116f2e5731dSTakashi Iwai } 117f2e5731dSTakashi Iwai 118da339866STakashi Iwai static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, 119caf3c043SMichał Mirosław const hda_nid_t *pins, bool on) 120f2e5731dSTakashi Iwai { 121f2e5731dSTakashi Iwai int i; 122f2e5731dSTakashi Iwai for (i = 0; i < num_pins; i++) { 123f2e5731dSTakashi Iwai if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) 124f2e5731dSTakashi Iwai snd_hda_codec_write(codec, pins[i], 0, 125da339866STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 126da339866STakashi Iwai on ? 0x02 : 0); 127f2e5731dSTakashi Iwai } 128f2e5731dSTakashi Iwai } 129f2e5731dSTakashi Iwai 130527c73baSTakashi Iwai /* turn on/off EAPD according to Master switch */ 131527c73baSTakashi Iwai static void cx_auto_vmaster_hook(void *private_data, int enabled) 132527c73baSTakashi Iwai { 133527c73baSTakashi Iwai struct hda_codec *codec = private_data; 134527c73baSTakashi Iwai struct conexant_spec *spec = codec->spec; 135527c73baSTakashi Iwai 136527c73baSTakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 137527c73baSTakashi Iwai } 138527c73baSTakashi Iwai 1393542aed7STakashi Iwai /* turn on/off EAPD according to Master switch (inversely!) for mute LED */ 140929f718cSTakashi Iwai static int cx_auto_vmaster_mute_led(struct led_classdev *led_cdev, 141929f718cSTakashi Iwai enum led_brightness brightness) 1423542aed7STakashi Iwai { 143929f718cSTakashi Iwai struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); 1443542aed7STakashi Iwai struct conexant_spec *spec = codec->spec; 1453542aed7STakashi Iwai 1463542aed7STakashi Iwai snd_hda_codec_write(codec, spec->mute_led_eapd, 0, 1473542aed7STakashi Iwai AC_VERB_SET_EAPD_BTLENABLE, 148929f718cSTakashi Iwai brightness ? 0x02 : 0x00); 149929f718cSTakashi Iwai return 0; 1503542aed7STakashi Iwai } 1513542aed7STakashi Iwai 152ff359b14STakashi Iwai static int cx_auto_init(struct hda_codec *codec) 153ff359b14STakashi Iwai { 154ff359b14STakashi Iwai struct conexant_spec *spec = codec->spec; 155ff359b14STakashi Iwai snd_hda_gen_init(codec); 156ff359b14STakashi Iwai if (!spec->dynamic_eapd) 157ff359b14STakashi Iwai cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true); 158e4c3bce2SDavid Henningsson 159e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); 160e4c3bce2SDavid Henningsson 161ff359b14STakashi Iwai return 0; 162ff359b14STakashi Iwai } 163ff359b14STakashi Iwai 164f6b28e4dSDavid Henningsson static void cx_auto_reboot_notify(struct hda_codec *codec) 165f6b28e4dSDavid Henningsson { 166f6b28e4dSDavid Henningsson struct conexant_spec *spec = codec->spec; 167f6b28e4dSDavid Henningsson 168d77a4b4aSPark Ju Hyung /* Turn the problematic codec into D3 to avoid spurious noises 169f6b28e4dSDavid Henningsson from the internal speaker during (and after) reboot */ 170f6b28e4dSDavid Henningsson cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false); 171871b9066SHui Wang snd_hda_gen_reboot_notify(codec); 172f6b28e4dSDavid Henningsson } 173f6b28e4dSDavid Henningsson 174f6b28e4dSDavid Henningsson static void cx_auto_free(struct hda_codec *codec) 175f6b28e4dSDavid Henningsson { 176f6b28e4dSDavid Henningsson cx_auto_reboot_notify(codec); 177f6b28e4dSDavid Henningsson snd_hda_gen_free(codec); 178f6b28e4dSDavid Henningsson } 17908cf680cSDavid Henningsson 18034cbe3a6STakashi Iwai static const struct hda_codec_ops cx_auto_patch_ops = { 18151e19ca5STakashi Iwai .build_controls = snd_hda_gen_build_controls, 182aed523f1STakashi Iwai .build_pcms = snd_hda_gen_build_pcms, 183ff359b14STakashi Iwai .init = cx_auto_init, 184f6b28e4dSDavid Henningsson .reboot_notify = cx_auto_reboot_notify, 18508cf680cSDavid Henningsson .free = cx_auto_free, 18629adc4b9SDavid Henningsson .unsol_event = snd_hda_jack_unsol_event, 187164a7adaSTakashi Iwai #ifdef CONFIG_PM 188164a7adaSTakashi Iwai .check_power_status = snd_hda_gen_check_power_status, 189164a7adaSTakashi Iwai #endif 190f2e5731dSTakashi Iwai }; 191f2e5731dSTakashi Iwai 192e92d4b08STakashi Iwai /* 193e92d4b08STakashi Iwai * pin fix-up 194e92d4b08STakashi Iwai */ 19518dcd304SDavid Henningsson enum { 19618dcd304SDavid Henningsson CXT_PINCFG_LENOVO_X200, 197d3980110STakashi Iwai CXT_PINCFG_LENOVO_TP410, 198239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1004, 199239fb862SHuacai Chen CXT_PINCFG_LEMOTE_A1205, 200ddb6ca75STakashi Iwai CXT_PINCFG_COMPAQ_CQ60, 20118dcd304SDavid Henningsson CXT_FIXUP_STEREO_DMIC, 202239fb862SHuacai Chen CXT_FIXUP_INC_MIC_BOOST, 203e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC_PIN, 204e4c3bce2SDavid Henningsson CXT_FIXUP_HEADPHONE_MIC, 2054a437044STakashi Iwai CXT_FIXUP_GPIO1, 206ff50479aSTakashi Iwai CXT_FIXUP_ASPIRE_DMIC, 20708cf680cSDavid Henningsson CXT_FIXUP_THINKPAD_ACPI, 2083a00c660STakashi Iwai CXT_FIXUP_OLPC_XO, 209ad7725d3STakashi Iwai CXT_FIXUP_CAP_MIX_AMP, 2106dcbadefSTakashi Iwai CXT_FIXUP_TOSHIBA_P105, 211e5eac90dSTakashi Iwai CXT_FIXUP_HP_530, 212ea30e7dfSTakashi Iwai CXT_FIXUP_CAP_MIX_AMP_5047, 2133542aed7STakashi Iwai CXT_FIXUP_MUTE_LED_EAPD, 214cc3a47a2SJaroslav Kysela CXT_FIXUP_HP_DOCK, 2150eec8809STakashi Iwai CXT_FIXUP_HP_SPECTRE, 216f73cd43aSTakashi Iwai CXT_FIXUP_HP_GATE_MIC, 2175cd5b1bdSJerónimo Borque CXT_FIXUP_MUTE_LED_GPIO, 218322f74edSHui Wang CXT_FIXUP_HEADSET_MIC, 219322f74edSHui Wang CXT_FIXUP_HP_MIC_NO_PRESENCE, 22018dcd304SDavid Henningsson }; 22118dcd304SDavid Henningsson 222b317b032STakashi Iwai /* for hda_fixup_thinkpad_acpi() */ 223b317b032STakashi Iwai #include "thinkpad_helper.c" 22408cf680cSDavid Henningsson 22523d30f28STakashi Iwai static void cxt_fixup_stereo_dmic(struct hda_codec *codec, 22623d30f28STakashi Iwai const struct hda_fixup *fix, int action) 227e92d4b08STakashi Iwai { 22818dcd304SDavid Henningsson struct conexant_spec *spec = codec->spec; 229aed523f1STakashi Iwai spec->gen.inv_dmic_split = 1; 230e92d4b08STakashi Iwai } 231e92d4b08STakashi Iwai 232239fb862SHuacai Chen static void cxt5066_increase_mic_boost(struct hda_codec *codec, 233239fb862SHuacai Chen const struct hda_fixup *fix, int action) 234239fb862SHuacai Chen { 235239fb862SHuacai Chen if (action != HDA_FIXUP_ACT_PRE_PROBE) 236239fb862SHuacai Chen return; 237239fb862SHuacai Chen 238239fb862SHuacai Chen snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT, 239239fb862SHuacai Chen (0x3 << AC_AMPCAP_OFFSET_SHIFT) | 240239fb862SHuacai Chen (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) | 241239fb862SHuacai Chen (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | 242239fb862SHuacai Chen (0 << AC_AMPCAP_MUTE_SHIFT)); 243239fb862SHuacai Chen } 244239fb862SHuacai Chen 245e4c3bce2SDavid Henningsson static void cxt_update_headset_mode(struct hda_codec *codec) 246e4c3bce2SDavid Henningsson { 247e4c3bce2SDavid Henningsson /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */ 248e4c3bce2SDavid Henningsson int i; 249e4c3bce2SDavid Henningsson bool mic_mode = false; 250e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 251e4c3bce2SDavid Henningsson struct auto_pin_cfg *cfg = &spec->gen.autocfg; 252e4c3bce2SDavid Henningsson 253e4c3bce2SDavid Henningsson hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; 254e4c3bce2SDavid Henningsson 255e4c3bce2SDavid Henningsson for (i = 0; i < cfg->num_inputs; i++) 256e4c3bce2SDavid Henningsson if (cfg->inputs[i].pin == mux_pin) { 257e4c3bce2SDavid Henningsson mic_mode = !!cfg->inputs[i].is_headphone_mic; 258e4c3bce2SDavid Henningsson break; 259e4c3bce2SDavid Henningsson } 260e4c3bce2SDavid Henningsson 261e4c3bce2SDavid Henningsson if (mic_mode) { 262e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */ 263e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = false; 264e4c3bce2SDavid Henningsson } else { 265e4c3bce2SDavid Henningsson snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */ 266e4c3bce2SDavid Henningsson spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]); 267e4c3bce2SDavid Henningsson } 268e4c3bce2SDavid Henningsson 269e4c3bce2SDavid Henningsson snd_hda_gen_update_outputs(codec); 270e4c3bce2SDavid Henningsson } 271e4c3bce2SDavid Henningsson 272e4c3bce2SDavid Henningsson static void cxt_update_headset_mode_hook(struct hda_codec *codec, 2737fe30711STakashi Iwai struct snd_kcontrol *kcontrol, 274e4c3bce2SDavid Henningsson struct snd_ctl_elem_value *ucontrol) 275e4c3bce2SDavid Henningsson { 276e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 277e4c3bce2SDavid Henningsson } 278e4c3bce2SDavid Henningsson 279e4c3bce2SDavid Henningsson static void cxt_fixup_headphone_mic(struct hda_codec *codec, 280e4c3bce2SDavid Henningsson const struct hda_fixup *fix, int action) 281e4c3bce2SDavid Henningsson { 282e4c3bce2SDavid Henningsson struct conexant_spec *spec = codec->spec; 283e4c3bce2SDavid Henningsson 284e4c3bce2SDavid Henningsson switch (action) { 285e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PRE_PROBE: 286e4c3bce2SDavid Henningsson spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC; 287a551d914STakashi Iwai snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410); 288e4c3bce2SDavid Henningsson break; 289e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_PROBE: 2900bed2aa3STakashi Iwai WARN_ON(spec->gen.cap_sync_hook); 291e4c3bce2SDavid Henningsson spec->gen.cap_sync_hook = cxt_update_headset_mode_hook; 292e4c3bce2SDavid Henningsson spec->gen.automute_hook = cxt_update_headset_mode; 293e4c3bce2SDavid Henningsson break; 294e4c3bce2SDavid Henningsson case HDA_FIXUP_ACT_INIT: 295e4c3bce2SDavid Henningsson cxt_update_headset_mode(codec); 296e4c3bce2SDavid Henningsson break; 297e4c3bce2SDavid Henningsson } 298e4c3bce2SDavid Henningsson } 299e4c3bce2SDavid Henningsson 300322f74edSHui Wang static void cxt_fixup_headset_mic(struct hda_codec *codec, 301322f74edSHui Wang const struct hda_fixup *fix, int action) 302322f74edSHui Wang { 303322f74edSHui Wang struct conexant_spec *spec = codec->spec; 304322f74edSHui Wang 305322f74edSHui Wang switch (action) { 306322f74edSHui Wang case HDA_FIXUP_ACT_PRE_PROBE: 307322f74edSHui Wang spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; 308322f74edSHui Wang break; 309322f74edSHui Wang } 310322f74edSHui Wang } 311322f74edSHui Wang 3123a00c660STakashi Iwai /* OPLC XO 1.5 fixup */ 3133a00c660STakashi Iwai 3143a00c660STakashi Iwai /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 3153a00c660STakashi Iwai * through the microphone jack. 3163a00c660STakashi Iwai * When the user enables this through a mixer switch, both internal and 3173a00c660STakashi Iwai * external microphones are disabled. Gain is fixed at 0dB. In this mode, 3183a00c660STakashi Iwai * we also allow the bias to be configured through a separate mixer 3193a00c660STakashi Iwai * control. */ 3203a00c660STakashi Iwai 3213a00c660STakashi Iwai #define update_mic_pin(codec, nid, val) \ 322401caff7STakashi Iwai snd_hda_codec_write_cache(codec, nid, 0, \ 3233a00c660STakashi Iwai AC_VERB_SET_PIN_WIDGET_CONTROL, val) 3243a00c660STakashi Iwai 3253a00c660STakashi Iwai static const struct hda_input_mux olpc_xo_dc_bias = { 3263a00c660STakashi Iwai .num_items = 3, 3273a00c660STakashi Iwai .items = { 3283a00c660STakashi Iwai { "Off", PIN_IN }, 3293a00c660STakashi Iwai { "50%", PIN_VREF50 }, 3303a00c660STakashi Iwai { "80%", PIN_VREF80 }, 3313a00c660STakashi Iwai }, 3323a00c660STakashi Iwai }; 3333a00c660STakashi Iwai 3343a00c660STakashi Iwai static void olpc_xo_update_mic_boost(struct hda_codec *codec) 3353a00c660STakashi Iwai { 3363a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 3373a00c660STakashi Iwai int ch, val; 3383a00c660STakashi Iwai 3393a00c660STakashi Iwai for (ch = 0; ch < 2; ch++) { 3403a00c660STakashi Iwai val = AC_AMP_SET_OUTPUT | 3413a00c660STakashi Iwai (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT); 3423a00c660STakashi Iwai if (!spec->dc_enable) 3433a00c660STakashi Iwai val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0); 3443a00c660STakashi Iwai snd_hda_codec_write(codec, 0x17, 0, 3453a00c660STakashi Iwai AC_VERB_SET_AMP_GAIN_MUTE, val); 3463a00c660STakashi Iwai } 3473a00c660STakashi Iwai } 3483a00c660STakashi Iwai 3493a00c660STakashi Iwai static void olpc_xo_update_mic_pins(struct hda_codec *codec) 3503a00c660STakashi Iwai { 3513a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 3523a00c660STakashi Iwai int cur_input, val; 3533a00c660STakashi Iwai struct nid_path *path; 3543a00c660STakashi Iwai 3553a00c660STakashi Iwai cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]]; 3563a00c660STakashi Iwai 3573a00c660STakashi Iwai /* Set up mic pins for port-B, C and F dynamically as the recording 3583a00c660STakashi Iwai * LED is turned on/off by these pin controls 3593a00c660STakashi Iwai */ 3603a00c660STakashi Iwai if (!spec->dc_enable) { 3613a00c660STakashi Iwai /* disable DC bias path and pin for port F */ 3623a00c660STakashi Iwai update_mic_pin(codec, 0x1e, 0); 3633a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, false, false); 3643a00c660STakashi Iwai 3653a00c660STakashi Iwai /* update port B (ext mic) and C (int mic) */ 3663a00c660STakashi Iwai /* OLPC defers mic widget control until when capture is 3673a00c660STakashi Iwai * started because the microphone LED comes on as soon as 3683a00c660STakashi Iwai * these settings are put in place. if we did this before 3693a00c660STakashi Iwai * recording, it would give the false indication that 3703a00c660STakashi Iwai * recording is happening when it is not. 3713a00c660STakashi Iwai */ 3723a00c660STakashi Iwai update_mic_pin(codec, 0x1a, spec->recording ? 3733a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1a) : 0); 3743a00c660STakashi Iwai update_mic_pin(codec, 0x1b, spec->recording ? 3753a00c660STakashi Iwai snd_hda_codec_get_pin_target(codec, 0x1b) : 0); 3763a00c660STakashi Iwai /* enable normal mic path */ 3773a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 3783a00c660STakashi Iwai if (path) 3793a00c660STakashi Iwai snd_hda_activate_path(codec, path, true, false); 3803a00c660STakashi Iwai } else { 3813a00c660STakashi Iwai /* disable normal mic path */ 3823a00c660STakashi Iwai path = snd_hda_get_path_from_idx(codec, cur_input); 3833a00c660STakashi Iwai if (path) 3843a00c660STakashi Iwai snd_hda_activate_path(codec, path, false, false); 3853a00c660STakashi Iwai 3863a00c660STakashi Iwai /* Even though port F is the DC input, the bias is controlled 3873a00c660STakashi Iwai * on port B. We also leave that port as an active input (but 3883a00c660STakashi Iwai * unselected) in DC mode just in case that is necessary to 3893a00c660STakashi Iwai * make the bias setting take effect. 3903a00c660STakashi Iwai */ 3913a00c660STakashi Iwai if (spec->recording) 3923a00c660STakashi Iwai val = olpc_xo_dc_bias.items[spec->dc_input_bias].index; 3933a00c660STakashi Iwai else 3943a00c660STakashi Iwai val = 0; 3953a00c660STakashi Iwai update_mic_pin(codec, 0x1a, val); 3963a00c660STakashi Iwai update_mic_pin(codec, 0x1b, 0); 3973a00c660STakashi Iwai /* enable DC bias path and pin */ 3983a00c660STakashi Iwai update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0); 3993a00c660STakashi Iwai snd_hda_activate_path(codec, spec->dc_mode_path, true, false); 4003a00c660STakashi Iwai } 4013a00c660STakashi Iwai } 4023a00c660STakashi Iwai 4033a00c660STakashi Iwai /* mic_autoswitch hook */ 4041a4f69d5STakashi Iwai static void olpc_xo_automic(struct hda_codec *codec, 4051a4f69d5STakashi Iwai struct hda_jack_callback *jack) 4063a00c660STakashi Iwai { 4073a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4083a00c660STakashi Iwai 4093a00c660STakashi Iwai /* in DC mode, we don't handle automic */ 4103a00c660STakashi Iwai if (!spec->dc_enable) 4113a00c660STakashi Iwai snd_hda_gen_mic_autoswitch(codec, jack); 4123a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 4133a00c660STakashi Iwai if (spec->dc_enable) 4143a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 4153a00c660STakashi Iwai } 4163a00c660STakashi Iwai 4173a00c660STakashi Iwai /* pcm_capture hook */ 4183a00c660STakashi Iwai static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo, 4193a00c660STakashi Iwai struct hda_codec *codec, 4203a00c660STakashi Iwai struct snd_pcm_substream *substream, 4213a00c660STakashi Iwai int action) 4223a00c660STakashi Iwai { 4233a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4243a00c660STakashi Iwai 4253a00c660STakashi Iwai /* toggle spec->recording flag and update mic pins accordingly 4263a00c660STakashi Iwai * for turning on/off LED 4273a00c660STakashi Iwai */ 4283a00c660STakashi Iwai switch (action) { 4293a00c660STakashi Iwai case HDA_GEN_PCM_ACT_PREPARE: 4303a00c660STakashi Iwai spec->recording = 1; 4313a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 4323a00c660STakashi Iwai break; 4333a00c660STakashi Iwai case HDA_GEN_PCM_ACT_CLEANUP: 4343a00c660STakashi Iwai spec->recording = 0; 4353a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 4363a00c660STakashi Iwai break; 4373a00c660STakashi Iwai } 4383a00c660STakashi Iwai } 4393a00c660STakashi Iwai 4403a00c660STakashi Iwai static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol, 4413a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 4423a00c660STakashi Iwai { 4433a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4443a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4453a00c660STakashi Iwai ucontrol->value.integer.value[0] = spec->dc_enable; 4463a00c660STakashi Iwai return 0; 4473a00c660STakashi Iwai } 4483a00c660STakashi Iwai 4493a00c660STakashi Iwai static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol, 4503a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 4513a00c660STakashi Iwai { 4523a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4533a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4543a00c660STakashi Iwai int dc_enable = !!ucontrol->value.integer.value[0]; 4553a00c660STakashi Iwai 4563a00c660STakashi Iwai if (dc_enable == spec->dc_enable) 4573a00c660STakashi Iwai return 0; 4583a00c660STakashi Iwai 4593a00c660STakashi Iwai spec->dc_enable = dc_enable; 4603a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 4613a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 4623a00c660STakashi Iwai return 1; 4633a00c660STakashi Iwai } 4643a00c660STakashi Iwai 4653a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 4663a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 4673a00c660STakashi Iwai { 4683a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4693a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4703a00c660STakashi Iwai ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 4713a00c660STakashi Iwai return 0; 4723a00c660STakashi Iwai } 4733a00c660STakashi Iwai 4743a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 4753a00c660STakashi Iwai struct snd_ctl_elem_info *uinfo) 4763a00c660STakashi Iwai { 4773a00c660STakashi Iwai return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo); 4783a00c660STakashi Iwai } 4793a00c660STakashi Iwai 4803a00c660STakashi Iwai static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 4813a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 4823a00c660STakashi Iwai { 4833a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4843a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 4853a00c660STakashi Iwai const struct hda_input_mux *imux = &olpc_xo_dc_bias; 4863a00c660STakashi Iwai unsigned int idx; 4873a00c660STakashi Iwai 4883a00c660STakashi Iwai idx = ucontrol->value.enumerated.item[0]; 4893a00c660STakashi Iwai if (idx >= imux->num_items) 4903a00c660STakashi Iwai idx = imux->num_items - 1; 4913a00c660STakashi Iwai if (spec->dc_input_bias == idx) 4923a00c660STakashi Iwai return 0; 4933a00c660STakashi Iwai 4943a00c660STakashi Iwai spec->dc_input_bias = idx; 4953a00c660STakashi Iwai if (spec->dc_enable) 4963a00c660STakashi Iwai olpc_xo_update_mic_pins(codec); 4973a00c660STakashi Iwai return 1; 4983a00c660STakashi Iwai } 4993a00c660STakashi Iwai 5003a00c660STakashi Iwai static const struct snd_kcontrol_new olpc_xo_mixers[] = { 5013a00c660STakashi Iwai { 5023a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5033a00c660STakashi Iwai .name = "DC Mode Enable Switch", 5043a00c660STakashi Iwai .info = snd_ctl_boolean_mono_info, 5053a00c660STakashi Iwai .get = olpc_xo_dc_mode_get, 5063a00c660STakashi Iwai .put = olpc_xo_dc_mode_put, 5073a00c660STakashi Iwai }, 5083a00c660STakashi Iwai { 5093a00c660STakashi Iwai .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5103a00c660STakashi Iwai .name = "DC Input Bias Enum", 5113a00c660STakashi Iwai .info = olpc_xo_dc_bias_enum_info, 5123a00c660STakashi Iwai .get = olpc_xo_dc_bias_enum_get, 5133a00c660STakashi Iwai .put = olpc_xo_dc_bias_enum_put, 5143a00c660STakashi Iwai }, 5153a00c660STakashi Iwai {} 5163a00c660STakashi Iwai }; 5173a00c660STakashi Iwai 5183a00c660STakashi Iwai /* overriding mic boost put callback; update mic boost volume only when 5193a00c660STakashi Iwai * DC mode is disabled 5203a00c660STakashi Iwai */ 5213a00c660STakashi Iwai static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol, 5223a00c660STakashi Iwai struct snd_ctl_elem_value *ucontrol) 5233a00c660STakashi Iwai { 5243a00c660STakashi Iwai struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 5253a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 5263a00c660STakashi Iwai int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); 5273a00c660STakashi Iwai if (ret > 0 && spec->dc_enable) 5283a00c660STakashi Iwai olpc_xo_update_mic_boost(codec); 5293a00c660STakashi Iwai return ret; 5303a00c660STakashi Iwai } 5313a00c660STakashi Iwai 5323a00c660STakashi Iwai static void cxt_fixup_olpc_xo(struct hda_codec *codec, 5333a00c660STakashi Iwai const struct hda_fixup *fix, int action) 5343a00c660STakashi Iwai { 5353a00c660STakashi Iwai struct conexant_spec *spec = codec->spec; 536a9c2dfc8STakashi Iwai struct snd_kcontrol_new *kctl; 5373a00c660STakashi Iwai int i; 5383a00c660STakashi Iwai 5393a00c660STakashi Iwai if (action != HDA_FIXUP_ACT_PROBE) 5403a00c660STakashi Iwai return; 5413a00c660STakashi Iwai 5423a00c660STakashi Iwai spec->gen.mic_autoswitch_hook = olpc_xo_automic; 5433a00c660STakashi Iwai spec->gen.pcm_capture_hook = olpc_xo_capture_hook; 5443a00c660STakashi Iwai spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0); 5453a00c660STakashi Iwai 5463a00c660STakashi Iwai snd_hda_add_new_ctls(codec, olpc_xo_mixers); 5473a00c660STakashi Iwai 5483a00c660STakashi Iwai /* OLPC's microphone port is DC coupled for use with external sensors, 5493a00c660STakashi Iwai * therefore we use a 50% mic bias in order to center the input signal 5503a00c660STakashi Iwai * with the DC input range of the codec. 5513a00c660STakashi Iwai */ 5523a00c660STakashi Iwai snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50); 5533a00c660STakashi Iwai 5543a00c660STakashi Iwai /* override mic boost control */ 555a9c2dfc8STakashi Iwai snd_array_for_each(&spec->gen.kctls, i, kctl) { 5563a00c660STakashi Iwai if (!strcmp(kctl->name, "Mic Boost Volume")) { 5573a00c660STakashi Iwai kctl->put = olpc_xo_mic_boost_put; 5583a00c660STakashi Iwai break; 5593a00c660STakashi Iwai } 5603a00c660STakashi Iwai } 5613a00c660STakashi Iwai } 5623a00c660STakashi Iwai 5633542aed7STakashi Iwai static void cxt_fixup_mute_led_eapd(struct hda_codec *codec, 5643542aed7STakashi Iwai const struct hda_fixup *fix, int action) 5653542aed7STakashi Iwai { 5663542aed7STakashi Iwai struct conexant_spec *spec = codec->spec; 5673542aed7STakashi Iwai 5683542aed7STakashi Iwai if (action == HDA_FIXUP_ACT_PRE_PROBE) { 5693542aed7STakashi Iwai spec->mute_led_eapd = 0x1b; 570*d15f7331SJiapeng Zhong spec->dynamic_eapd = true; 571929f718cSTakashi Iwai snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led); 5723542aed7STakashi Iwai } 5733542aed7STakashi Iwai } 5743542aed7STakashi Iwai 575ad7725d3STakashi Iwai /* 576ad7725d3STakashi Iwai * Fix max input level on mixer widget to 0dB 577ad7725d3STakashi Iwai * (originally it has 0x2b steps with 0dB offset 0x14) 578ad7725d3STakashi Iwai */ 579ad7725d3STakashi Iwai static void cxt_fixup_cap_mix_amp(struct hda_codec *codec, 580ad7725d3STakashi Iwai const struct hda_fixup *fix, int action) 581ad7725d3STakashi Iwai { 582ad7725d3STakashi Iwai snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT, 583ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_OFFSET_SHIFT) | 584ad7725d3STakashi Iwai (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) | 585ad7725d3STakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 586ad7725d3STakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 587ad7725d3STakashi Iwai } 588e4c3bce2SDavid Henningsson 589ea30e7dfSTakashi Iwai /* 590ea30e7dfSTakashi Iwai * Fix max input level on mixer widget to 0dB 591ea30e7dfSTakashi Iwai * (originally it has 0x1e steps with 0 dB offset 0x17) 592ea30e7dfSTakashi Iwai */ 593ea30e7dfSTakashi Iwai static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec, 594ea30e7dfSTakashi Iwai const struct hda_fixup *fix, int action) 595ea30e7dfSTakashi Iwai { 596ea30e7dfSTakashi Iwai snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT, 597ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_OFFSET_SHIFT) | 598ea30e7dfSTakashi Iwai (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | 599ea30e7dfSTakashi Iwai (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | 600ea30e7dfSTakashi Iwai (1 << AC_AMPCAP_MUTE_SHIFT)); 601ea30e7dfSTakashi Iwai } 602ea30e7dfSTakashi Iwai 603f73cd43aSTakashi Iwai static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec, 604f73cd43aSTakashi Iwai const struct hda_fixup *fix, 605f73cd43aSTakashi Iwai int action) 606f73cd43aSTakashi Iwai { 607f73cd43aSTakashi Iwai /* the mic pin (0x19) doesn't give an unsolicited event; 608f73cd43aSTakashi Iwai * probe the mic pin together with the headphone pin (0x16) 609f73cd43aSTakashi Iwai */ 610f73cd43aSTakashi Iwai if (action == HDA_FIXUP_ACT_PROBE) 611f73cd43aSTakashi Iwai snd_hda_jack_set_gating_jack(codec, 0x19, 0x16); 612f73cd43aSTakashi Iwai } 613f73cd43aSTakashi Iwai 6145cd5b1bdSJerónimo Borque /* update LED status via GPIO */ 6155cd5b1bdSJerónimo Borque static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask, 616f9ef724dSJeronimo Borque bool led_on) 6175cd5b1bdSJerónimo Borque { 6185cd5b1bdSJerónimo Borque struct conexant_spec *spec = codec->spec; 6195cd5b1bdSJerónimo Borque unsigned int oldval = spec->gpio_led; 6205cd5b1bdSJerónimo Borque 6215cd5b1bdSJerónimo Borque if (spec->mute_led_polarity) 622f9ef724dSJeronimo Borque led_on = !led_on; 6235cd5b1bdSJerónimo Borque 624f9ef724dSJeronimo Borque if (led_on) 6255cd5b1bdSJerónimo Borque spec->gpio_led |= mask; 626f9ef724dSJeronimo Borque else 627f9ef724dSJeronimo Borque spec->gpio_led &= ~mask; 628f9ef724dSJeronimo Borque codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n", 629f9ef724dSJeronimo Borque mask, led_on, spec->gpio_led); 6305cd5b1bdSJerónimo Borque if (spec->gpio_led != oldval) 6315cd5b1bdSJerónimo Borque snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 6325cd5b1bdSJerónimo Borque spec->gpio_led); 6335cd5b1bdSJerónimo Borque } 6345cd5b1bdSJerónimo Borque 6355cd5b1bdSJerónimo Borque /* turn on/off mute LED via GPIO per vmaster hook */ 636929f718cSTakashi Iwai static int cxt_gpio_mute_update(struct led_classdev *led_cdev, 637929f718cSTakashi Iwai enum led_brightness brightness) 6385cd5b1bdSJerónimo Borque { 639929f718cSTakashi Iwai struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); 6405cd5b1bdSJerónimo Borque struct conexant_spec *spec = codec->spec; 641929f718cSTakashi Iwai 642929f718cSTakashi Iwai cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness); 643929f718cSTakashi Iwai return 0; 6445cd5b1bdSJerónimo Borque } 6455cd5b1bdSJerónimo Borque 6465cd5b1bdSJerónimo Borque /* turn on/off mic-mute LED via GPIO per capture hook */ 647e65a2cafSTakashi Iwai static int cxt_gpio_micmute_update(struct led_classdev *led_cdev, 648e65a2cafSTakashi Iwai enum led_brightness brightness) 6495cd5b1bdSJerónimo Borque { 650e65a2cafSTakashi Iwai struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); 6515cd5b1bdSJerónimo Borque struct conexant_spec *spec = codec->spec; 6525cd5b1bdSJerónimo Borque 653e65a2cafSTakashi Iwai cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness); 654e65a2cafSTakashi Iwai return 0; 6555cd5b1bdSJerónimo Borque } 6565cd5b1bdSJerónimo Borque 6575cd5b1bdSJerónimo Borque 6585cd5b1bdSJerónimo Borque static void cxt_fixup_mute_led_gpio(struct hda_codec *codec, 6595cd5b1bdSJerónimo Borque const struct hda_fixup *fix, int action) 6605cd5b1bdSJerónimo Borque { 6615cd5b1bdSJerónimo Borque struct conexant_spec *spec = codec->spec; 6625cd5b1bdSJerónimo Borque static const struct hda_verb gpio_init[] = { 6635cd5b1bdSJerónimo Borque { 0x01, AC_VERB_SET_GPIO_MASK, 0x03 }, 6645cd5b1bdSJerónimo Borque { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03 }, 6655cd5b1bdSJerónimo Borque {} 6665cd5b1bdSJerónimo Borque }; 6675cd5b1bdSJerónimo Borque 6685cd5b1bdSJerónimo Borque if (action == HDA_FIXUP_ACT_PRE_PROBE) { 669929f718cSTakashi Iwai snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update); 6705cd5b1bdSJerónimo Borque spec->gpio_led = 0; 6715cd5b1bdSJerónimo Borque spec->mute_led_polarity = 0; 6725cd5b1bdSJerónimo Borque spec->gpio_mute_led_mask = 0x01; 6735cd5b1bdSJerónimo Borque spec->gpio_mic_led_mask = 0x02; 674e65a2cafSTakashi Iwai snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update); 6755cd5b1bdSJerónimo Borque } 6765cd5b1bdSJerónimo Borque snd_hda_add_verbs(codec, gpio_init); 6775cd5b1bdSJerónimo Borque if (spec->gpio_led) 6785cd5b1bdSJerónimo Borque snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 6795cd5b1bdSJerónimo Borque spec->gpio_led); 6805cd5b1bdSJerónimo Borque } 6815cd5b1bdSJerónimo Borque 6825cd5b1bdSJerónimo Borque 683d70f3632STakashi Iwai /* ThinkPad X200 & co with cxt5051 */ 68423d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 685e92d4b08STakashi Iwai { 0x16, 0x042140ff }, /* HP (seq# overridden) */ 686e92d4b08STakashi Iwai { 0x17, 0x21a11000 }, /* dock-mic */ 687e92d4b08STakashi Iwai { 0x19, 0x2121103f }, /* dock-HP */ 6883e93f5efSTakashi Iwai { 0x1c, 0x21440100 }, /* dock SPDIF out */ 689e92d4b08STakashi Iwai {} 690e92d4b08STakashi Iwai }; 691e92d4b08STakashi Iwai 692d70f3632STakashi Iwai /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */ 69323d30f28STakashi Iwai static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = { 694d70f3632STakashi Iwai { 0x19, 0x042110ff }, /* HP (seq# overridden) */ 695d70f3632STakashi Iwai { 0x1a, 0x21a190f0 }, /* dock-mic */ 696d70f3632STakashi Iwai { 0x1c, 0x212140ff }, /* dock-HP */ 697d70f3632STakashi Iwai {} 698e92d4b08STakashi Iwai }; 699e92d4b08STakashi Iwai 700239fb862SHuacai Chen /* Lemote A1004/A1205 with cxt5066 */ 701239fb862SHuacai Chen static const struct hda_pintbl cxt_pincfg_lemote[] = { 702239fb862SHuacai Chen { 0x1a, 0x90a10020 }, /* Internal mic */ 703239fb862SHuacai Chen { 0x1b, 0x03a11020 }, /* External mic */ 704239fb862SHuacai Chen { 0x1d, 0x400101f0 }, /* Not used */ 705239fb862SHuacai Chen { 0x1e, 0x40a701f0 }, /* Not used */ 706239fb862SHuacai Chen { 0x20, 0x404501f0 }, /* Not used */ 707239fb862SHuacai Chen { 0x22, 0x404401f0 }, /* Not used */ 708239fb862SHuacai Chen { 0x23, 0x40a701f0 }, /* Not used */ 709239fb862SHuacai Chen {} 710239fb862SHuacai Chen }; 711239fb862SHuacai Chen 71223d30f28STakashi Iwai static const struct hda_fixup cxt_fixups[] = { 71323d30f28STakashi Iwai [CXT_PINCFG_LENOVO_X200] = { 71423d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 71523d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_x200, 71623d30f28STakashi Iwai }, 71723d30f28STakashi Iwai [CXT_PINCFG_LENOVO_TP410] = { 71823d30f28STakashi Iwai .type = HDA_FIXUP_PINS, 71923d30f28STakashi Iwai .v.pins = cxt_pincfg_lenovo_tp410, 72008cf680cSDavid Henningsson .chained = true, 72108cf680cSDavid Henningsson .chain_id = CXT_FIXUP_THINKPAD_ACPI, 72223d30f28STakashi Iwai }, 723239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1004] = { 724239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 725239fb862SHuacai Chen .chained = true, 726239fb862SHuacai Chen .chain_id = CXT_FIXUP_INC_MIC_BOOST, 727239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 728239fb862SHuacai Chen }, 729239fb862SHuacai Chen [CXT_PINCFG_LEMOTE_A1205] = { 730239fb862SHuacai Chen .type = HDA_FIXUP_PINS, 731239fb862SHuacai Chen .v.pins = cxt_pincfg_lemote, 732239fb862SHuacai Chen }, 733ddb6ca75STakashi Iwai [CXT_PINCFG_COMPAQ_CQ60] = { 734ddb6ca75STakashi Iwai .type = HDA_FIXUP_PINS, 735ddb6ca75STakashi Iwai .v.pins = (const struct hda_pintbl[]) { 736ddb6ca75STakashi Iwai /* 0x17 was falsely set up as a mic, it should 0x1d */ 737ddb6ca75STakashi Iwai { 0x17, 0x400001f0 }, 738ddb6ca75STakashi Iwai { 0x1d, 0x97a70120 }, 739ddb6ca75STakashi Iwai { } 740ddb6ca75STakashi Iwai } 741ddb6ca75STakashi Iwai }, 74223d30f28STakashi Iwai [CXT_FIXUP_STEREO_DMIC] = { 74323d30f28STakashi Iwai .type = HDA_FIXUP_FUNC, 74423d30f28STakashi Iwai .v.func = cxt_fixup_stereo_dmic, 74523d30f28STakashi Iwai }, 746239fb862SHuacai Chen [CXT_FIXUP_INC_MIC_BOOST] = { 747239fb862SHuacai Chen .type = HDA_FIXUP_FUNC, 748239fb862SHuacai Chen .v.func = cxt5066_increase_mic_boost, 749239fb862SHuacai Chen }, 750e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC_PIN] = { 751e4c3bce2SDavid Henningsson .type = HDA_FIXUP_PINS, 752e4c3bce2SDavid Henningsson .chained = true, 753e4c3bce2SDavid Henningsson .chain_id = CXT_FIXUP_HEADPHONE_MIC, 754e4c3bce2SDavid Henningsson .v.pins = (const struct hda_pintbl[]) { 755e4c3bce2SDavid Henningsson { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ 756e4c3bce2SDavid Henningsson { } 757e4c3bce2SDavid Henningsson } 758e4c3bce2SDavid Henningsson }, 759e4c3bce2SDavid Henningsson [CXT_FIXUP_HEADPHONE_MIC] = { 760e4c3bce2SDavid Henningsson .type = HDA_FIXUP_FUNC, 761e4c3bce2SDavid Henningsson .v.func = cxt_fixup_headphone_mic, 762e4c3bce2SDavid Henningsson }, 7634a437044STakashi Iwai [CXT_FIXUP_GPIO1] = { 7644a437044STakashi Iwai .type = HDA_FIXUP_VERBS, 7654a437044STakashi Iwai .v.verbs = (const struct hda_verb[]) { 7664a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, 7674a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, 7684a437044STakashi Iwai { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 }, 7694a437044STakashi Iwai { } 7704a437044STakashi Iwai }, 7714a437044STakashi Iwai }, 772ff50479aSTakashi Iwai [CXT_FIXUP_ASPIRE_DMIC] = { 773ff50479aSTakashi Iwai .type = HDA_FIXUP_FUNC, 774ff50479aSTakashi Iwai .v.func = cxt_fixup_stereo_dmic, 775ff50479aSTakashi Iwai .chained = true, 776ff50479aSTakashi Iwai .chain_id = CXT_FIXUP_GPIO1, 777ff50479aSTakashi Iwai }, 77808cf680cSDavid Henningsson [CXT_FIXUP_THINKPAD_ACPI] = { 77908cf680cSDavid Henningsson .type = HDA_FIXUP_FUNC, 780b317b032STakashi Iwai .v.func = hda_fixup_thinkpad_acpi, 78108cf680cSDavid Henningsson }, 7823a00c660STakashi Iwai [CXT_FIXUP_OLPC_XO] = { 7833a00c660STakashi Iwai .type = HDA_FIXUP_FUNC, 7843a00c660STakashi Iwai .v.func = cxt_fixup_olpc_xo, 7853a00c660STakashi Iwai }, 786ad7725d3STakashi Iwai [CXT_FIXUP_CAP_MIX_AMP] = { 787ad7725d3STakashi Iwai .type = HDA_FIXUP_FUNC, 788ad7725d3STakashi Iwai .v.func = cxt_fixup_cap_mix_amp, 789ad7725d3STakashi Iwai }, 7906dcbadefSTakashi Iwai [CXT_FIXUP_TOSHIBA_P105] = { 7916dcbadefSTakashi Iwai .type = HDA_FIXUP_PINS, 7926dcbadefSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 7936dcbadefSTakashi Iwai { 0x10, 0x961701f0 }, /* speaker/hp */ 7946dcbadefSTakashi Iwai { 0x12, 0x02a1901e }, /* ext mic */ 7956dcbadefSTakashi Iwai { 0x14, 0x95a70110 }, /* int mic */ 7966dcbadefSTakashi Iwai {} 7976dcbadefSTakashi Iwai }, 7986dcbadefSTakashi Iwai }, 799e5eac90dSTakashi Iwai [CXT_FIXUP_HP_530] = { 800e5eac90dSTakashi Iwai .type = HDA_FIXUP_PINS, 801e5eac90dSTakashi Iwai .v.pins = (const struct hda_pintbl[]) { 802e5eac90dSTakashi Iwai { 0x12, 0x90a60160 }, /* int mic */ 803e5eac90dSTakashi Iwai {} 804e5eac90dSTakashi Iwai }, 805e5eac90dSTakashi Iwai .chained = true, 806e5eac90dSTakashi Iwai .chain_id = CXT_FIXUP_CAP_MIX_AMP, 807e5eac90dSTakashi Iwai }, 808ea30e7dfSTakashi Iwai [CXT_FIXUP_CAP_MIX_AMP_5047] = { 809ea30e7dfSTakashi Iwai .type = HDA_FIXUP_FUNC, 810ea30e7dfSTakashi Iwai .v.func = cxt_fixup_cap_mix_amp_5047, 811ea30e7dfSTakashi Iwai }, 8123542aed7STakashi Iwai [CXT_FIXUP_MUTE_LED_EAPD] = { 8133542aed7STakashi Iwai .type = HDA_FIXUP_FUNC, 8143542aed7STakashi Iwai .v.func = cxt_fixup_mute_led_eapd, 8153542aed7STakashi Iwai }, 816cc3a47a2SJaroslav Kysela [CXT_FIXUP_HP_DOCK] = { 817cc3a47a2SJaroslav Kysela .type = HDA_FIXUP_PINS, 818cc3a47a2SJaroslav Kysela .v.pins = (const struct hda_pintbl[]) { 819cc3a47a2SJaroslav Kysela { 0x16, 0x21011020 }, /* line-out */ 820cc3a47a2SJaroslav Kysela { 0x18, 0x2181103f }, /* line-in */ 821cc3a47a2SJaroslav Kysela { } 822c3123d6aSFlorin Tudorache }, 823c3123d6aSFlorin Tudorache .chained = true, 824c3123d6aSFlorin Tudorache .chain_id = CXT_FIXUP_MUTE_LED_GPIO, 825cc3a47a2SJaroslav Kysela }, 8260eec8809STakashi Iwai [CXT_FIXUP_HP_SPECTRE] = { 8270eec8809STakashi Iwai .type = HDA_FIXUP_PINS, 8280eec8809STakashi Iwai .v.pins = (const struct hda_pintbl[]) { 8290eec8809STakashi Iwai /* enable NID 0x1d for the speaker on top */ 8300eec8809STakashi Iwai { 0x1d, 0x91170111 }, 8310eec8809STakashi Iwai { } 8320eec8809STakashi Iwai } 8330eec8809STakashi Iwai }, 834f73cd43aSTakashi Iwai [CXT_FIXUP_HP_GATE_MIC] = { 835f73cd43aSTakashi Iwai .type = HDA_FIXUP_FUNC, 836f73cd43aSTakashi Iwai .v.func = cxt_fixup_hp_gate_mic_jack, 837f73cd43aSTakashi Iwai }, 8385cd5b1bdSJerónimo Borque [CXT_FIXUP_MUTE_LED_GPIO] = { 8395cd5b1bdSJerónimo Borque .type = HDA_FIXUP_FUNC, 8405cd5b1bdSJerónimo Borque .v.func = cxt_fixup_mute_led_gpio, 8415cd5b1bdSJerónimo Borque }, 842322f74edSHui Wang [CXT_FIXUP_HEADSET_MIC] = { 843322f74edSHui Wang .type = HDA_FIXUP_FUNC, 844322f74edSHui Wang .v.func = cxt_fixup_headset_mic, 845322f74edSHui Wang }, 846322f74edSHui Wang [CXT_FIXUP_HP_MIC_NO_PRESENCE] = { 847322f74edSHui Wang .type = HDA_FIXUP_PINS, 848322f74edSHui Wang .v.pins = (const struct hda_pintbl[]) { 849322f74edSHui Wang { 0x1a, 0x02a1113c }, 850322f74edSHui Wang { } 851322f74edSHui Wang }, 852322f74edSHui Wang .chained = true, 853322f74edSHui Wang .chain_id = CXT_FIXUP_HEADSET_MIC, 854322f74edSHui Wang }, 855ad7725d3STakashi Iwai }; 856ad7725d3STakashi Iwai 857ad7725d3STakashi Iwai static const struct snd_pci_quirk cxt5045_fixups[] = { 858e5eac90dSTakashi Iwai SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530), 8596dcbadefSTakashi Iwai SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105), 860ad7725d3STakashi Iwai /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have 861ad7725d3STakashi Iwai * really bad sound over 0dB on NID 0x17. 862ad7725d3STakashi Iwai */ 863ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP), 864ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP), 865ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP), 866ad7725d3STakashi Iwai SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP), 867ad7725d3STakashi Iwai {} 868ad7725d3STakashi Iwai }; 869ad7725d3STakashi Iwai 870ad7725d3STakashi Iwai static const struct hda_model_fixup cxt5045_fixup_models[] = { 871ad7725d3STakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" }, 8726dcbadefSTakashi Iwai { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" }, 873e5eac90dSTakashi Iwai { .id = CXT_FIXUP_HP_530, .name = "hp-530" }, 874ad7725d3STakashi Iwai {} 875e92d4b08STakashi Iwai }; 876e92d4b08STakashi Iwai 877ea30e7dfSTakashi Iwai static const struct snd_pci_quirk cxt5047_fixups[] = { 878ea30e7dfSTakashi Iwai /* HP laptops have really bad sound over 0 dB on NID 0x10. 879ea30e7dfSTakashi Iwai */ 880ea30e7dfSTakashi Iwai SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047), 881ea30e7dfSTakashi Iwai {} 882ea30e7dfSTakashi Iwai }; 883ea30e7dfSTakashi Iwai 884ea30e7dfSTakashi Iwai static const struct hda_model_fixup cxt5047_fixup_models[] = { 885ea30e7dfSTakashi Iwai { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" }, 886ea30e7dfSTakashi Iwai {} 887ea30e7dfSTakashi Iwai }; 888ea30e7dfSTakashi Iwai 889d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5051_fixups[] = { 890ddb6ca75STakashi Iwai SND_PCI_QUIRK(0x103c, 0x360b, "Compaq CQ60", CXT_PINCFG_COMPAQ_CQ60), 891e92d4b08STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200), 892e92d4b08STakashi Iwai {} 893e92d4b08STakashi Iwai }; 894e92d4b08STakashi Iwai 895a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5051_fixup_models[] = { 896a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" }, 897a2dd933dSTakashi Iwai {} 898a2dd933dSTakashi Iwai }; 899a2dd933dSTakashi Iwai 900d70f3632STakashi Iwai static const struct snd_pci_quirk cxt5066_fixups[] = { 90163a077e2STakashi Iwai SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 902ff50479aSTakashi Iwai SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC), 903522a7fa8SDavid Henningsson SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC), 904cc3a47a2SJaroslav Kysela SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK), 905aea80817SDennis Wassenberg SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK), 906099fd6caSDennis Wassenberg SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK), 90740906ebeSMantas Mikulėnas SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK), 9084cd3016cSJurica Vukadin SND_PCI_QUIRK(0x103c, 0x83b2, "HP EliteBook 840 G5", CXT_FIXUP_HP_DOCK), 9092861751fSDennis Wassenberg SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK), 9107eef32c1SDennis Wassenberg SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK), 9110eec8809STakashi Iwai SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE), 912f73cd43aSTakashi Iwai SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC), 9135cd5b1bdSJerónimo Borque SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO), 914ba92b114SKai-Heng Feng SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO), 9159a6249d2SPo-Hsu Lin SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO), 91669939038SAnthony Wong SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO), 917322f74edSHui Wang SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 918322f74edSHui Wang SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE), 919e190de69SKai-Heng Feng SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO), 920f16041dfSTakashi Iwai SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE), 921167897f4SJaroslav Kysela SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 922167897f4SJaroslav Kysela SND_PCI_QUIRK(0x103c, 0x8457, "HP Z2 G4 mini", CXT_FIXUP_HP_MIC_NO_PRESENCE), 923167897f4SJaroslav Kysela SND_PCI_QUIRK(0x103c, 0x8458, "HP Z2 G4 mini premium", CXT_FIXUP_HP_MIC_NO_PRESENCE), 924e4c3bce2SDavid Henningsson SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), 9253a00c660STakashi Iwai SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO), 926d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 927d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 928d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 929d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), 930d70f3632STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 931ef7d84caSPeter Große SND_PCI_QUIRK(0x17aa, 0x21d2, "Lenovo T420s", CXT_PINCFG_LENOVO_TP410), 932a555bb8cSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 93388d57606SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), 9343542aed7STakashi Iwai SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD), 935e7bb6ad5SJeremy Cline SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC), 936e8d65a8dSDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC), 93718dcd304SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 938e4db0952SFelix Kaechele SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 939bbba6f9dSTakashi Iwai SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC), 940b3c5dce8SDavid Henningsson SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 9412fd3f170SHui Wang SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI), 942239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004), 943239fb862SHuacai Chen SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205), 944f2e5731dSTakashi Iwai {} 945f2e5731dSTakashi Iwai }; 946f2e5731dSTakashi Iwai 947a2dd933dSTakashi Iwai static const struct hda_model_fixup cxt5066_fixup_models[] = { 948a2dd933dSTakashi Iwai { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" }, 949a2dd933dSTakashi Iwai { .id = CXT_FIXUP_GPIO1, .name = "gpio1" }, 950a2dd933dSTakashi Iwai { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" }, 951a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" }, 952a2dd933dSTakashi Iwai { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" }, 953a2dd933dSTakashi Iwai { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" }, 9548245b363SHuacai Chen { .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" }, 9553a00c660STakashi Iwai { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" }, 9563542aed7STakashi Iwai { .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" }, 957cc3a47a2SJaroslav Kysela { .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" }, 9585cd5b1bdSJerónimo Borque { .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" }, 95909b83d10STakashi Iwai { .id = CXT_FIXUP_HP_MIC_NO_PRESENCE, .name = "hp-mic-fix" }, 960a2dd933dSTakashi Iwai {} 961a2dd933dSTakashi Iwai }; 962a2dd933dSTakashi Iwai 9633868137eSTakashi Iwai /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 9643868137eSTakashi Iwai * can be created (bko#42825) 9653868137eSTakashi Iwai */ 9663868137eSTakashi Iwai static void add_cx5051_fake_mutes(struct hda_codec *codec) 9673868137eSTakashi Iwai { 968d89c6c0cSTakashi Iwai struct conexant_spec *spec = codec->spec; 969caf3c043SMichał Mirosław static const hda_nid_t out_nids[] = { 9703868137eSTakashi Iwai 0x10, 0x11, 0 9713868137eSTakashi Iwai }; 972caf3c043SMichał Mirosław const hda_nid_t *p; 9733868137eSTakashi Iwai 9743868137eSTakashi Iwai for (p = out_nids; *p; p++) 9753868137eSTakashi Iwai snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, 9763868137eSTakashi Iwai AC_AMPCAP_MIN_MUTE | 9773868137eSTakashi Iwai query_amp_caps(codec, *p, HDA_OUTPUT)); 978d89c6c0cSTakashi Iwai spec->gen.dac_min_mute = true; 9793868137eSTakashi Iwai } 9803868137eSTakashi Iwai 981f2e5731dSTakashi Iwai static int patch_conexant_auto(struct hda_codec *codec) 982f2e5731dSTakashi Iwai { 983f2e5731dSTakashi Iwai struct conexant_spec *spec; 984f2e5731dSTakashi Iwai int err; 985f2e5731dSTakashi Iwai 9867639a06cSTakashi Iwai codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name); 9871f8458a2STakashi Iwai 988f2e5731dSTakashi Iwai spec = kzalloc(sizeof(*spec), GFP_KERNEL); 989f2e5731dSTakashi Iwai if (!spec) 990f2e5731dSTakashi Iwai return -ENOMEM; 991aed523f1STakashi Iwai snd_hda_gen_spec_init(&spec->gen); 992f2e5731dSTakashi Iwai codec->spec = spec; 993225068abSTakashi Iwai codec->patch_ops = cx_auto_patch_ops; 994e92d4b08STakashi Iwai 995aed523f1STakashi Iwai cx_auto_parse_eapd(codec); 996ff359b14STakashi Iwai spec->gen.own_eapd_ctl = 1; 997e92d4b08STakashi Iwai 9987639a06cSTakashi Iwai switch (codec->core.vendor_id) { 9996b452142STakashi Iwai case 0x14f15045: 10004f32456eSMichael Karcher codec->single_adc_amp = 1; 100170540e24STakashi Iwai spec->gen.mixer_nid = 0x17; 100274f14b36STakashi Iwai spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO; 1003ad7725d3STakashi Iwai snd_hda_pick_fixup(codec, cxt5045_fixup_models, 1004ad7725d3STakashi Iwai cxt5045_fixups, cxt_fixups); 10056b452142STakashi Iwai break; 1006164a7adaSTakashi Iwai case 0x14f15047: 1007164a7adaSTakashi Iwai codec->pin_amp_workaround = 1; 1008164a7adaSTakashi Iwai spec->gen.mixer_nid = 0x19; 100974f14b36STakashi Iwai spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO; 1010ea30e7dfSTakashi Iwai snd_hda_pick_fixup(codec, cxt5047_fixup_models, 1011ea30e7dfSTakashi Iwai cxt5047_fixups, cxt_fixups); 1012164a7adaSTakashi Iwai break; 10133868137eSTakashi Iwai case 0x14f15051: 10143868137eSTakashi Iwai add_cx5051_fake_mutes(codec); 101551969d62SMichael Karcher codec->pin_amp_workaround = 1; 1016a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5051_fixup_models, 1017a2dd933dSTakashi Iwai cxt5051_fixups, cxt_fixups); 10183868137eSTakashi Iwai break; 1019b03d61d6SDavid Henningsson case 0x14f150f2: 1020b03d61d6SDavid Henningsson codec->power_save_node = 1; 1021c0dbbdadSGustavo A. R. Silva fallthrough; 102251969d62SMichael Karcher default: 102351969d62SMichael Karcher codec->pin_amp_workaround = 1; 1024a2dd933dSTakashi Iwai snd_hda_pick_fixup(codec, cxt5066_fixup_models, 1025a2dd933dSTakashi Iwai cxt5066_fixups, cxt_fixups); 102623d30f28STakashi Iwai break; 10276b452142STakashi Iwai } 10286b452142STakashi Iwai 1029929f718cSTakashi Iwai if (!spec->gen.vmaster_mute.hook && spec->dynamic_eapd) 1030929f718cSTakashi Iwai spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; 1031527c73baSTakashi Iwai 1032aed523f1STakashi Iwai snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 1033aed523f1STakashi Iwai 1034e4c3bce2SDavid Henningsson err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 1035e4c3bce2SDavid Henningsson spec->parse_flags); 103622ce5f74STakashi Iwai if (err < 0) 1037aed523f1STakashi Iwai goto error; 1038aed523f1STakashi Iwai 1039aed523f1STakashi Iwai err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 1040aed523f1STakashi Iwai if (err < 0) 1041aed523f1STakashi Iwai goto error; 1042aed523f1STakashi Iwai 104351e19ca5STakashi Iwai err = cx_auto_parse_beep(codec); 104451e19ca5STakashi Iwai if (err < 0) 104551e19ca5STakashi Iwai goto error; 104651e19ca5STakashi Iwai 10474f2864a4STakashi Iwai /* Some laptops with Conexant chips show stalls in S3 resume, 10484f2864a4STakashi Iwai * which falls into the single-cmd mode. 10494f2864a4STakashi Iwai * Better to make reset, then. 10504f2864a4STakashi Iwai */ 1051d068ebc2STakashi Iwai if (!codec->bus->core.sync_write) { 10524e76a883STakashi Iwai codec_info(codec, 10534f2864a4STakashi Iwai "Enable sync_write for stable communication\n"); 1054d068ebc2STakashi Iwai codec->bus->core.sync_write = 1; 10554f2864a4STakashi Iwai codec->bus->allow_bus_reset = 1; 10564f2864a4STakashi Iwai } 10574f2864a4STakashi Iwai 1058e4c3bce2SDavid Henningsson snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 1059e4c3bce2SDavid Henningsson 1060f2e5731dSTakashi Iwai return 0; 1061aed523f1STakashi Iwai 1062aed523f1STakashi Iwai error: 106308cf680cSDavid Henningsson cx_auto_free(codec); 1064aed523f1STakashi Iwai return err; 1065f2e5731dSTakashi Iwai } 1066f2e5731dSTakashi Iwai 1067f2e5731dSTakashi Iwai /* 1068461e2c78STakashi Iwai */ 1069461e2c78STakashi Iwai 1070b9a94a9cSTakashi Iwai static const struct hda_device_id snd_hda_id_conexant[] = { 10713f880949SHui Wang HDA_CODEC_ENTRY(0x14f11f86, "CX8070", patch_conexant_auto), 1072bcdda2ecSTakashi Iwai HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto), 1073744a11abSbo liu HDA_CODEC_ENTRY(0x14f120d0, "CX11970", patch_conexant_auto), 1074b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15045, "CX20549 (Venice)", patch_conexant_auto), 1075b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15047, "CX20551 (Waikiki)", patch_conexant_auto), 1076b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15051, "CX20561 (Hermosa)", patch_conexant_auto), 1077b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15066, "CX20582 (Pebble)", patch_conexant_auto), 1078b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15067, "CX20583 (Pebble HSF)", patch_conexant_auto), 1079b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15068, "CX20584", patch_conexant_auto), 1080b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15069, "CX20585", patch_conexant_auto), 1081b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f1506c, "CX20588", patch_conexant_auto), 1082b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f1506e, "CX20590", patch_conexant_auto), 1083b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15097, "CX20631", patch_conexant_auto), 1084b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15098, "CX20632", patch_conexant_auto), 1085b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150a1, "CX20641", patch_conexant_auto), 1086b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150a2, "CX20642", patch_conexant_auto), 1087b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150ab, "CX20651", patch_conexant_auto), 1088b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150ac, "CX20652", patch_conexant_auto), 1089b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150b8, "CX20664", patch_conexant_auto), 1090b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150b9, "CX20665", patch_conexant_auto), 10913b7e2a7dSTakashi Iwai HDA_CODEC_ENTRY(0x14f150f1, "CX21722", patch_conexant_auto), 1092b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150f2, "CX20722", patch_conexant_auto), 10933b7e2a7dSTakashi Iwai HDA_CODEC_ENTRY(0x14f150f3, "CX21724", patch_conexant_auto), 1094b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f150f4, "CX20724", patch_conexant_auto), 1095b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f1510f, "CX20751/2", patch_conexant_auto), 1096b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15110, "CX20751/2", patch_conexant_auto), 1097b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15111, "CX20753/4", patch_conexant_auto), 1098b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15113, "CX20755", patch_conexant_auto), 1099b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15114, "CX20756", patch_conexant_auto), 1100b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f15115, "CX20757", patch_conexant_auto), 1101b9a94a9cSTakashi Iwai HDA_CODEC_ENTRY(0x14f151d7, "CX20952", patch_conexant_auto), 1102c9b443d4STobin Davis {} /* terminator */ 1103c9b443d4STobin Davis }; 1104b9a94a9cSTakashi Iwai MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_conexant); 11051289e9e8STakashi Iwai 11061289e9e8STakashi Iwai MODULE_LICENSE("GPL"); 11071289e9e8STakashi Iwai MODULE_DESCRIPTION("Conexant HD-audio codec"); 11081289e9e8STakashi Iwai 1109d8a766a1STakashi Iwai static struct hda_codec_driver conexant_driver = { 1110b9a94a9cSTakashi Iwai .id = snd_hda_id_conexant, 11111289e9e8STakashi Iwai }; 11121289e9e8STakashi Iwai 1113d8a766a1STakashi Iwai module_hda_codec_driver(conexant_driver); 1114