| 1 | // SPDX-License-Identifier: GPL-2.0-or-later
|
|---|
| 2 | /*
|
|---|
| 3 | * HD audio interface patch for Conexant HDA audio codec
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
|
|---|
| 6 | * Takashi Iwai <tiwai@suse.de>
|
|---|
| 7 | * Tobin Davis <tdavis@dsl-only.net>
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #include <linux/init.h>
|
|---|
| 11 | #include <linux/delay.h>
|
|---|
| 12 | #include <linux/slab.h>
|
|---|
| 13 | #include <linux/module.h>
|
|---|
| 14 | #include <sound/core.h>
|
|---|
| 15 | #include <sound/jack.h>
|
|---|
| 16 |
|
|---|
| 17 | #include <sound/hda_codec.h>
|
|---|
| 18 | #include "hda_local.h"
|
|---|
| 19 | #include "hda_auto_parser.h"
|
|---|
| 20 | #include "hda_beep.h"
|
|---|
| 21 | #include "hda_jack.h"
|
|---|
| 22 | #include "hda_generic.h"
|
|---|
| 23 |
|
|---|
| 24 | #ifdef TARGET_OS2
|
|---|
| 25 | #define KBUILD_MODNAME "patch_conexant"
|
|---|
| 26 | #endif
|
|---|
| 27 |
|
|---|
| 28 | struct conexant_spec {
|
|---|
| 29 | struct hda_gen_spec gen;
|
|---|
| 30 |
|
|---|
| 31 | /* extra EAPD pins */
|
|---|
| 32 | unsigned int num_eapds;
|
|---|
| 33 | hda_nid_t eapds[4];
|
|---|
| 34 | bool dynamic_eapd;
|
|---|
| 35 | hda_nid_t mute_led_eapd;
|
|---|
| 36 |
|
|---|
| 37 | unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
|
|---|
| 38 |
|
|---|
| 39 | /* OPLC XO specific */
|
|---|
| 40 | bool recording;
|
|---|
| 41 | bool dc_enable;
|
|---|
| 42 | unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */
|
|---|
| 43 | struct nid_path *dc_mode_path;
|
|---|
| 44 |
|
|---|
| 45 | int mute_led_polarity;
|
|---|
| 46 | unsigned int gpio_led;
|
|---|
| 47 | unsigned int gpio_mute_led_mask;
|
|---|
| 48 | unsigned int gpio_mic_led_mask;
|
|---|
| 49 | bool is_cx8070_sn6140;
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | #ifdef CONFIG_SND_HDA_INPUT_BEEP
|
|---|
| 54 | /* additional beep mixers; private_value will be overwritten */
|
|---|
| 55 | static const struct snd_kcontrol_new cxt_beep_mixer[] = {
|
|---|
| 56 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
|
|---|
| 57 | HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
|
|---|
| 58 | };
|
|---|
| 59 |
|
|---|
| 60 | static int set_beep_amp(struct conexant_spec *spec, hda_nid_t nid,
|
|---|
| 61 | int idx, int dir)
|
|---|
| 62 | {
|
|---|
| 63 | struct snd_kcontrol_new *knew;
|
|---|
| 64 | unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
|
|---|
| 65 | int i;
|
|---|
| 66 |
|
|---|
| 67 | spec->gen.beep_nid = nid;
|
|---|
| 68 | for (i = 0; i < ARRAY_SIZE(cxt_beep_mixer); i++) {
|
|---|
| 69 | knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
|
|---|
| 70 | &cxt_beep_mixer[i]);
|
|---|
| 71 | if (!knew)
|
|---|
| 72 | return -ENOMEM;
|
|---|
| 73 | knew->private_value = beep_amp;
|
|---|
| 74 | }
|
|---|
| 75 | return 0;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | static int cx_auto_parse_beep(struct hda_codec *codec)
|
|---|
| 79 | {
|
|---|
| 80 | struct conexant_spec *spec = codec->spec;
|
|---|
| 81 | hda_nid_t nid;
|
|---|
| 82 |
|
|---|
| 83 | for_each_hda_codec_node(nid, codec)
|
|---|
| 84 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
|
|---|
| 85 | return set_beep_amp(spec, nid, 0, HDA_OUTPUT);
|
|---|
| 86 | return 0;
|
|---|
| 87 | }
|
|---|
| 88 | #else
|
|---|
| 89 | #define cx_auto_parse_beep(codec) 0
|
|---|
| 90 | #endif
|
|---|
| 91 |
|
|---|
| 92 | /*
|
|---|
| 93 | * Automatic parser for CX20641 & co
|
|---|
| 94 | */
|
|---|
| 95 |
|
|---|
| 96 | /* parse EAPDs */
|
|---|
| 97 | static void cx_auto_parse_eapd(struct hda_codec *codec)
|
|---|
| 98 | {
|
|---|
| 99 | struct conexant_spec *spec = codec->spec;
|
|---|
| 100 | hda_nid_t nid;
|
|---|
| 101 |
|
|---|
| 102 | for_each_hda_codec_node(nid, codec) {
|
|---|
| 103 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
|
|---|
| 104 | continue;
|
|---|
| 105 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
|
|---|
| 106 | continue;
|
|---|
| 107 | spec->eapds[spec->num_eapds++] = nid;
|
|---|
| 108 | if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
|
|---|
| 109 | break;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | /* NOTE: below is a wild guess; if we have more than two EAPDs,
|
|---|
| 113 | * it's a new chip, where EAPDs are supposed to be associated to
|
|---|
| 114 | * pins, and we can control EAPD per pin.
|
|---|
| 115 | * OTOH, if only one or two EAPDs are found, it's an old chip,
|
|---|
| 116 | * thus it might control over all pins.
|
|---|
| 117 | */
|
|---|
| 118 | if (spec->num_eapds > 2)
|
|---|
| 119 | spec->dynamic_eapd = 1;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
|
|---|
| 123 | const hda_nid_t *pins, bool on)
|
|---|
| 124 | {
|
|---|
| 125 | int i;
|
|---|
| 126 | for (i = 0; i < num_pins; i++) {
|
|---|
| 127 | if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
|
|---|
| 128 | snd_hda_codec_write(codec, pins[i], 0,
|
|---|
| 129 | AC_VERB_SET_EAPD_BTLENABLE,
|
|---|
| 130 | on ? 0x02 : 0);
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | /* turn on/off EAPD according to Master switch */
|
|---|
| 135 | static void cx_auto_vmaster_hook(void *private_data, int enabled)
|
|---|
| 136 | {
|
|---|
| 137 | struct hda_codec *codec = private_data;
|
|---|
| 138 | struct conexant_spec *spec = codec->spec;
|
|---|
| 139 |
|
|---|
| 140 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | #ifdef NOT_USED
|
|---|
| 144 | /* turn on/off EAPD according to Master switch (inversely!) for mute LED */
|
|---|
| 145 | static int cx_auto_vmaster_mute_led(struct led_classdev *led_cdev,
|
|---|
| 146 | enum led_brightness brightness)
|
|---|
| 147 | {
|
|---|
| 148 | struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
|
|---|
| 149 | struct conexant_spec *spec = codec->spec;
|
|---|
| 150 |
|
|---|
| 151 | snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
|
|---|
| 152 | AC_VERB_SET_EAPD_BTLENABLE,
|
|---|
| 153 | brightness ? 0x02 : 0x00);
|
|---|
| 154 | return 0;
|
|---|
| 155 | }
|
|---|
| 156 | #endif /* NOT_USED */
|
|---|
| 157 |
|
|---|
| 158 | static void cxt_init_gpio_led(struct hda_codec *codec)
|
|---|
| 159 | {
|
|---|
| 160 | struct conexant_spec *spec = codec->spec;
|
|---|
| 161 | unsigned int mask = spec->gpio_mute_led_mask | spec->gpio_mic_led_mask;
|
|---|
| 162 |
|
|---|
| 163 | if (mask) {
|
|---|
| 164 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
|
|---|
| 165 | mask);
|
|---|
| 166 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
|
|---|
| 167 | mask);
|
|---|
| 168 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
|
|---|
| 169 | spec->gpio_led);
|
|---|
| 170 | }
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | static void cx_fixup_headset_recog(struct hda_codec *codec)
|
|---|
| 174 | {
|
|---|
| 175 | unsigned int mic_present;
|
|---|
| 176 |
|
|---|
| 177 | /* fix some headset type recognize fail issue, such as EDIFIER headset */
|
|---|
| 178 | /* set micbias output current comparator threshold from 66% to 55%. */
|
|---|
| 179 | snd_hda_codec_write(codec, 0x1c, 0, 0x320, 0x010);
|
|---|
| 180 | /* set OFF voltage for DFET from -1.2V to -0.8V, set headset micbias register
|
|---|
| 181 | * value adjustment trim from 2.2K ohms to 2.0K ohms.
|
|---|
| 182 | */
|
|---|
| 183 | snd_hda_codec_write(codec, 0x1c, 0, 0x3b0, 0xe10);
|
|---|
| 184 | /* fix reboot headset type recognize fail issue */
|
|---|
| 185 | mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
|
|---|
| 186 | if (mic_present & AC_PINSENSE_PRESENCE)
|
|---|
| 187 | /* enable headset mic VREF */
|
|---|
| 188 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
|
|---|
| 189 | else
|
|---|
| 190 | /* disable headset mic VREF */
|
|---|
| 191 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | static int cx_auto_init(struct hda_codec *codec)
|
|---|
| 195 | {
|
|---|
| 196 | struct conexant_spec *spec = codec->spec;
|
|---|
| 197 | snd_hda_gen_init(codec);
|
|---|
| 198 | if (!spec->dynamic_eapd)
|
|---|
| 199 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
|
|---|
| 200 |
|
|---|
| 201 | cxt_init_gpio_led(codec);
|
|---|
| 202 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
|
|---|
| 203 |
|
|---|
| 204 | if (spec->is_cx8070_sn6140)
|
|---|
| 205 | cx_fixup_headset_recog(codec);
|
|---|
| 206 |
|
|---|
| 207 | return 0;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | static void cx_auto_shutdown(struct hda_codec *codec)
|
|---|
| 211 | {
|
|---|
| 212 | struct conexant_spec *spec = codec->spec;
|
|---|
| 213 |
|
|---|
| 214 | /* Turn the problematic codec into D3 to avoid spurious noises
|
|---|
| 215 | from the internal speaker during (and after) reboot */
|
|---|
| 216 | cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | static void cx_auto_free(struct hda_codec *codec)
|
|---|
| 220 | {
|
|---|
| 221 | cx_auto_shutdown(codec);
|
|---|
| 222 | snd_hda_gen_free(codec);
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | static void cx_process_headset_plugin(struct hda_codec *codec)
|
|---|
| 226 | {
|
|---|
| 227 | unsigned int val;
|
|---|
| 228 | unsigned int count = 0;
|
|---|
| 229 |
|
|---|
| 230 | /* Wait headset detect done. */
|
|---|
| 231 | do {
|
|---|
| 232 | val = snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0);
|
|---|
| 233 | if (val & 0x080) {
|
|---|
| 234 | codec_dbg(codec, "headset type detect done!\n");
|
|---|
| 235 | break;
|
|---|
| 236 | }
|
|---|
| 237 | msleep(20);
|
|---|
| 238 | count++;
|
|---|
| 239 | } while (count < 3);
|
|---|
| 240 | val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
|
|---|
| 241 | if (val & 0x800) {
|
|---|
| 242 | codec_dbg(codec, "headset plugin, type is CTIA\n");
|
|---|
| 243 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
|
|---|
| 244 | } else if (val & 0x400) {
|
|---|
| 245 | codec_dbg(codec, "headset plugin, type is OMTP\n");
|
|---|
| 246 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
|
|---|
| 247 | } else {
|
|---|
| 248 | codec_dbg(codec, "headphone plugin\n");
|
|---|
| 249 | }
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event)
|
|---|
| 253 | {
|
|---|
| 254 | unsigned int mic_present;
|
|---|
| 255 |
|
|---|
| 256 | /* In cx8070 and sn6140, the node 16 can only be configured to headphone or disabled,
|
|---|
| 257 | * the node 19 can only be configured to microphone or disabled.
|
|---|
| 258 | * Check hp&mic tag to process headset plugin & plugout.
|
|---|
| 259 | */
|
|---|
| 260 | mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
|
|---|
| 261 | if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */
|
|---|
| 262 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
|
|---|
| 263 | else
|
|---|
| 264 | cx_process_headset_plugin(codec);
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | static int cx_auto_suspend(struct hda_codec *codec)
|
|---|
| 268 | {
|
|---|
| 269 | cx_auto_shutdown(codec);
|
|---|
| 270 | return 0;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | static const struct hda_codec_ops cx_auto_patch_ops = {
|
|---|
| 274 | .build_controls = snd_hda_gen_build_controls,
|
|---|
| 275 | .build_pcms = snd_hda_gen_build_pcms,
|
|---|
| 276 | .init = cx_auto_init,
|
|---|
| 277 | .free = cx_auto_free,
|
|---|
| 278 | .unsol_event = snd_hda_jack_unsol_event,
|
|---|
| 279 | .suspend = cx_auto_suspend,
|
|---|
| 280 | .check_power_status = snd_hda_gen_check_power_status,
|
|---|
| 281 | };
|
|---|
| 282 |
|
|---|
| 283 | /*
|
|---|
| 284 | * pin fix-up
|
|---|
| 285 | */
|
|---|
| 286 | enum {
|
|---|
| 287 | CXT_PINCFG_LENOVO_X200,
|
|---|
| 288 | CXT_PINCFG_LENOVO_TP410,
|
|---|
| 289 | CXT_PINCFG_LEMOTE_A1004,
|
|---|
| 290 | CXT_PINCFG_LEMOTE_A1205,
|
|---|
| 291 | CXT_PINCFG_COMPAQ_CQ60,
|
|---|
| 292 | CXT_FIXUP_STEREO_DMIC,
|
|---|
| 293 | CXT_PINCFG_LENOVO_NOTEBOOK,
|
|---|
| 294 | CXT_FIXUP_INC_MIC_BOOST,
|
|---|
| 295 | CXT_FIXUP_HEADPHONE_MIC_PIN,
|
|---|
| 296 | CXT_FIXUP_HEADPHONE_MIC,
|
|---|
| 297 | CXT_FIXUP_GPIO1,
|
|---|
| 298 | CXT_FIXUP_ASPIRE_DMIC,
|
|---|
| 299 | CXT_FIXUP_THINKPAD_ACPI,
|
|---|
| 300 | CXT_FIXUP_OLPC_XO,
|
|---|
| 301 | CXT_FIXUP_CAP_MIX_AMP,
|
|---|
| 302 | CXT_FIXUP_TOSHIBA_P105,
|
|---|
| 303 | CXT_FIXUP_HP_530,
|
|---|
| 304 | CXT_FIXUP_CAP_MIX_AMP_5047,
|
|---|
| 305 | CXT_FIXUP_MUTE_LED_EAPD,
|
|---|
| 306 | CXT_FIXUP_HP_DOCK,
|
|---|
| 307 | CXT_FIXUP_HP_SPECTRE,
|
|---|
| 308 | CXT_FIXUP_HP_GATE_MIC,
|
|---|
| 309 | CXT_FIXUP_MUTE_LED_GPIO,
|
|---|
| 310 | CXT_FIXUP_HP_ELITEONE_OUT_DIS,
|
|---|
| 311 | CXT_FIXUP_HP_ZBOOK_MUTE_LED,
|
|---|
| 312 | CXT_FIXUP_HEADSET_MIC,
|
|---|
| 313 | CXT_FIXUP_HP_MIC_NO_PRESENCE,
|
|---|
| 314 | CXT_PINCFG_SWS_JS201D,
|
|---|
| 315 | CXT_PINCFG_TOP_SPEAKER,
|
|---|
| 316 | CXT_FIXUP_HP_A_U,
|
|---|
| 317 | };
|
|---|
| 318 |
|
|---|
| 319 | /* for hda_fixup_thinkpad_acpi() */
|
|---|
| 320 | #include "thinkpad_helper.c"
|
|---|
| 321 |
|
|---|
| 322 | static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
|
|---|
| 323 | const struct hda_fixup *fix, int action)
|
|---|
| 324 | {
|
|---|
| 325 | struct conexant_spec *spec = codec->spec;
|
|---|
| 326 | spec->gen.inv_dmic_split = 1;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | /* fix widget control pin settings */
|
|---|
| 330 | static void cxt_fixup_update_pinctl(struct hda_codec *codec,
|
|---|
| 331 | const struct hda_fixup *fix, int action)
|
|---|
| 332 | {
|
|---|
| 333 | if (action == HDA_FIXUP_ACT_PROBE) {
|
|---|
| 334 | /* Unset OUT_EN for this Node pin, leaving only HP_EN.
|
|---|
| 335 | * This is the value stored in the codec register after
|
|---|
| 336 | * the correct initialization of the previous windows boot.
|
|---|
| 337 | */
|
|---|
| 338 | snd_hda_set_pin_ctl_cache(codec, 0x1d, AC_PINCTL_HP_EN);
|
|---|
| 339 | }
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | static void cxt5066_increase_mic_boost(struct hda_codec *codec,
|
|---|
| 343 | const struct hda_fixup *fix, int action)
|
|---|
| 344 | {
|
|---|
| 345 | if (action != HDA_FIXUP_ACT_PRE_PROBE)
|
|---|
| 346 | return;
|
|---|
| 347 |
|
|---|
| 348 | snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
|
|---|
| 349 | (0x3 << AC_AMPCAP_OFFSET_SHIFT) |
|
|---|
| 350 | (0x4 << AC_AMPCAP_NUM_STEPS_SHIFT) |
|
|---|
| 351 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
|
|---|
| 352 | (0 << AC_AMPCAP_MUTE_SHIFT));
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | static void cxt_update_headset_mode(struct hda_codec *codec)
|
|---|
| 356 | {
|
|---|
| 357 | /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
|
|---|
| 358 | int i;
|
|---|
| 359 | bool mic_mode = false;
|
|---|
| 360 | struct conexant_spec *spec = codec->spec;
|
|---|
| 361 | struct auto_pin_cfg *cfg = &spec->gen.autocfg;
|
|---|
| 362 |
|
|---|
| 363 | hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
|
|---|
| 364 |
|
|---|
| 365 | for (i = 0; i < cfg->num_inputs; i++)
|
|---|
| 366 | if (cfg->inputs[i].pin == mux_pin) {
|
|---|
| 367 | mic_mode = !!cfg->inputs[i].is_headphone_mic;
|
|---|
| 368 | break;
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | if (mic_mode) {
|
|---|
| 372 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
|
|---|
| 373 | spec->gen.hp_jack_present = false;
|
|---|
| 374 | } else {
|
|---|
| 375 | snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
|
|---|
| 376 | spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]);
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | snd_hda_gen_update_outputs(codec);
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | static void cxt_update_headset_mode_hook(struct hda_codec *codec,
|
|---|
| 383 | struct snd_kcontrol *kcontrol,
|
|---|
| 384 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 385 | {
|
|---|
| 386 | cxt_update_headset_mode(codec);
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | static void cxt_fixup_headphone_mic(struct hda_codec *codec,
|
|---|
| 390 | const struct hda_fixup *fix, int action)
|
|---|
| 391 | {
|
|---|
| 392 | struct conexant_spec *spec = codec->spec;
|
|---|
| 393 |
|
|---|
| 394 | switch (action) {
|
|---|
| 395 | case HDA_FIXUP_ACT_PRE_PROBE:
|
|---|
| 396 | spec->parse_flags |= HDA_PINCFG_HEADPHONE_MIC;
|
|---|
| 397 | snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410);
|
|---|
| 398 | break;
|
|---|
| 399 | case HDA_FIXUP_ACT_PROBE:
|
|---|
| 400 | WARN_ON(spec->gen.cap_sync_hook);
|
|---|
| 401 | spec->gen.cap_sync_hook = cxt_update_headset_mode_hook;
|
|---|
| 402 | spec->gen.automute_hook = cxt_update_headset_mode;
|
|---|
| 403 | break;
|
|---|
| 404 | case HDA_FIXUP_ACT_INIT:
|
|---|
| 405 | cxt_update_headset_mode(codec);
|
|---|
| 406 | break;
|
|---|
| 407 | }
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | static void cxt_fixup_headset_mic(struct hda_codec *codec,
|
|---|
| 411 | const struct hda_fixup *fix, int action)
|
|---|
| 412 | {
|
|---|
| 413 | struct conexant_spec *spec = codec->spec;
|
|---|
| 414 |
|
|---|
| 415 | switch (action) {
|
|---|
| 416 | case HDA_FIXUP_ACT_PRE_PROBE:
|
|---|
| 417 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
|
|---|
| 418 | break;
|
|---|
| 419 | }
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | /* OPLC XO 1.5 fixup */
|
|---|
| 423 |
|
|---|
| 424 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
|
|---|
| 425 | * through the microphone jack.
|
|---|
| 426 | * When the user enables this through a mixer switch, both internal and
|
|---|
| 427 | * external microphones are disabled. Gain is fixed at 0dB. In this mode,
|
|---|
| 428 | * we also allow the bias to be configured through a separate mixer
|
|---|
| 429 | * control. */
|
|---|
| 430 |
|
|---|
| 431 | #define update_mic_pin(codec, nid, val) \
|
|---|
| 432 | snd_hda_codec_write_cache(codec, nid, 0, \
|
|---|
| 433 | AC_VERB_SET_PIN_WIDGET_CONTROL, val)
|
|---|
| 434 |
|
|---|
| 435 | static const struct hda_input_mux olpc_xo_dc_bias = {
|
|---|
| 436 | .num_items = 3,
|
|---|
| 437 | .items = {
|
|---|
| 438 | { "Off", PIN_IN },
|
|---|
| 439 | { "50%", PIN_VREF50 },
|
|---|
| 440 | { "80%", PIN_VREF80 },
|
|---|
| 441 | },
|
|---|
| 442 | };
|
|---|
| 443 |
|
|---|
| 444 | static void olpc_xo_update_mic_boost(struct hda_codec *codec)
|
|---|
| 445 | {
|
|---|
| 446 | struct conexant_spec *spec = codec->spec;
|
|---|
| 447 | int ch, val;
|
|---|
| 448 |
|
|---|
| 449 | for (ch = 0; ch < 2; ch++) {
|
|---|
| 450 | val = AC_AMP_SET_OUTPUT |
|
|---|
| 451 | (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT);
|
|---|
| 452 | if (!spec->dc_enable)
|
|---|
| 453 | val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
|
|---|
| 454 | snd_hda_codec_write(codec, 0x17, 0,
|
|---|
| 455 | AC_VERB_SET_AMP_GAIN_MUTE, val);
|
|---|
| 456 | }
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | static void olpc_xo_update_mic_pins(struct hda_codec *codec)
|
|---|
| 460 | {
|
|---|
| 461 | struct conexant_spec *spec = codec->spec;
|
|---|
| 462 | int cur_input, val;
|
|---|
| 463 | struct nid_path *path;
|
|---|
| 464 |
|
|---|
| 465 | cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]];
|
|---|
| 466 |
|
|---|
| 467 | /* Set up mic pins for port-B, C and F dynamically as the recording
|
|---|
| 468 | * LED is turned on/off by these pin controls
|
|---|
| 469 | */
|
|---|
| 470 | if (!spec->dc_enable) {
|
|---|
| 471 | /* disable DC bias path and pin for port F */
|
|---|
| 472 | update_mic_pin(codec, 0x1e, 0);
|
|---|
| 473 | snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
|
|---|
| 474 |
|
|---|
| 475 | /* update port B (ext mic) and C (int mic) */
|
|---|
| 476 | /* OLPC defers mic widget control until when capture is
|
|---|
| 477 | * started because the microphone LED comes on as soon as
|
|---|
| 478 | * these settings are put in place. if we did this before
|
|---|
| 479 | * recording, it would give the false indication that
|
|---|
| 480 | * recording is happening when it is not.
|
|---|
| 481 | */
|
|---|
| 482 | update_mic_pin(codec, 0x1a, spec->recording ?
|
|---|
| 483 | snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
|
|---|
| 484 | update_mic_pin(codec, 0x1b, spec->recording ?
|
|---|
| 485 | snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
|
|---|
| 486 | /* enable normal mic path */
|
|---|
| 487 | path = snd_hda_get_path_from_idx(codec, cur_input);
|
|---|
| 488 | if (path)
|
|---|
| 489 | snd_hda_activate_path(codec, path, true, false);
|
|---|
| 490 | } else {
|
|---|
| 491 | /* disable normal mic path */
|
|---|
| 492 | path = snd_hda_get_path_from_idx(codec, cur_input);
|
|---|
| 493 | if (path)
|
|---|
| 494 | snd_hda_activate_path(codec, path, false, false);
|
|---|
| 495 |
|
|---|
| 496 | /* Even though port F is the DC input, the bias is controlled
|
|---|
| 497 | * on port B. We also leave that port as an active input (but
|
|---|
| 498 | * unselected) in DC mode just in case that is necessary to
|
|---|
| 499 | * make the bias setting take effect.
|
|---|
| 500 | */
|
|---|
| 501 | if (spec->recording)
|
|---|
| 502 | val = olpc_xo_dc_bias.items[spec->dc_input_bias].index;
|
|---|
| 503 | else
|
|---|
| 504 | val = 0;
|
|---|
| 505 | update_mic_pin(codec, 0x1a, val);
|
|---|
| 506 | update_mic_pin(codec, 0x1b, 0);
|
|---|
| 507 | /* enable DC bias path and pin */
|
|---|
| 508 | update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
|
|---|
| 509 | snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
|
|---|
| 510 | }
|
|---|
| 511 | }
|
|---|
| 512 |
|
|---|
| 513 | /* mic_autoswitch hook */
|
|---|
| 514 | static void olpc_xo_automic(struct hda_codec *codec,
|
|---|
| 515 | struct hda_jack_callback *jack)
|
|---|
| 516 | {
|
|---|
| 517 | struct conexant_spec *spec = codec->spec;
|
|---|
| 518 |
|
|---|
| 519 | /* in DC mode, we don't handle automic */
|
|---|
| 520 | if (!spec->dc_enable)
|
|---|
| 521 | snd_hda_gen_mic_autoswitch(codec, jack);
|
|---|
| 522 | olpc_xo_update_mic_pins(codec);
|
|---|
| 523 | if (spec->dc_enable)
|
|---|
| 524 | olpc_xo_update_mic_boost(codec);
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 | /* pcm_capture hook */
|
|---|
| 528 | static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo,
|
|---|
| 529 | struct hda_codec *codec,
|
|---|
| 530 | struct snd_pcm_substream *substream,
|
|---|
| 531 | int action)
|
|---|
| 532 | {
|
|---|
| 533 | struct conexant_spec *spec = codec->spec;
|
|---|
| 534 |
|
|---|
| 535 | /* toggle spec->recording flag and update mic pins accordingly
|
|---|
| 536 | * for turning on/off LED
|
|---|
| 537 | */
|
|---|
| 538 | switch (action) {
|
|---|
| 539 | case HDA_GEN_PCM_ACT_PREPARE:
|
|---|
| 540 | spec->recording = 1;
|
|---|
| 541 | olpc_xo_update_mic_pins(codec);
|
|---|
| 542 | break;
|
|---|
| 543 | case HDA_GEN_PCM_ACT_CLEANUP:
|
|---|
| 544 | spec->recording = 0;
|
|---|
| 545 | olpc_xo_update_mic_pins(codec);
|
|---|
| 546 | break;
|
|---|
| 547 | }
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol,
|
|---|
| 551 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 552 | {
|
|---|
| 553 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 554 | struct conexant_spec *spec = codec->spec;
|
|---|
| 555 | ucontrol->value.integer.value[0] = spec->dc_enable;
|
|---|
| 556 | return 0;
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol,
|
|---|
| 560 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 561 | {
|
|---|
| 562 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 563 | struct conexant_spec *spec = codec->spec;
|
|---|
| 564 | int dc_enable = !!ucontrol->value.integer.value[0];
|
|---|
| 565 |
|
|---|
| 566 | if (dc_enable == spec->dc_enable)
|
|---|
| 567 | return 0;
|
|---|
| 568 |
|
|---|
| 569 | spec->dc_enable = dc_enable;
|
|---|
| 570 | olpc_xo_update_mic_pins(codec);
|
|---|
| 571 | olpc_xo_update_mic_boost(codec);
|
|---|
| 572 | return 1;
|
|---|
| 573 | }
|
|---|
| 574 |
|
|---|
| 575 | static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
|
|---|
| 576 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 577 | {
|
|---|
| 578 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 579 | struct conexant_spec *spec = codec->spec;
|
|---|
| 580 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
|
|---|
| 581 | return 0;
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 | static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
|
|---|
| 585 | struct snd_ctl_elem_info *uinfo)
|
|---|
| 586 | {
|
|---|
| 587 | return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo);
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
|
|---|
| 591 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 592 | {
|
|---|
| 593 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 594 | struct conexant_spec *spec = codec->spec;
|
|---|
| 595 | const struct hda_input_mux *imux = &olpc_xo_dc_bias;
|
|---|
| 596 | unsigned int idx;
|
|---|
| 597 |
|
|---|
| 598 | idx = ucontrol->value.enumerated.item[0];
|
|---|
| 599 | if (idx >= imux->num_items)
|
|---|
| 600 | idx = imux->num_items - 1;
|
|---|
| 601 | if (spec->dc_input_bias == idx)
|
|---|
| 602 | return 0;
|
|---|
| 603 |
|
|---|
| 604 | spec->dc_input_bias = idx;
|
|---|
| 605 | if (spec->dc_enable)
|
|---|
| 606 | olpc_xo_update_mic_pins(codec);
|
|---|
| 607 | return 1;
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | static const struct snd_kcontrol_new olpc_xo_mixers[] = {
|
|---|
| 611 | {
|
|---|
| 612 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|---|
| 613 | .name = "DC Mode Enable Switch",
|
|---|
| 614 | .info = snd_ctl_boolean_mono_info,
|
|---|
| 615 | .get = olpc_xo_dc_mode_get,
|
|---|
| 616 | .put = olpc_xo_dc_mode_put,
|
|---|
| 617 | },
|
|---|
| 618 | {
|
|---|
| 619 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|---|
| 620 | .name = "DC Input Bias Enum",
|
|---|
| 621 | .info = olpc_xo_dc_bias_enum_info,
|
|---|
| 622 | .get = olpc_xo_dc_bias_enum_get,
|
|---|
| 623 | .put = olpc_xo_dc_bias_enum_put,
|
|---|
| 624 | },
|
|---|
| 625 | {0}
|
|---|
| 626 | };
|
|---|
| 627 |
|
|---|
| 628 | /* overriding mic boost put callback; update mic boost volume only when
|
|---|
| 629 | * DC mode is disabled
|
|---|
| 630 | */
|
|---|
| 631 | static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol,
|
|---|
| 632 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 633 | {
|
|---|
| 634 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 635 | struct conexant_spec *spec = codec->spec;
|
|---|
| 636 | int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
|
|---|
| 637 | if (ret > 0 && spec->dc_enable)
|
|---|
| 638 | olpc_xo_update_mic_boost(codec);
|
|---|
| 639 | return ret;
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | static void cxt_fixup_olpc_xo(struct hda_codec *codec,
|
|---|
| 643 | const struct hda_fixup *fix, int action)
|
|---|
| 644 | {
|
|---|
| 645 | struct conexant_spec *spec = codec->spec;
|
|---|
| 646 | struct snd_kcontrol_new *kctl;
|
|---|
| 647 | int i;
|
|---|
| 648 |
|
|---|
| 649 | if (action != HDA_FIXUP_ACT_PROBE)
|
|---|
| 650 | return;
|
|---|
| 651 |
|
|---|
| 652 | spec->gen.mic_autoswitch_hook = olpc_xo_automic;
|
|---|
| 653 | spec->gen.pcm_capture_hook = olpc_xo_capture_hook;
|
|---|
| 654 | spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
|
|---|
| 655 |
|
|---|
| 656 | snd_hda_add_new_ctls(codec, olpc_xo_mixers);
|
|---|
| 657 |
|
|---|
| 658 | /* OLPC's microphone port is DC coupled for use with external sensors,
|
|---|
| 659 | * therefore we use a 50% mic bias in order to center the input signal
|
|---|
| 660 | * with the DC input range of the codec.
|
|---|
| 661 | */
|
|---|
| 662 | snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
|
|---|
| 663 |
|
|---|
| 664 | /* override mic boost control */
|
|---|
| 665 | snd_array_for_each(&spec->gen.kctls, i, kctl) {
|
|---|
| 666 | if (!strcmp(kctl->name, "Mic Boost Volume")) {
|
|---|
| 667 | kctl->put = olpc_xo_mic_boost_put;
|
|---|
| 668 | break;
|
|---|
| 669 | }
|
|---|
| 670 | }
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
|
|---|
| 674 | const struct hda_fixup *fix, int action)
|
|---|
| 675 | {
|
|---|
| 676 | struct conexant_spec *spec = codec->spec;
|
|---|
| 677 |
|
|---|
| 678 | if (action == HDA_FIXUP_ACT_PRE_PROBE) {
|
|---|
| 679 | spec->mute_led_eapd = 0x1b;
|
|---|
| 680 | spec->dynamic_eapd = true;
|
|---|
| 681 | #ifdef CONFIG_SND_HDA_GENERIC_LEDS
|
|---|
| 682 | snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led);
|
|---|
| 683 | #endif
|
|---|
| 684 | }
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | /*
|
|---|
| 688 | * Fix max input level on mixer widget to 0dB
|
|---|
| 689 | * (originally it has 0x2b steps with 0dB offset 0x14)
|
|---|
| 690 | */
|
|---|
| 691 | static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
|
|---|
| 692 | const struct hda_fixup *fix, int action)
|
|---|
| 693 | {
|
|---|
| 694 | snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
|
|---|
| 695 | (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
|
|---|
| 696 | (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
|
|---|
| 697 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
|
|---|
| 698 | (1 << AC_AMPCAP_MUTE_SHIFT));
|
|---|
| 699 | }
|
|---|
| 700 |
|
|---|
| 701 | /*
|
|---|
| 702 | * Fix max input level on mixer widget to 0dB
|
|---|
| 703 | * (originally it has 0x1e steps with 0 dB offset 0x17)
|
|---|
| 704 | */
|
|---|
| 705 | static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
|
|---|
| 706 | const struct hda_fixup *fix, int action)
|
|---|
| 707 | {
|
|---|
| 708 | snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
|
|---|
| 709 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
|
|---|
| 710 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
|
|---|
| 711 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
|
|---|
| 712 | (1 << AC_AMPCAP_MUTE_SHIFT));
|
|---|
| 713 | }
|
|---|
| 714 |
|
|---|
| 715 | static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec,
|
|---|
| 716 | const struct hda_fixup *fix,
|
|---|
| 717 | int action)
|
|---|
| 718 | {
|
|---|
| 719 | /* the mic pin (0x19) doesn't give an unsolicited event;
|
|---|
| 720 | * probe the mic pin together with the headphone pin (0x16)
|
|---|
| 721 | */
|
|---|
| 722 | if (action == HDA_FIXUP_ACT_PROBE)
|
|---|
| 723 | snd_hda_jack_set_gating_jack(codec, 0x19, 0x16);
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | #ifdef NOT_USED
|
|---|
| 727 | /* update LED status via GPIO */
|
|---|
| 728 | static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask,
|
|---|
| 729 | bool led_on)
|
|---|
| 730 | {
|
|---|
| 731 | struct conexant_spec *spec = codec->spec;
|
|---|
| 732 | unsigned int oldval = spec->gpio_led;
|
|---|
| 733 |
|
|---|
| 734 | if (spec->mute_led_polarity)
|
|---|
| 735 | led_on = !led_on;
|
|---|
| 736 |
|
|---|
| 737 | if (led_on)
|
|---|
| 738 | spec->gpio_led |= mask;
|
|---|
| 739 | else
|
|---|
| 740 | spec->gpio_led &= ~mask;
|
|---|
| 741 | codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n",
|
|---|
| 742 | mask, led_on, spec->gpio_led);
|
|---|
| 743 | if (spec->gpio_led != oldval)
|
|---|
| 744 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
|
|---|
| 745 | spec->gpio_led);
|
|---|
| 746 | }
|
|---|
| 747 |
|
|---|
| 748 | /* turn on/off mute LED via GPIO per vmaster hook */
|
|---|
| 749 | static int cxt_gpio_mute_update(struct led_classdev *led_cdev,
|
|---|
| 750 | enum led_brightness brightness)
|
|---|
| 751 | {
|
|---|
| 752 | struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
|
|---|
| 753 | struct conexant_spec *spec = codec->spec;
|
|---|
| 754 |
|
|---|
| 755 | cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness);
|
|---|
| 756 | return 0;
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 | /* turn on/off mic-mute LED via GPIO per capture hook */
|
|---|
| 760 | static int cxt_gpio_micmute_update(struct led_classdev *led_cdev,
|
|---|
| 761 | enum led_brightness brightness)
|
|---|
| 762 | {
|
|---|
| 763 | struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
|
|---|
| 764 | struct conexant_spec *spec = codec->spec;
|
|---|
| 765 |
|
|---|
| 766 | cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness);
|
|---|
| 767 | return 0;
|
|---|
| 768 | }
|
|---|
| 769 | #endif /* NOT_USED */
|
|---|
| 770 |
|
|---|
| 771 | static void cxt_setup_mute_led(struct hda_codec *codec,
|
|---|
| 772 | unsigned int mute, unsigned int mic_mute)
|
|---|
| 773 | {
|
|---|
| 774 | struct conexant_spec *spec = codec->spec;
|
|---|
| 775 |
|
|---|
| 776 | spec->gpio_led = 0;
|
|---|
| 777 | spec->mute_led_polarity = 0;
|
|---|
| 778 | #ifdef NOT_USED
|
|---|
| 779 | if (mute) {
|
|---|
| 780 | snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update);
|
|---|
| 781 | spec->gpio_mute_led_mask = mute;
|
|---|
| 782 | }
|
|---|
| 783 | if (mic_mute) {
|
|---|
| 784 | snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update);
|
|---|
| 785 | spec->gpio_mic_led_mask = mic_mute;
|
|---|
| 786 | }
|
|---|
| 787 | #endif /* NOT_USED */
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 | static void cxt_setup_gpio_unmute(struct hda_codec *codec,
|
|---|
| 791 | unsigned int gpio_mute_mask)
|
|---|
| 792 | {
|
|---|
| 793 | if (gpio_mute_mask) {
|
|---|
| 794 | // set gpio data to 0.
|
|---|
| 795 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
|
|---|
| 796 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, gpio_mute_mask);
|
|---|
| 797 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, gpio_mute_mask);
|
|---|
| 798 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_STICKY_MASK, 0);
|
|---|
| 799 | }
|
|---|
| 800 | }
|
|---|
| 801 |
|
|---|
| 802 | static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
|
|---|
| 803 | const struct hda_fixup *fix, int action)
|
|---|
| 804 | {
|
|---|
| 805 | if (action == HDA_FIXUP_ACT_PRE_PROBE)
|
|---|
| 806 | cxt_setup_mute_led(codec, 0x01, 0x02);
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | static void cxt_fixup_hp_zbook_mute_led(struct hda_codec *codec,
|
|---|
| 810 | const struct hda_fixup *fix, int action)
|
|---|
| 811 | {
|
|---|
| 812 | if (action == HDA_FIXUP_ACT_PRE_PROBE)
|
|---|
| 813 | cxt_setup_mute_led(codec, 0x10, 0x20);
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 | static void cxt_fixup_hp_a_u(struct hda_codec *codec,
|
|---|
| 817 | const struct hda_fixup *fix, int action)
|
|---|
| 818 | {
|
|---|
| 819 | // Init vers in BIOS mute the spk/hp by set gpio high to avoid pop noise,
|
|---|
| 820 | // so need to unmute once by clearing the gpio data when runs into the system.
|
|---|
| 821 | if (action == HDA_FIXUP_ACT_INIT)
|
|---|
| 822 | cxt_setup_gpio_unmute(codec, 0x2);
|
|---|
| 823 | }
|
|---|
| 824 |
|
|---|
| 825 | /* ThinkPad X200 & co with cxt5051 */
|
|---|
| 826 | static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
|
|---|
| 827 | { 0x16, 0x042140ff }, /* HP (seq# overridden) */
|
|---|
| 828 | { 0x17, 0x21a11000 }, /* dock-mic */
|
|---|
| 829 | { 0x19, 0x2121103f }, /* dock-HP */
|
|---|
| 830 | { 0x1c, 0x21440100 }, /* dock SPDIF out */
|
|---|
| 831 | {0}
|
|---|
| 832 | };
|
|---|
| 833 |
|
|---|
| 834 | /* ThinkPad 410/420/510/520, X201 & co with cxt5066 */
|
|---|
| 835 | static const struct hda_pintbl cxt_pincfg_lenovo_tp410[] = {
|
|---|
| 836 | { 0x19, 0x042110ff }, /* HP (seq# overridden) */
|
|---|
| 837 | { 0x1a, 0x21a190f0 }, /* dock-mic */
|
|---|
| 838 | { 0x1c, 0x212140ff }, /* dock-HP */
|
|---|
| 839 | {0}
|
|---|
| 840 | };
|
|---|
| 841 |
|
|---|
| 842 | /* Lemote A1004/A1205 with cxt5066 */
|
|---|
| 843 | static const struct hda_pintbl cxt_pincfg_lemote[] = {
|
|---|
| 844 | { 0x1a, 0x90a10020 }, /* Internal mic */
|
|---|
| 845 | { 0x1b, 0x03a11020 }, /* External mic */
|
|---|
| 846 | { 0x1d, 0x400101f0 }, /* Not used */
|
|---|
| 847 | { 0x1e, 0x40a701f0 }, /* Not used */
|
|---|
| 848 | { 0x20, 0x404501f0 }, /* Not used */
|
|---|
| 849 | { 0x22, 0x404401f0 }, /* Not used */
|
|---|
| 850 | { 0x23, 0x40a701f0 }, /* Not used */
|
|---|
| 851 | {0}
|
|---|
| 852 | };
|
|---|
| 853 |
|
|---|
| 854 | #ifdef TARGET_OS2
|
|---|
| 855 | static const struct hda_pintbl CXT_FIXUP_HEADPHONE_MIC_PIN_PINS[] = {
|
|---|
| 856 | { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
|
|---|
| 857 | {0}
|
|---|
| 858 | };
|
|---|
| 859 |
|
|---|
| 860 | static const struct hda_verb CXT_FIXUP_GPIO1_VERBS[] = {
|
|---|
| 861 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
|
|---|
| 862 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
|
|---|
| 863 | { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 },
|
|---|
| 864 | {0}
|
|---|
| 865 | };
|
|---|
| 866 |
|
|---|
| 867 | static const struct hda_pintbl CXT_FIXUP_TOSHIBA_P105_PINS[] = {
|
|---|
| 868 | { 0x10, 0x961701f0 }, /* speaker/hp */
|
|---|
| 869 | { 0x12, 0x02a1901e }, /* ext mic */
|
|---|
| 870 | { 0x14, 0x95a70110 }, /* int mic */
|
|---|
| 871 | {0}
|
|---|
| 872 | };
|
|---|
| 873 |
|
|---|
| 874 | static const struct hda_pintbl CXT_FIXUP_HP_530_PINS[] = {
|
|---|
| 875 | { 0x12, 0x90a60160 }, /* int mic */
|
|---|
| 876 | {0}
|
|---|
| 877 | };
|
|---|
| 878 | #endif
|
|---|
| 879 |
|
|---|
| 880 | /* SuoWoSi/South-holding JS201D with sn6140 */
|
|---|
| 881 | static const struct hda_pintbl cxt_pincfg_sws_js201d[] = {
|
|---|
| 882 | { 0x16, 0x03211040 }, /* hp out */
|
|---|
| 883 | { 0x17, 0x91170110 }, /* SPK/Class_D */
|
|---|
| 884 | { 0x18, 0x95a70130 }, /* Internal mic */
|
|---|
| 885 | { 0x19, 0x03a11020 }, /* Headset Mic */
|
|---|
| 886 | { 0x1a, 0x40f001f0 }, /* Not used */
|
|---|
| 887 | { 0x21, 0x40f001f0 }, /* Not used */
|
|---|
| 888 | {0}
|
|---|
| 889 | };
|
|---|
| 890 |
|
|---|
| 891 | static const struct hda_fixup cxt_fixups[] = {
|
|---|
| 892 | [CXT_PINCFG_LENOVO_X200] = {
|
|---|
| 893 | .type = HDA_FIXUP_PINS,
|
|---|
| 894 | .v.pins = cxt_pincfg_lenovo_x200,
|
|---|
| 895 | },
|
|---|
| 896 | [CXT_PINCFG_LENOVO_TP410] = {
|
|---|
| 897 | .type = HDA_FIXUP_PINS,
|
|---|
| 898 | .v.pins = cxt_pincfg_lenovo_tp410,
|
|---|
| 899 | .chained = true,
|
|---|
| 900 | .chain_id = CXT_FIXUP_THINKPAD_ACPI,
|
|---|
| 901 | },
|
|---|
| 902 | [CXT_PINCFG_LEMOTE_A1004] = {
|
|---|
| 903 | .type = HDA_FIXUP_PINS,
|
|---|
| 904 | .chained = true,
|
|---|
| 905 | .chain_id = CXT_FIXUP_INC_MIC_BOOST,
|
|---|
| 906 | .v.pins = cxt_pincfg_lemote,
|
|---|
| 907 | },
|
|---|
| 908 | [CXT_PINCFG_LEMOTE_A1205] = {
|
|---|
| 909 | .type = HDA_FIXUP_PINS,
|
|---|
| 910 | .v.pins = cxt_pincfg_lemote,
|
|---|
| 911 | },
|
|---|
| 912 | #ifdef NOT_USED
|
|---|
| 913 | [CXT_PINCFG_COMPAQ_CQ60] = {
|
|---|
| 914 | .type = HDA_FIXUP_PINS,
|
|---|
| 915 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 916 | /* 0x17 was falsely set up as a mic, it should 0x1d */
|
|---|
| 917 | { 0x17, 0x400001f0 },
|
|---|
| 918 | { 0x1d, 0x97a70120 },
|
|---|
| 919 | {0}
|
|---|
| 920 | }
|
|---|
| 921 | },
|
|---|
| 922 | #endif
|
|---|
| 923 | [CXT_FIXUP_STEREO_DMIC] = {
|
|---|
| 924 | .type = HDA_FIXUP_FUNC,
|
|---|
| 925 | .v.func = cxt_fixup_stereo_dmic,
|
|---|
| 926 | },
|
|---|
| 927 | #ifdef NOT_USED
|
|---|
| 928 | [CXT_PINCFG_LENOVO_NOTEBOOK] = {
|
|---|
| 929 | .type = HDA_FIXUP_PINS,
|
|---|
| 930 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 931 | { 0x1a, 0x05d71030 },
|
|---|
| 932 | { }
|
|---|
| 933 | },
|
|---|
| 934 | .chain_id = CXT_FIXUP_STEREO_DMIC,
|
|---|
| 935 | },
|
|---|
| 936 | #endif
|
|---|
| 937 | [CXT_FIXUP_INC_MIC_BOOST] = {
|
|---|
| 938 | .type = HDA_FIXUP_FUNC,
|
|---|
| 939 | .v.func = cxt5066_increase_mic_boost,
|
|---|
| 940 | },
|
|---|
| 941 | [CXT_FIXUP_HEADPHONE_MIC_PIN] = {
|
|---|
| 942 | .type = HDA_FIXUP_PINS,
|
|---|
| 943 | .chained = true,
|
|---|
| 944 | .chain_id = CXT_FIXUP_HEADPHONE_MIC,
|
|---|
| 945 | #ifndef TARGET_OS2
|
|---|
| 946 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 947 | { 0x18, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
|
|---|
| 948 | {0}
|
|---|
| 949 | }
|
|---|
| 950 | #else
|
|---|
| 951 | .v.pins = CXT_FIXUP_HEADPHONE_MIC_PIN_PINS
|
|---|
| 952 | #endif
|
|---|
| 953 | },
|
|---|
| 954 | [CXT_FIXUP_HEADPHONE_MIC] = {
|
|---|
| 955 | .type = HDA_FIXUP_FUNC,
|
|---|
| 956 | .v.func = cxt_fixup_headphone_mic,
|
|---|
| 957 | },
|
|---|
| 958 | [CXT_FIXUP_GPIO1] = {
|
|---|
| 959 | .type = HDA_FIXUP_VERBS,
|
|---|
| 960 | #ifndef TARGET_OS2
|
|---|
| 961 | .v.verbs = (const struct hda_verb[]) {
|
|---|
| 962 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
|
|---|
| 963 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
|
|---|
| 964 | { 0x01, AC_VERB_SET_GPIO_DATA, 0x01 },
|
|---|
| 965 | {0}
|
|---|
| 966 | },
|
|---|
| 967 | #else
|
|---|
| 968 | .v.verbs = CXT_FIXUP_GPIO1_VERBS,
|
|---|
| 969 | #endif
|
|---|
| 970 | },
|
|---|
| 971 | [CXT_FIXUP_ASPIRE_DMIC] = {
|
|---|
| 972 | .type = HDA_FIXUP_FUNC,
|
|---|
| 973 | .v.func = cxt_fixup_stereo_dmic,
|
|---|
| 974 | .chained = true,
|
|---|
| 975 | .chain_id = CXT_FIXUP_GPIO1,
|
|---|
| 976 | },
|
|---|
| 977 | [CXT_FIXUP_THINKPAD_ACPI] = {
|
|---|
| 978 | .type = HDA_FIXUP_FUNC,
|
|---|
| 979 | .v.func = hda_fixup_thinkpad_acpi,
|
|---|
| 980 | },
|
|---|
| 981 | [CXT_FIXUP_OLPC_XO] = {
|
|---|
| 982 | .type = HDA_FIXUP_FUNC,
|
|---|
| 983 | .v.func = cxt_fixup_olpc_xo,
|
|---|
| 984 | },
|
|---|
| 985 | [CXT_FIXUP_CAP_MIX_AMP] = {
|
|---|
| 986 | .type = HDA_FIXUP_FUNC,
|
|---|
| 987 | .v.func = cxt_fixup_cap_mix_amp,
|
|---|
| 988 | },
|
|---|
| 989 | [CXT_FIXUP_TOSHIBA_P105] = {
|
|---|
| 990 | .type = HDA_FIXUP_PINS,
|
|---|
| 991 | #ifndef TARGET_OS2
|
|---|
| 992 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 993 | { 0x10, 0x961701f0 }, /* speaker/hp */
|
|---|
| 994 | { 0x12, 0x02a1901e }, /* ext mic */
|
|---|
| 995 | { 0x14, 0x95a70110 }, /* int mic */
|
|---|
| 996 | {0}
|
|---|
| 997 | },
|
|---|
| 998 | #else
|
|---|
| 999 | .v.pins = CXT_FIXUP_TOSHIBA_P105_PINS,
|
|---|
| 1000 | #endif
|
|---|
| 1001 | },
|
|---|
| 1002 | [CXT_FIXUP_HP_530] = {
|
|---|
| 1003 | .type = HDA_FIXUP_PINS,
|
|---|
| 1004 | #ifndef TARGET_OS2
|
|---|
| 1005 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 1006 | { 0x12, 0x90a60160 }, /* int mic */
|
|---|
| 1007 | {0}
|
|---|
| 1008 | },
|
|---|
| 1009 | #else
|
|---|
| 1010 | .v.pins = CXT_FIXUP_HP_530_PINS,
|
|---|
| 1011 | #endif
|
|---|
| 1012 | .chained = true,
|
|---|
| 1013 | .chain_id = CXT_FIXUP_CAP_MIX_AMP,
|
|---|
| 1014 | },
|
|---|
| 1015 | [CXT_FIXUP_CAP_MIX_AMP_5047] = {
|
|---|
| 1016 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1017 | .v.func = cxt_fixup_cap_mix_amp_5047,
|
|---|
| 1018 | },
|
|---|
| 1019 | [CXT_FIXUP_MUTE_LED_EAPD] = {
|
|---|
| 1020 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1021 | .v.func = cxt_fixup_mute_led_eapd,
|
|---|
| 1022 | },
|
|---|
| 1023 | #ifdef NOT_USED
|
|---|
| 1024 | [CXT_FIXUP_HP_DOCK] = {
|
|---|
| 1025 | .type = HDA_FIXUP_PINS,
|
|---|
| 1026 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 1027 | { 0x16, 0x21011020 }, /* line-out */
|
|---|
| 1028 | { 0x18, 0x2181103f }, /* line-in */
|
|---|
| 1029 | {0}
|
|---|
| 1030 | },
|
|---|
| 1031 | .chained = true,
|
|---|
| 1032 | .chain_id = CXT_FIXUP_MUTE_LED_GPIO,
|
|---|
| 1033 | },
|
|---|
| 1034 | [CXT_FIXUP_HP_SPECTRE] = {
|
|---|
| 1035 | .type = HDA_FIXUP_PINS,
|
|---|
| 1036 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 1037 | /* enable NID 0x1d for the speaker on top */
|
|---|
| 1038 | { 0x1d, 0x91170111 },
|
|---|
| 1039 | {0}
|
|---|
| 1040 | }
|
|---|
| 1041 | },
|
|---|
| 1042 | #endif
|
|---|
| 1043 | [CXT_FIXUP_HP_GATE_MIC] = {
|
|---|
| 1044 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1045 | .v.func = cxt_fixup_hp_gate_mic_jack,
|
|---|
| 1046 | },
|
|---|
| 1047 | [CXT_FIXUP_MUTE_LED_GPIO] = {
|
|---|
| 1048 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1049 | .v.func = cxt_fixup_mute_led_gpio,
|
|---|
| 1050 | },
|
|---|
| 1051 | [CXT_FIXUP_HP_ELITEONE_OUT_DIS] = {
|
|---|
| 1052 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1053 | .v.func = cxt_fixup_update_pinctl,
|
|---|
| 1054 | },
|
|---|
| 1055 | [CXT_FIXUP_HP_ZBOOK_MUTE_LED] = {
|
|---|
| 1056 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1057 | .v.func = cxt_fixup_hp_zbook_mute_led,
|
|---|
| 1058 | },
|
|---|
| 1059 | [CXT_FIXUP_HEADSET_MIC] = {
|
|---|
| 1060 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1061 | .v.func = cxt_fixup_headset_mic,
|
|---|
| 1062 | },
|
|---|
| 1063 | #ifdef NOT_USED
|
|---|
| 1064 | [CXT_FIXUP_HP_MIC_NO_PRESENCE] = {
|
|---|
| 1065 | .type = HDA_FIXUP_PINS,
|
|---|
| 1066 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 1067 | { 0x1a, 0x02a1113c },
|
|---|
| 1068 | {0}
|
|---|
| 1069 | },
|
|---|
| 1070 | .chained = true,
|
|---|
| 1071 | .chain_id = CXT_FIXUP_HEADSET_MIC,
|
|---|
| 1072 | },
|
|---|
| 1073 | #endif
|
|---|
| 1074 | [CXT_PINCFG_SWS_JS201D] = {
|
|---|
| 1075 | .type = HDA_FIXUP_PINS,
|
|---|
| 1076 | .v.pins = cxt_pincfg_sws_js201d,
|
|---|
| 1077 | },
|
|---|
| 1078 | #ifdef NOT_USED
|
|---|
| 1079 | [CXT_PINCFG_TOP_SPEAKER] = {
|
|---|
| 1080 | .type = HDA_FIXUP_PINS,
|
|---|
| 1081 | .v.pins = (const struct hda_pintbl[]) {
|
|---|
| 1082 | { 0x1d, 0x82170111 },
|
|---|
| 1083 | { }
|
|---|
| 1084 | },
|
|---|
| 1085 | },
|
|---|
| 1086 | #endif
|
|---|
| 1087 | [CXT_FIXUP_HP_A_U] = {
|
|---|
| 1088 | .type = HDA_FIXUP_FUNC,
|
|---|
| 1089 | .v.func = cxt_fixup_hp_a_u,
|
|---|
| 1090 | },
|
|---|
| 1091 | };
|
|---|
| 1092 |
|
|---|
| 1093 | static const struct hda_quirk cxt5045_fixups[] = {
|
|---|
| 1094 | SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530),
|
|---|
| 1095 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105),
|
|---|
| 1096 | /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
|
|---|
| 1097 | * really bad sound over 0dB on NID 0x17.
|
|---|
| 1098 | */
|
|---|
| 1099 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP),
|
|---|
| 1100 | SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP),
|
|---|
| 1101 | SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP),
|
|---|
| 1102 | SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP),
|
|---|
| 1103 | {0}
|
|---|
| 1104 | };
|
|---|
| 1105 |
|
|---|
| 1106 | static const struct hda_model_fixup cxt5045_fixup_models[] = {
|
|---|
| 1107 | { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" },
|
|---|
| 1108 | { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" },
|
|---|
| 1109 | { .id = CXT_FIXUP_HP_530, .name = "hp-530" },
|
|---|
| 1110 | {0}
|
|---|
| 1111 | };
|
|---|
| 1112 |
|
|---|
| 1113 | static const struct hda_quirk cxt5047_fixups[] = {
|
|---|
| 1114 | /* HP laptops have really bad sound over 0 dB on NID 0x10.
|
|---|
| 1115 | */
|
|---|
| 1116 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047),
|
|---|
| 1117 | {0}
|
|---|
| 1118 | };
|
|---|
| 1119 |
|
|---|
| 1120 | static const struct hda_model_fixup cxt5047_fixup_models[] = {
|
|---|
| 1121 | { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" },
|
|---|
| 1122 | {0}
|
|---|
| 1123 | };
|
|---|
| 1124 |
|
|---|
| 1125 | static const struct hda_quirk cxt5051_fixups[] = {
|
|---|
| 1126 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq CQ60", CXT_PINCFG_COMPAQ_CQ60),
|
|---|
| 1127 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT_PINCFG_LENOVO_X200),
|
|---|
| 1128 | {0}
|
|---|
| 1129 | };
|
|---|
| 1130 |
|
|---|
| 1131 | static const struct hda_model_fixup cxt5051_fixup_models[] = {
|
|---|
| 1132 | { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" },
|
|---|
| 1133 | {0}
|
|---|
| 1134 | };
|
|---|
| 1135 |
|
|---|
| 1136 | static const struct hda_quirk cxt5066_fixups[] = {
|
|---|
| 1137 | SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1138 | SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
|
|---|
| 1139 | SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC),
|
|---|
| 1140 | SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
|
|---|
| 1141 | SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
|
|---|
| 1142 | SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
|
|---|
| 1143 | SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
|
|---|
| 1144 | SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1145 | SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
|
|---|
| 1146 | SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1147 | SND_PCI_QUIRK(0x103c, 0x8231, "HP ProBook 450 G4", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1148 | SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK),
|
|---|
| 1149 | SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1150 | SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1151 | SND_PCI_QUIRK(0x103c, 0x82b4, "HP ProDesk 600 G3", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1152 | SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1153 | SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1154 | SND_PCI_QUIRK(0x103c, 0x83b2, "HP EliteBook 840 G5", CXT_FIXUP_HP_DOCK),
|
|---|
| 1155 | SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
|
|---|
| 1156 | SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
|
|---|
| 1157 | SND_PCI_QUIRK(0x103c, 0x83e5, "HP EliteOne 1000 G2", CXT_FIXUP_HP_ELITEONE_OUT_DIS),
|
|---|
| 1158 | SND_PCI_QUIRK(0x103c, 0x8402, "HP ProBook 645 G4", CXT_FIXUP_MUTE_LED_GPIO),
|
|---|
| 1159 | SND_PCI_QUIRK(0x103c, 0x8427, "HP ZBook Studio G5", CXT_FIXUP_HP_ZBOOK_MUTE_LED),
|
|---|
| 1160 | SND_PCI_QUIRK(0x103c, 0x844f, "HP ZBook Studio G5", CXT_FIXUP_HP_ZBOOK_MUTE_LED),
|
|---|
| 1161 | SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1162 | SND_PCI_QUIRK(0x103c, 0x8456, "HP Z2 G4 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1163 | SND_PCI_QUIRK(0x103c, 0x8457, "HP Z2 G4 mini", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1164 | SND_PCI_QUIRK(0x103c, 0x8458, "HP Z2 G4 mini premium", CXT_FIXUP_HP_MIC_NO_PRESENCE),
|
|---|
| 1165 | SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
|
|---|
| 1166 | SND_PCI_QUIRK(0x14f1, 0x0252, "MBX-Z60MR100", CXT_FIXUP_HP_A_U),
|
|---|
| 1167 | SND_PCI_QUIRK(0x14f1, 0x0265, "SWS JS201D", CXT_PINCFG_SWS_JS201D),
|
|---|
| 1168 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
|
|---|
| 1169 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1170 | SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1171 | SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1172 | SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1173 | SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1174 | SND_PCI_QUIRK(0x17aa, 0x21d2, "Lenovo T420s", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1175 | SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1176 | SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
|
|---|
| 1177 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
|
|---|
| 1178 | SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1179 | SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1180 | SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1181 | /* NOTE: we'd need to extend the quirk for 17aa:3977 as the same
|
|---|
| 1182 | * PCI SSID is used on multiple Lenovo models
|
|---|
| 1183 | */
|
|---|
| 1184 | SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1185 | SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1186 | SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
|
|---|
| 1187 | SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
|
|---|
| 1188 | SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
|
|---|
| 1189 | SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT_PINCFG_LEMOTE_A1205),
|
|---|
| 1190 | HDA_CODEC_QUIRK(0x2782, 0x12c3, "Sirius Gen1", CXT_PINCFG_TOP_SPEAKER),
|
|---|
| 1191 | HDA_CODEC_QUIRK(0x2782, 0x12c5, "Sirius Gen2", CXT_PINCFG_TOP_SPEAKER),
|
|---|
| 1192 | {0}
|
|---|
| 1193 | };
|
|---|
| 1194 |
|
|---|
| 1195 | static const struct hda_model_fixup cxt5066_fixup_models[] = {
|
|---|
| 1196 | { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" },
|
|---|
| 1197 | { .id = CXT_FIXUP_GPIO1, .name = "gpio1" },
|
|---|
| 1198 | { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" },
|
|---|
| 1199 | { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" },
|
|---|
| 1200 | { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" },
|
|---|
| 1201 | { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
|
|---|
| 1202 | { .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" },
|
|---|
| 1203 | { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
|
|---|
| 1204 | { .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
|
|---|
| 1205 | { .id = CXT_FIXUP_HP_DOCK, .name = "hp-dock" },
|
|---|
| 1206 | { .id = CXT_FIXUP_MUTE_LED_GPIO, .name = "mute-led-gpio" },
|
|---|
| 1207 | { .id = CXT_FIXUP_HP_ZBOOK_MUTE_LED, .name = "hp-zbook-mute-led" },
|
|---|
| 1208 | { .id = CXT_FIXUP_HP_MIC_NO_PRESENCE, .name = "hp-mic-fix" },
|
|---|
| 1209 | { .id = CXT_PINCFG_LENOVO_NOTEBOOK, .name = "lenovo-20149" },
|
|---|
| 1210 | { .id = CXT_PINCFG_SWS_JS201D, .name = "sws-js201d" },
|
|---|
| 1211 | { .id = CXT_PINCFG_TOP_SPEAKER, .name = "sirius-top-speaker" },
|
|---|
| 1212 | { .id = CXT_FIXUP_HP_A_U, .name = "HP-U-support" },
|
|---|
| 1213 | {0}
|
|---|
| 1214 | };
|
|---|
| 1215 |
|
|---|
| 1216 | /* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
|
|---|
| 1217 | * can be created (bko#42825)
|
|---|
| 1218 | */
|
|---|
| 1219 | static void add_cx5051_fake_mutes(struct hda_codec *codec)
|
|---|
| 1220 | {
|
|---|
| 1221 | struct conexant_spec *spec = codec->spec;
|
|---|
| 1222 | static const hda_nid_t out_nids[] = {
|
|---|
| 1223 | 0x10, 0x11, 0
|
|---|
| 1224 | };
|
|---|
| 1225 | const hda_nid_t *p;
|
|---|
| 1226 |
|
|---|
| 1227 | for (p = out_nids; *p; p++)
|
|---|
| 1228 | snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
|
|---|
| 1229 | AC_AMPCAP_MIN_MUTE |
|
|---|
| 1230 | query_amp_caps(codec, *p, HDA_OUTPUT));
|
|---|
| 1231 | spec->gen.dac_min_mute = true;
|
|---|
| 1232 | }
|
|---|
| 1233 |
|
|---|
| 1234 | static int patch_conexant_auto(struct hda_codec *codec)
|
|---|
| 1235 | {
|
|---|
| 1236 | struct conexant_spec *spec;
|
|---|
| 1237 | int err;
|
|---|
| 1238 |
|
|---|
| 1239 | codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
|
|---|
| 1240 |
|
|---|
| 1241 | spec = kzalloc(sizeof(*spec), GFP_KERNEL);
|
|---|
| 1242 | if (!spec)
|
|---|
| 1243 | return -ENOMEM;
|
|---|
| 1244 | snd_hda_gen_spec_init(&spec->gen);
|
|---|
| 1245 | codec->spec = spec;
|
|---|
| 1246 | codec->patch_ops = cx_auto_patch_ops;
|
|---|
| 1247 |
|
|---|
| 1248 | /* init cx8070/sn6140 flag and reset headset_present_flag */
|
|---|
| 1249 | switch (codec->core.vendor_id) {
|
|---|
| 1250 | case 0x14f11f86:
|
|---|
| 1251 | case 0x14f11f87:
|
|---|
| 1252 | spec->is_cx8070_sn6140 = true;
|
|---|
| 1253 | snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref);
|
|---|
| 1254 | break;
|
|---|
| 1255 | }
|
|---|
| 1256 |
|
|---|
| 1257 | cx_auto_parse_eapd(codec);
|
|---|
| 1258 | spec->gen.own_eapd_ctl = 1;
|
|---|
| 1259 |
|
|---|
| 1260 | switch (codec->core.vendor_id) {
|
|---|
| 1261 | case 0x14f15045:
|
|---|
| 1262 | codec->single_adc_amp = 1;
|
|---|
| 1263 | spec->gen.mixer_nid = 0x17;
|
|---|
| 1264 | spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
|
|---|
| 1265 | snd_hda_pick_fixup(codec, cxt5045_fixup_models,
|
|---|
| 1266 | cxt5045_fixups, cxt_fixups);
|
|---|
| 1267 | break;
|
|---|
| 1268 | case 0x14f15047:
|
|---|
| 1269 | codec->pin_amp_workaround = 1;
|
|---|
| 1270 | spec->gen.mixer_nid = 0x19;
|
|---|
| 1271 | spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
|
|---|
| 1272 | snd_hda_pick_fixup(codec, cxt5047_fixup_models,
|
|---|
| 1273 | cxt5047_fixups, cxt_fixups);
|
|---|
| 1274 | break;
|
|---|
| 1275 | case 0x14f15051:
|
|---|
| 1276 | add_cx5051_fake_mutes(codec);
|
|---|
| 1277 | codec->pin_amp_workaround = 1;
|
|---|
| 1278 | snd_hda_pick_fixup(codec, cxt5051_fixup_models,
|
|---|
| 1279 | cxt5051_fixups, cxt_fixups);
|
|---|
| 1280 | break;
|
|---|
| 1281 | case 0x14f15098:
|
|---|
| 1282 | codec->pin_amp_workaround = 1;
|
|---|
| 1283 | spec->gen.mixer_nid = 0x22;
|
|---|
| 1284 | spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
|
|---|
| 1285 | snd_hda_pick_fixup(codec, cxt5066_fixup_models,
|
|---|
| 1286 | cxt5066_fixups, cxt_fixups);
|
|---|
| 1287 | break;
|
|---|
| 1288 | case 0x14f150f2:
|
|---|
| 1289 | codec->power_save_node = 1;
|
|---|
| 1290 | fallthrough;
|
|---|
| 1291 | default:
|
|---|
| 1292 | codec->pin_amp_workaround = 1;
|
|---|
| 1293 | snd_hda_pick_fixup(codec, cxt5066_fixup_models,
|
|---|
| 1294 | cxt5066_fixups, cxt_fixups);
|
|---|
| 1295 | break;
|
|---|
| 1296 | }
|
|---|
| 1297 |
|
|---|
| 1298 | if (!spec->gen.vmaster_mute.hook && spec->dynamic_eapd)
|
|---|
| 1299 | spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
|
|---|
| 1300 |
|
|---|
| 1301 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
|
|---|
| 1302 |
|
|---|
| 1303 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
|
|---|
| 1304 | spec->parse_flags);
|
|---|
| 1305 | if (err < 0)
|
|---|
| 1306 | goto error;
|
|---|
| 1307 |
|
|---|
| 1308 | err = cx_auto_parse_beep(codec);
|
|---|
| 1309 | if (err < 0)
|
|---|
| 1310 | goto error;
|
|---|
| 1311 |
|
|---|
| 1312 | err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
|
|---|
| 1313 | if (err < 0)
|
|---|
| 1314 | goto error;
|
|---|
| 1315 |
|
|---|
| 1316 | /* Some laptops with Conexant chips show stalls in S3 resume,
|
|---|
| 1317 | * which falls into the single-cmd mode.
|
|---|
| 1318 | * Better to make reset, then.
|
|---|
| 1319 | */
|
|---|
| 1320 | if (!codec->bus->core.sync_write) {
|
|---|
| 1321 | codec_info(codec,
|
|---|
| 1322 | "Enable sync_write for stable communication\n");
|
|---|
| 1323 | codec->bus->core.sync_write = 1;
|
|---|
| 1324 | codec->bus->allow_bus_reset = 1;
|
|---|
| 1325 | }
|
|---|
| 1326 |
|
|---|
| 1327 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
|
|---|
| 1328 |
|
|---|
| 1329 | return 0;
|
|---|
| 1330 |
|
|---|
| 1331 | error:
|
|---|
| 1332 | cx_auto_free(codec);
|
|---|
| 1333 | return err;
|
|---|
| 1334 | }
|
|---|
| 1335 |
|
|---|
| 1336 | /*
|
|---|
| 1337 | */
|
|---|
| 1338 |
|
|---|
| 1339 | static const struct hda_device_id snd_hda_id_conexant[] = {
|
|---|
| 1340 | HDA_CODEC_ENTRY(0x14f11f86, "CX8070", patch_conexant_auto),
|
|---|
| 1341 | HDA_CODEC_ENTRY(0x14f11f87, "SN6140", patch_conexant_auto),
|
|---|
| 1342 | HDA_CODEC_ENTRY(0x14f12008, "CX8200", patch_conexant_auto),
|
|---|
| 1343 | HDA_CODEC_ENTRY(0x14f120d0, "CX11970", patch_conexant_auto),
|
|---|
| 1344 | HDA_CODEC_ENTRY(0x14f120d1, "SN6180", patch_conexant_auto),
|
|---|
| 1345 | HDA_CODEC_ENTRY(0x14f15045, "CX20549 (Venice)", patch_conexant_auto),
|
|---|
| 1346 | HDA_CODEC_ENTRY(0x14f15047, "CX20551 (Waikiki)", patch_conexant_auto),
|
|---|
| 1347 | HDA_CODEC_ENTRY(0x14f15051, "CX20561 (Hermosa)", patch_conexant_auto),
|
|---|
| 1348 | HDA_CODEC_ENTRY(0x14f15066, "CX20582 (Pebble)", patch_conexant_auto),
|
|---|
| 1349 | HDA_CODEC_ENTRY(0x14f15067, "CX20583 (Pebble HSF)", patch_conexant_auto),
|
|---|
| 1350 | HDA_CODEC_ENTRY(0x14f15068, "CX20584", patch_conexant_auto),
|
|---|
| 1351 | HDA_CODEC_ENTRY(0x14f15069, "CX20585", patch_conexant_auto),
|
|---|
| 1352 | HDA_CODEC_ENTRY(0x14f1506c, "CX20588", patch_conexant_auto),
|
|---|
| 1353 | HDA_CODEC_ENTRY(0x14f1506e, "CX20590", patch_conexant_auto),
|
|---|
| 1354 | HDA_CODEC_ENTRY(0x14f15097, "CX20631", patch_conexant_auto),
|
|---|
| 1355 | HDA_CODEC_ENTRY(0x14f15098, "CX20632", patch_conexant_auto),
|
|---|
| 1356 | HDA_CODEC_ENTRY(0x14f150a1, "CX20641", patch_conexant_auto),
|
|---|
| 1357 | HDA_CODEC_ENTRY(0x14f150a2, "CX20642", patch_conexant_auto),
|
|---|
| 1358 | HDA_CODEC_ENTRY(0x14f150ab, "CX20651", patch_conexant_auto),
|
|---|
| 1359 | HDA_CODEC_ENTRY(0x14f150ac, "CX20652", patch_conexant_auto),
|
|---|
| 1360 | HDA_CODEC_ENTRY(0x14f150b8, "CX20664", patch_conexant_auto),
|
|---|
| 1361 | HDA_CODEC_ENTRY(0x14f150b9, "CX20665", patch_conexant_auto),
|
|---|
| 1362 | HDA_CODEC_ENTRY(0x14f150f1, "CX21722", patch_conexant_auto),
|
|---|
| 1363 | HDA_CODEC_ENTRY(0x14f150f2, "CX20722", patch_conexant_auto),
|
|---|
| 1364 | HDA_CODEC_ENTRY(0x14f150f3, "CX21724", patch_conexant_auto),
|
|---|
| 1365 | HDA_CODEC_ENTRY(0x14f150f4, "CX20724", patch_conexant_auto),
|
|---|
| 1366 | HDA_CODEC_ENTRY(0x14f1510f, "CX20751/2", patch_conexant_auto),
|
|---|
| 1367 | HDA_CODEC_ENTRY(0x14f15110, "CX20751/2", patch_conexant_auto),
|
|---|
| 1368 | HDA_CODEC_ENTRY(0x14f15111, "CX20753/4", patch_conexant_auto),
|
|---|
| 1369 | HDA_CODEC_ENTRY(0x14f15113, "CX20755", patch_conexant_auto),
|
|---|
| 1370 | HDA_CODEC_ENTRY(0x14f15114, "CX20756", patch_conexant_auto),
|
|---|
| 1371 | HDA_CODEC_ENTRY(0x14f15115, "CX20757", patch_conexant_auto),
|
|---|
| 1372 | HDA_CODEC_ENTRY(0x14f151d7, "CX20952", patch_conexant_auto),
|
|---|
| 1373 | {0} /* terminator */
|
|---|
| 1374 | };
|
|---|
| 1375 | MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_conexant);
|
|---|
| 1376 |
|
|---|
| 1377 | MODULE_LICENSE("GPL");
|
|---|
| 1378 | MODULE_DESCRIPTION("Conexant HD-audio codec");
|
|---|
| 1379 |
|
|---|
| 1380 | static struct hda_codec_driver conexant_driver = {
|
|---|
| 1381 | .id = snd_hda_id_conexant,
|
|---|
| 1382 | };
|
|---|
| 1383 |
|
|---|
| 1384 | module_hda_codec_driver(conexant_driver);
|
|---|