Lines Matching +full:src +full:- +full:coef
1 // SPDX-License-Identifier: GPL-2.0-or-later
66 /* Vendor-specific processing widget */
73 /* coef indices */
79 * 1 = digital immediate, analog zero-cross
80 * 2 = digtail & analog soft-ramp
81 * 3 = digital soft-ramp, analog zero-cross
85 #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */
86 /* PGA mode: 0 = differential, 1 = signle-ended */
88 #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */
92 * 1 = zero-cross
93 * 2 = soft-ramp
94 * 3 = soft-ramp on zero-cross
101 /* 0x0008 - test reg key */
102 /* 0x0009 - 0x0014 -> 12 test regs */
103 /* 0x0015 - visibility reg */
132 struct cs_spec *spec = codec->spec; in cs_vendor_coef_get()
134 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
136 return snd_hda_codec_read(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
141 unsigned int coef) in cs_vendor_coef_set() argument
143 struct cs_spec *spec = codec->spec; in cs_vendor_coef_set()
145 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
147 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
148 AC_VERB_SET_PROC_COEF, coef); in cs_vendor_coef_set()
152 * auto-mute and auto-mic switching
153 * CS421x auto-output redirecting
159 struct cs_spec *spec = codec->spec; in cs_automute()
162 spec->gen.master_mute = !!(spec->spdif_present && spec->sense_b); in cs_automute()
166 if (spec->gpio_eapd_hp || spec->gpio_eapd_speaker) { in cs_automute()
167 if (spec->gen.automute_speaker) in cs_automute()
168 spec->gpio_data = spec->gen.hp_jack_present ? in cs_automute()
169 spec->gpio_eapd_hp : spec->gpio_eapd_speaker; in cs_automute()
171 spec->gpio_data = in cs_automute()
172 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs_automute()
174 AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs_automute()
188 struct cs_spec *spec = codec->spec; in init_input_coef()
189 unsigned int coef; in init_input_coef() local
192 if (spec->vendor_nid == CS420X_VENDOR_NID) { in init_input_coef()
193 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG); in init_input_coef()
195 coef |= 1 << 4; /* DMIC2 2 chan on, GPIO1 off */ in init_input_coef()
197 coef |= 1 << 3; /* DMIC1 2 chan on, GPIO0 off in init_input_coef()
202 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef); in init_input_coef()
215 /* ADC1/2 - Digital and Analog Soft Ramp */
244 * the clock and write enable to the S/PDIF SRC RAMs is not properly
249 * Workaround: The following verb sequence briefly turns on the S/PDIF SRC
280 unsigned int coef; in init_digital_coef() local
282 coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */ in init_digital_coef()
283 coef |= 0x0008; /* Replace with mute on error */ in init_digital_coef()
285 coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2 in init_digital_coef()
289 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); in init_digital_coef()
294 struct cs_spec *spec = codec->spec; in cs_init()
296 if (spec->vendor_nid == CS420X_VENDOR_NID) { in cs_init()
300 } else if (spec->vendor_nid == CS4208_VENDOR_NID) { in cs_init()
306 if (spec->gpio_mask) { in cs_init()
308 spec->gpio_mask); in cs_init()
310 spec->gpio_dir); in cs_init()
312 spec->gpio_data); in cs_init()
315 if (spec->vendor_nid == CS420X_VENDOR_NID) { in cs_init()
346 struct cs_spec *spec = codec->spec; in cs_parse_auto_config()
350 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs_parse_auto_config()
354 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs_parse_auto_config()
359 if (spec->gen.dyn_adc_switch) { in cs_parse_auto_config()
362 for (i = 0; i < spec->gen.input_mux.num_items; i++) { in cs_parse_auto_config()
363 int idx = spec->gen.dyn_adc_idx[i]; in cs_parse_auto_config()
368 spec->gen.adc_nids[idx]); in cs_parse_auto_config()
497 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_13()
499 spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ in cs420x_fixup_gpio_13()
500 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ in cs420x_fixup_gpio_13()
501 spec->gpio_mask = spec->gpio_dir = in cs420x_fixup_gpio_13()
502 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs420x_fixup_gpio_13()
510 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_23()
512 spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ in cs420x_fixup_gpio_23()
513 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ in cs420x_fixup_gpio_23()
514 spec->gpio_mask = spec->gpio_dir = in cs420x_fixup_gpio_23()
515 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs420x_fixup_gpio_23()
578 codec->spec = spec; in cs_alloc_spec()
579 spec->vendor_nid = vendor_nid; in cs_alloc_spec()
580 codec->power_save_node = 1; in cs_alloc_spec()
581 snd_hda_gen_spec_init(&spec->gen); in cs_alloc_spec()
593 return -ENOMEM; in patch_cs420x()
595 codec->patch_ops = cs_patch_ops; in patch_cs420x()
596 spec->gen.automute_hook = cs_automute; in patch_cs420x()
597 codec->single_adc_amp = 1; in patch_cs420x()
655 struct cs_spec *spec = codec->spec; in cs4208_fixup_gpio0()
657 spec->gpio_eapd_hp = 0; in cs4208_fixup_gpio0()
658 spec->gpio_eapd_speaker = 1; in cs4208_fixup_gpio0()
659 spec->gpio_mask = spec->gpio_dir = in cs4208_fixup_gpio0()
660 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs4208_fixup_gpio0()
673 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in cs4208_fixup_mac()
675 if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET) in cs4208_fixup_mac()
676 codec->fixup_id = CS4208_GPIO0; /* default fixup */ in cs4208_fixup_mac()
685 { 0x18, 0x00ab9150 }, /* mic (audio-in) jack: disable detect */ in cs4208_fixup_macmini()
692 codec->inv_jack_detect = 1; in cs4208_fixup_macmini()
702 struct cs_spec *spec = codec->spec; in cs4208_spdif_sw_put()
703 hda_nid_t pin = spec->gen.autocfg.dig_out_pins[0]; in cs4208_spdif_sw_put()
704 int pinctl = ucontrol->value.integer.value[0] ? PIN_OUT : 0; in cs4208_spdif_sw_put()
707 return spec->spdif_sw_put(kcontrol, ucontrol); in cs4208_spdif_sw_put()
715 struct cs_spec *spec = codec->spec; in cs4208_fixup_spdif_switch()
718 if (!spec->gen.autocfg.dig_out_pins[0]) in cs4208_fixup_spdif_switch()
723 spec->spdif_sw_put = kctl->put; in cs4208_fixup_spdif_switch()
724 kctl->put = cs4208_spdif_sw_put; in cs4208_fixup_spdif_switch()
775 return -ENOMEM; in patch_cs4208()
777 codec->patch_ops = cs_patch_ops; in patch_cs4208()
778 spec->gen.automute_hook = cs_automute; in patch_cs4208()
780 spec->gen.out_vol_mask = 1ULL << 0x10; in patch_cs4208()
853 struct cs_spec *spec = codec->spec; in cs421x_fixup_sense_b()
856 spec->sense_b = 1; in cs421x_fixup_sense_b()
880 * Disable Coefficient Index Auto-Increment(DAI)=1,
934 /* Speaker Amp Gain is controlled by the vendor widget's coef 4 */
940 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in cs421x_boost_vol_info()
941 uinfo->count = 1; in cs421x_boost_vol_info()
942 uinfo->value.integer.min = 0; in cs421x_boost_vol_info()
943 uinfo->value.integer.max = 3; in cs421x_boost_vol_info()
952 ucontrol->value.integer.value[0] = in cs421x_boost_vol_get()
962 unsigned int vol = ucontrol->value.integer.value[0]; in cs421x_boost_vol_put()
963 unsigned int coef = in cs421x_boost_vol_put() local
965 unsigned int original_coef = coef; in cs421x_boost_vol_put()
967 coef &= ~0x0003; in cs421x_boost_vol_put()
968 coef |= (vol & 0x0003); in cs421x_boost_vol_put()
969 if (original_coef != coef) { in cs421x_boost_vol_put()
970 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef); in cs421x_boost_vol_put()
991 struct cs_spec *spec = codec->spec; in cs4210_pinmux_init()
992 unsigned int def_conf, coef; in cs4210_pinmux_init() local
995 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs4210_pinmux_init()
997 if (spec->gpio_mask) in cs4210_pinmux_init()
998 coef |= 0x0008; /* B1,B2 are GPIOs */ in cs4210_pinmux_init()
1000 coef &= ~0x0008; in cs4210_pinmux_init()
1002 if (spec->sense_b) in cs4210_pinmux_init()
1003 coef |= 0x0010; /* B2 is SENSE_B, not inverted */ in cs4210_pinmux_init()
1005 coef &= ~0x0010; in cs4210_pinmux_init()
1007 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs4210_pinmux_init()
1009 if ((spec->gpio_mask || spec->sense_b) && in cs4210_pinmux_init()
1013 * GPIO or SENSE_B forced - disconnect the DMIC pin. in cs4210_pinmux_init()
1025 struct cs_spec *spec = codec->spec; in cs4210_spdif_automute()
1027 hda_nid_t spdif_pin = spec->gen.autocfg.dig_out_pins[0]; in cs4210_spdif_automute()
1030 if (!spec->spdif_detect || in cs4210_spdif_automute()
1031 spec->vendor_nid != CS4210_VENDOR_NID) in cs4210_spdif_automute()
1035 if (spdif_present == spec->spdif_present) in cs4210_spdif_automute()
1038 spec->spdif_present = spdif_present; in cs4210_spdif_automute()
1047 struct cs_spec *spec = codec->spec; in parse_cs421x_digital()
1048 struct auto_pin_cfg *cfg = &spec->gen.autocfg; in parse_cs421x_digital()
1051 for (i = 0; i < cfg->dig_outs; i++) { in parse_cs421x_digital()
1052 hda_nid_t nid = cfg->dig_out_pins[i]; in parse_cs421x_digital()
1055 spec->spdif_detect = 1; in parse_cs421x_digital()
1064 struct cs_spec *spec = codec->spec; in cs421x_init()
1066 if (spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_init()
1074 if (spec->gpio_mask) { in cs421x_init()
1076 spec->gpio_mask); in cs421x_init()
1078 spec->gpio_dir); in cs421x_init()
1080 spec->gpio_data); in cs421x_init()
1094 /* set the upper-limit for mixer amp to 0dB */ in fix_volume_caps()
1104 struct cs_spec *spec = codec->spec; in cs421x_parse_auto_config()
1110 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs421x_parse_auto_config()
1114 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs421x_parse_auto_config()
1120 if (spec->gen.autocfg.speaker_outs && in cs421x_parse_auto_config()
1121 spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_parse_auto_config()
1122 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, in cs421x_parse_auto_config()
1124 return -ENOMEM; in cs421x_parse_auto_config()
1133 * (DAC,ADC) -> D3, PDREF=1, AFG->D3
1137 struct cs_spec *spec = codec->spec; in cs421x_suspend()
1138 unsigned int coef; in cs421x_suspend() local
1147 if (spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_suspend()
1148 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs421x_suspend()
1149 coef |= 0x0004; /* PDREF */ in cs421x_suspend()
1150 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs421x_suspend()
1175 return -ENOMEM; in patch_cs4210()
1177 codec->patch_ops = cs421x_patch_ops; in patch_cs4210()
1178 spec->gen.automute_hook = cs_automute; in patch_cs4210()
1186 * is auto-parsed. If GPIO or SENSE_B is forced, DMIC input in patch_cs4210()
1211 return -ENOMEM; in patch_cs4213()
1213 codec->patch_ops = cs421x_patch_ops; in patch_cs4213()
1240 MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");