Lines Matching +full:charge +full:- +full:ctrl +full:- +full:value

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // Realtek HD-audio codec support code
49 if (val != -1)
63 /* a special bypass for COEF 0; read the cached value at the second time */
66 struct alc_spec *spec = codec->spec;
68 if (!spec->coef0)
69 spec->coef0 = alc_read_coef_idx(codec, 0);
70 return spec->coef0;
77 for (; fw->nid; fw++) {
78 if (fw->mask == (unsigned short)-1)
79 __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
81 __alc_update_coefex_idx(codec, fw->nid, fw->idx,
82 fw->mask, fw->val);
94 struct alc_spec *spec = codec->spec;
96 spec->gpio_mask |= mask;
97 spec->gpio_dir |= mask;
98 spec->gpio_data |= mask;
104 struct alc_spec *spec = codec->spec;
107 spec->gpio_data);
114 struct alc_spec *spec = codec->spec;
115 unsigned int oldval = spec->gpio_data;
118 spec->gpio_data |= mask;
120 spec->gpio_data &= ~mask;
121 if (oldval != spec->gpio_data)
128 struct alc_spec *spec = codec->spec;
130 if (!spec->gpio_mask)
133 snd_hda_codec_write(codec, codec->core.afg, 0,
134 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
135 snd_hda_codec_write(codec, codec->core.afg, 0,
136 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
137 if (spec->gpio_write_delay)
189 * the default value is 1.
193 struct alc_spec *spec = codec->spec;
195 if (spec->pll_nid)
196 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
197 1 << spec->pll_coef_bit, 0);
204 struct alc_spec *spec = codec->spec;
205 spec->pll_nid = nid;
206 spec->pll_coef_idx = coef_idx;
207 spec->pll_coef_bit = coef_bit;
212 /* update the master volume per volume-knob's unsol event */
226 val = snd_hda_codec_read(codec, jack->nid, 0,
229 uctl->value.integer.value[0] = val;
230 uctl->value.integer.value[1] = val;
231 kctl->put(kctl, uctl);
242 switch (codec->core.vendor_id) {
314 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
323 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
380 struct alc_spec *spec = codec->spec;
381 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
386 for (i = 0; i < cfg->num_inputs; i++) {
387 if (cfg->inputs[i].type != AUTO_PIN_MIC)
389 nid = cfg->inputs[i].pin;
409 if (codec->bus->shutdown)
412 snd_array_for_each(&codec->init_pins, i, pin) {
414 if (pin->nid != mic_pin)
415 snd_hda_codec_read(codec, pin->nid, 0,
419 codec->pins_shutup = 1;
425 struct alc_spec *spec = codec->spec;
427 if (spec->no_shutup_pins)
430 switch (codec->core.vendor_id) {
452 * just turning off EAPD and a little pause for avoiding pop-noise
456 struct alc_spec *spec = codec->spec;
459 if (!spec->no_depop_delay)
469 /* alc888-VA */
471 /* alc888-VB */
485 switch (codec->core.vendor_id) {
507 if (spec->gen.autocfg.hp_pins[0])
508 return spec->gen.autocfg.hp_pins[0];
509 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
510 return spec->gen.autocfg.line_out_pins[0];
519 /* Could be any non-zero and even value. When used as fixup, tells
527 struct alc_spec *spec = codec->spec;
529 spec->cdefine.fixup = 1;
530 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
538 struct alc_spec *spec = codec->spec;
541 spec->no_depop_delay = 1;
542 codec->depop_delay = 0;
551 struct alc_spec *spec = codec->spec;
553 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
555 if (spec->cdefine.fixup) {
556 ass = spec->cdefine.sku_cfg;
558 return -1;
562 if (!codec->bus->pci)
563 return -1;
564 ass = codec->core.subsystem_id & 0xffff;
565 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
569 if (codec->core.vendor_id == 0x10ec0260)
575 codec->core.chip_name, ass);
576 return -1;
586 return -1;
588 spec->cdefine.port_connectivity = ass >> 30;
589 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
590 spec->cdefine.check_sum = (ass >> 16) & 0xf;
591 spec->cdefine.customization = ass >> 8;
593 spec->cdefine.sku_cfg = ass;
594 spec->cdefine.external_amp = (ass & 0x38) >> 3;
595 spec->cdefine.platform_type = (ass & 0x4) >> 2;
596 spec->cdefine.swap = (ass & 0x2) >> 1;
597 spec->cdefine.override = ass & 0x1;
600 nid, spec->cdefine.sku_cfg);
602 spec->cdefine.port_connectivity);
603 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
604 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
605 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
606 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
607 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
608 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
609 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
615 /* return the position of NID in the list, or -1 if not found */
622 return -1;
630 /* check subsystem ID and set up device-specific initialization;
633 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
637 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
643 struct alc_spec *spec = codec->spec;
645 if (spec->cdefine.fixup) {
646 ass = spec->cdefine.sku_cfg;
652 ass = codec->core.subsystem_id & 0xffff;
653 if (codec->bus->pci &&
654 ass != codec->bus->pci->subsystem_device && (ass & 1))
667 if (codec->core.vendor_id == 0x10ec0260)
688 ass & 0xffff, codec->core.vendor_id);
692 * 2 : 0 --> Desktop, 1 --> Laptop
697 if (spec->init_amp == ALC_INIT_UNDEFINED) {
710 spec->init_amp = ALC_INIT_DEFAULT;
722 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
724 * 15 : 1 --> enable the function "Mute internal speaker
731 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
732 spec->gen.autocfg.line_outs))
734 spec->gen.autocfg.hp_pins[0] = nid;
740 /* Check the validity of ALC subsystem-id
741 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
745 struct alc_spec *spec = codec->spec;
746 if (spec->init_amp == ALC_INIT_UNDEFINED) {
749 spec->init_amp = ALC_INIT_DEFAULT;
755 /* inverted digital-mic */
759 struct alc_spec *spec = codec->spec;
761 spec->gen.inv_dmic_split = 1;
780 struct alc_spec *spec = codec->spec;
786 if (spec->init_hook)
787 spec->init_hook(codec);
789 spec->gen.skip_verbs = 1; /* applied in below */
792 alc_auto_init_amp(codec, spec->init_amp);
803 struct alc_spec *spec = codec->spec;
808 if (spec && spec->shutup)
809 spec->shutup(codec);
823 struct alc_spec *spec = codec->spec;
825 if (spec && spec->power_hook)
826 spec->power_hook(codec);
833 struct alc_spec *spec = codec->spec;
835 if (!spec->no_depop_delay)
845 * Rename codecs appropriately from COEF value or subvendor id
872 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
873 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
919 for (p = rename_tbl; p->vendor_id; p++) {
920 if (p->vendor_id != codec->core.vendor_id)
922 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
923 return alc_codec_rename(codec, p->name);
926 if (!codec->bus->pci)
928 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
929 if (q->codec_vendor_id != codec->core.vendor_id)
931 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
933 if (!q->pci_subdevice ||
934 q->pci_subdevice == codec->bus->pci->subsystem_device)
935 return alc_codec_rename(codec, q->name);
942 * Digital-beep handlers
960 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
963 return -ENOMEM;
964 knew->private_value = beep_amp;
978 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
980 /* denylist -- no beep available */
988 struct alc_spec *spec = codec->spec;
990 q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
992 return q->value;
993 return spec->cdefine.enable_pcbeep;
1007 struct alc_spec *spec = codec->spec;
1008 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1012 spec->parse_flags);
1034 return -ENOMEM;
1035 codec->spec = spec;
1036 snd_hda_gen_spec_init(&spec->gen);
1037 spec->gen.mixer_nid = mixer_nid;
1038 spec->gen.own_eapd_ctl = 1;
1039 codec->single_adc_amp = 1;
1041 codec->spdif_status_reset = 1;
1042 codec->forced_resume = 1;
1043 mutex_init(&spec->coef_mutex);
1054 /* For dual-codec configuration, we need to disable some features to avoid
1060 struct alc_spec *spec = codec->spec;
1065 spec->gen.suppress_vmaster = 1;
1066 /* auto-mute and auto-mic switch don't work with multiple codecs */
1067 spec->gen.suppress_auto_mute = 1;
1068 spec->gen.suppress_auto_mic = 1;
1070 spec->gen.mixer_nid = 0;
1072 codec->force_pin_prefix = 1;
1090 struct alc_spec *spec = codec->spec;
1091 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
1105 strscpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
1110 codec->addr == 0 ?
1111 "Rear-Panel Capture Volume" :
1112 "Front-Panel Capture Volume");
1114 codec->addr == 0 ?
1115 "Rear-Panel Capture Switch" :
1116 "Front-Panel Capture Switch");
1130 strscpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
1135 codec->addr == 0 ?
1136 "Rear-Panel Capture Volume" :
1137 "Front-Panel Capture Volume");
1139 codec->addr == 0 ?
1140 "Rear-Panel Capture Switch" :
1141 "Front-Panel Capture Switch");
1149 struct alc_spec *spec = codec->spec;
1161 struct alc_spec *spec = codec->spec;
1162 struct hda_input_mux *imux = &spec->gen.input_mux;
1167 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
1171 spec->shutup = alc_shutup_dell_xps13;
1175 for (i = 0; i < imux->num_items; i++) {
1176 if (spec->gen.imux_pins[i] == 0x12) {
1177 spec->gen.cur_mux[0] = i;
1227 struct alc_spec *spec = codec->spec;
1275 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
1277 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
1302 if (spec->no_internal_mic_pin) {
1307 switch (codec->core.vendor_id) {
1398 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
1400 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
1422 switch (codec->core.vendor_id) {
1498 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
1550 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
1567 switch (codec->core.vendor_id) {
1678 switch (codec->core.vendor_id) {
1742 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
1795 switch (codec->core.vendor_id) {
1845 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
1852 struct alc_spec *spec = codec->spec;
1891 if (spec->no_internal_mic_pin) {
1896 switch (codec->core.vendor_id) {
2037 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
2039 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
2044 struct alc_spec *spec = codec->spec;
2046 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
2053 else if (mux_pin == spec->headset_mic_pin)
2055 else if (mux_pin == spec->headphone_mic_pin)
2060 if (new_headset_mode == spec->current_headset_mode) {
2068 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
2069 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
2070 spec->gen.hp_jack_present = false;
2073 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
2075 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
2077 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
2079 spec->gen.hp_jack_present = true;
2082 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
2083 spec->gen.hp_jack_present = false;
2087 spec->gen.hp_jack_present = true;
2093 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
2094 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
2097 spec->current_headset_mode = new_headset_mode;
2120 struct alc_spec *spec = codec->spec;
2121 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
2124 for (i = 0; i < cfg->num_inputs; i++) {
2125 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
2126 spec->headset_mic_pin = cfg->inputs[i].pin;
2127 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
2128 spec->headphone_mic_pin = cfg->inputs[i].pin;
2131 WARN_ON(spec->gen.cap_sync_hook);
2132 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
2133 spec->gen.automute_hook = alc_update_headset_mode;
2134 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
2140 struct alc_spec *spec = codec->spec;
2144 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
2151 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
2152 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
2164 struct alc_spec *spec = codec->spec;
2165 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
2175 struct alc_spec *spec = codec->spec;
2178 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
2188 alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
2192 /* turn on/off mic-mute LED via GPIO per capture hook */
2196 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
2197 struct alc_spec *spec = codec->spec;
2199 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
2200 spec->micmute_led_polarity, !brightness);
2208 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
2209 struct alc_spec *spec = codec->spec;
2211 alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
2212 spec->mute_led_polarity, !brightness);
2216 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
2222 struct alc_spec *spec = codec->spec;
2229 spec->gpio_mute_led_mask = mute_mask;
2233 spec->gpio_mic_led_mask = micmute_mask;
2239 /* suppress the jack-detection */
2244 codec->no_jack_detect = 1;
2252 struct alc_spec *spec = codec->spec;
2253 /* Disable AA-loopback as it causes white noise */
2254 spec->gen.mixer_nid = 0;
2263 struct alc_spec *spec = codec->spec;
2264 spec->gen.auto_mute_via_amp = 1;
2271 MODULE_DESCRIPTION("Realtek HD-audio codec helper");