Lines Matching defs:codec

130 static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
132 struct cs_spec *spec = codec->spec;
134 snd_hda_codec_write(codec, spec->vendor_nid, 0,
136 return snd_hda_codec_read(codec, spec->vendor_nid, 0,
140 static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx,
143 struct cs_spec *spec = codec->spec;
145 snd_hda_codec_write(codec, spec->vendor_nid, 0,
147 snd_hda_codec_write(codec, spec->vendor_nid, 0,
157 static void cs_automute(struct hda_codec *codec)
159 struct cs_spec *spec = codec->spec;
164 snd_hda_gen_update_outputs(codec);
173 snd_hda_codec_write(codec, 0x01, 0,
178 static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid)
182 val = snd_hda_codec_get_pincfg(codec, nid);
186 static void init_input_coef(struct hda_codec *codec)
188 struct cs_spec *spec = codec->spec;
193 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG);
194 if (is_active_pin(codec, CS_DMIC2_PIN_NID))
196 if (is_active_pin(codec, CS_DMIC1_PIN_NID))
202 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef);
278 static void init_digital_coef(struct hda_codec *codec)
284 if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID))
289 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef);
292 static int cs_init(struct hda_codec *codec)
294 struct cs_spec *spec = codec->spec;
298 snd_hda_sequence_write(codec, cs_errata_init_verbs);
299 snd_hda_sequence_write(codec, cs_coef_init_verbs);
301 snd_hda_sequence_write(codec, cs4208_coef_init_verbs);
304 snd_hda_gen_init(codec);
307 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
309 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
311 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
316 init_input_coef(codec);
317 init_digital_coef(codec);
323 static int cs_build_controls(struct hda_codec *codec)
327 err = snd_hda_gen_build_controls(codec);
330 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
344 static int cs_parse_auto_config(struct hda_codec *codec)
346 struct cs_spec *spec = codec->spec;
350 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
354 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
367 snd_hda_gen_fix_pin_power(codec,
396 /* codec SSID */
494 static void cs420x_fixup_gpio_13(struct hda_codec *codec,
498 struct cs_spec *spec = codec->spec;
507 static void cs420x_fixup_gpio_23(struct hda_codec *codec,
511 struct cs_spec *spec = codec->spec;
572 static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid)
579 codec->spec = spec;
581 codec->power_save_node = 1;
587 static int patch_cs420x(struct hda_codec *codec)
592 spec = cs_alloc_spec(codec, CS420X_VENDOR_NID);
596 codec->patch_ops = cs_patch_ops;
598 codec->single_adc_amp = 1;
600 snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl,
602 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
604 err = cs_parse_auto_config(codec);
608 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
613 cs_free(codec);
642 /* codec SSID matching */
652 static void cs4208_fixup_gpio0(struct hda_codec *codec,
656 struct cs_spec *spec = codec->spec;
667 /* remap the fixup from codec SSID and apply it */
668 static void cs4208_fixup_mac(struct hda_codec *codec,
674 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
675 snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups);
676 if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET)
677 codec->fixup_id = CS4208_GPIO0; /* default fixup */
678 snd_hda_apply_fixup(codec, action);
682 static void cs4208_fixup_macmini(struct hda_codec *codec,
693 codec->inv_jack_detect = 1;
695 snd_hda_apply_pincfgs(codec, pincfgs);
702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
703 struct cs_spec *spec = codec->spec;
707 snd_hda_set_pin_ctl_cache(codec, pin, pinctl);
712 static void cs4208_fixup_spdif_switch(struct hda_codec *codec,
716 struct cs_spec *spec = codec->spec;
721 kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch");
759 static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc)
763 caps = query_amp_caps(codec, adc, HDA_INPUT);
766 snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps);
769 static int patch_cs4208(struct hda_codec *codec)
774 spec = cs_alloc_spec(codec, CS4208_VENDOR_NID);
778 codec->patch_ops = cs_patch_ops;
783 snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl,
785 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
787 snd_hda_override_wcaps(codec, 0x18,
788 get_wcaps(codec, 0x18) | AC_WCAP_STEREO);
789 cs4208_fix_amp_caps(codec, 0x18);
790 cs4208_fix_amp_caps(codec, 0x1b);
791 cs4208_fix_amp_caps(codec, 0x1c);
793 err = cs_parse_auto_config(codec);
797 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
802 cs_free(codec);
851 static void cs421x_fixup_sense_b(struct hda_codec *codec,
854 struct cs_spec *spec = codec->spec;
951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
954 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003;
961 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
965 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL);
971 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef);
990 static void cs4210_pinmux_init(struct hda_codec *codec)
992 struct cs_spec *spec = codec->spec;
996 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
1008 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
1011 is_active_pin(codec, CS421X_DMIC_PIN_NID)) {
1016 def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID);
1019 snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf);
1023 static void cs4210_spdif_automute(struct hda_codec *codec,
1026 struct cs_spec *spec = codec->spec;
1035 spdif_present = snd_hda_jack_detect(codec, spdif_pin);
1041 snd_hda_set_pin_ctl(codec, spdif_pin, spdif_present ? PIN_OUT : 0);
1043 cs_automute(codec);
1046 static void parse_cs421x_digital(struct hda_codec *codec)
1048 struct cs_spec *spec = codec->spec;
1055 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1057 snd_hda_jack_detect_enable_callback(codec, nid,
1063 static int cs421x_init(struct hda_codec *codec)
1065 struct cs_spec *spec = codec->spec;
1068 snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
1069 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
1070 cs4210_pinmux_init(codec);
1073 snd_hda_gen_init(codec);
1076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
1078 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
1080 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
1084 init_input_coef(codec);
1086 cs4210_spdif_automute(codec, NULL);
1091 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
1096 caps = query_amp_caps(codec, dac, HDA_OUTPUT);
1100 snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps);
1103 static int cs421x_parse_auto_config(struct hda_codec *codec)
1105 struct cs_spec *spec = codec->spec;
1109 fix_volume_caps(codec, dac);
1111 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
1115 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
1119 parse_cs421x_digital(codec);
1135 static int cs421x_suspend(struct hda_codec *codec)
1137 struct cs_spec *spec = codec->spec;
1140 snd_hda_shutup_pins(codec);
1142 snd_hda_codec_write(codec, CS4210_DAC_NID, 0,
1144 snd_hda_codec_write(codec, CS4210_ADC_NID, 0,
1148 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
1150 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
1165 static int patch_cs4210(struct hda_codec *codec)
1170 spec = cs_alloc_spec(codec, CS4210_VENDOR_NID);
1174 codec->patch_ops = cs421x_patch_ops;
1177 snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl,
1179 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1186 cs4210_pinmux_init(codec);
1188 err = cs421x_parse_auto_config(codec);
1192 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1197 cs_free(codec);
1201 static int patch_cs4213(struct hda_codec *codec)
1206 spec = cs_alloc_spec(codec, CS4213_VENDOR_NID);
1210 codec->patch_ops = cs421x_patch_ops;
1212 err = cs421x_parse_auto_config(codec);
1219 cs_free(codec);
1237 MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");