Lines Matching refs:codec
129 static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
131 struct cs_spec *spec = codec->spec;
132 snd_hda_codec_write(codec, spec->vendor_nid, 0,
134 return snd_hda_codec_read(codec, spec->vendor_nid, 0,
138 static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx,
141 struct cs_spec *spec = codec->spec;
142 snd_hda_codec_write(codec, spec->vendor_nid, 0,
144 snd_hda_codec_write(codec, spec->vendor_nid, 0,
154 static void cs_automute(struct hda_codec *codec)
156 struct cs_spec *spec = codec->spec;
161 snd_hda_gen_update_outputs(codec);
170 snd_hda_codec_write(codec, 0x01, 0,
175 static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid)
178 val = snd_hda_codec_get_pincfg(codec, nid);
182 static void init_input_coef(struct hda_codec *codec)
184 struct cs_spec *spec = codec->spec;
189 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG);
190 if (is_active_pin(codec, CS_DMIC2_PIN_NID))
192 if (is_active_pin(codec, CS_DMIC1_PIN_NID))
198 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef);
281 static void init_digital_coef(struct hda_codec *codec)
287 if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID))
292 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef);
295 static int cs_init(struct hda_codec *codec)
297 struct cs_spec *spec = codec->spec;
301 snd_hda_sequence_write(codec, cs_errata_init_verbs);
302 snd_hda_sequence_write(codec, cs_coef_init_verbs);
304 snd_hda_sequence_write(codec, cs4208_coef_init_verbs);
307 snd_hda_gen_init(codec);
310 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
312 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
314 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
319 init_input_coef(codec);
320 init_digital_coef(codec);
326 static int cs_build_controls(struct hda_codec *codec)
330 err = snd_hda_gen_build_controls(codec);
333 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
347 static int cs_parse_auto_config(struct hda_codec *codec)
349 struct cs_spec *spec = codec->spec;
353 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
357 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
368 snd_hda_gen_fix_pin_power(codec,
397 /* codec SSID */
495 static void cs420x_fixup_gpio_13(struct hda_codec *codec,
499 struct cs_spec *spec = codec->spec;
507 static void cs420x_fixup_gpio_23(struct hda_codec *codec,
511 struct cs_spec *spec = codec->spec;
571 static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid)
578 codec->spec = spec;
580 codec->power_save_node = 1;
586 static int patch_cs420x(struct hda_codec *codec)
591 spec = cs_alloc_spec(codec, CS420X_VENDOR_NID);
595 codec->patch_ops = cs_patch_ops;
597 codec->single_adc_amp = 1;
599 snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl,
601 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
603 err = cs_parse_auto_config(codec);
607 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
612 cs_free(codec);
641 /* codec SSID matching */
651 static void cs4208_fixup_gpio0(struct hda_codec *codec,
655 struct cs_spec *spec = codec->spec;
665 /* remap the fixup from codec SSID and apply it */
666 static void cs4208_fixup_mac(struct hda_codec *codec,
672 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
673 snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups);
674 if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET)
675 codec->fixup_id = CS4208_GPIO0; /* default fixup */
676 snd_hda_apply_fixup(codec, action);
680 static void cs4208_fixup_macmini(struct hda_codec *codec,
691 codec->inv_jack_detect = 1;
693 snd_hda_apply_pincfgs(codec, pincfgs);
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 struct cs_spec *spec = codec->spec;
705 snd_hda_set_pin_ctl_cache(codec, pin, pinctl);
710 static void cs4208_fixup_spdif_switch(struct hda_codec *codec,
714 struct cs_spec *spec = codec->spec;
719 kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch");
757 static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc)
761 caps = query_amp_caps(codec, adc, HDA_INPUT);
764 snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps);
767 static int patch_cs4208(struct hda_codec *codec)
772 spec = cs_alloc_spec(codec, CS4208_VENDOR_NID);
776 codec->patch_ops = cs_patch_ops;
781 snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl,
783 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
785 snd_hda_override_wcaps(codec, 0x18,
786 get_wcaps(codec, 0x18) | AC_WCAP_STEREO);
787 cs4208_fix_amp_caps(codec, 0x18);
788 cs4208_fix_amp_caps(codec, 0x1b);
789 cs4208_fix_amp_caps(codec, 0x1c);
791 err = cs_parse_auto_config(codec);
795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
800 cs_free(codec);
849 static void cs421x_fixup_sense_b(struct hda_codec *codec,
852 struct cs_spec *spec = codec->spec;
948 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
951 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003;
958 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
962 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL);
970 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef);
987 static void cs4210_pinmux_init(struct hda_codec *codec)
989 struct cs_spec *spec = codec->spec;
993 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
1005 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
1008 is_active_pin(codec, CS421X_DMIC_PIN_NID)) {
1013 def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID);
1016 snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf);
1020 static void cs4210_spdif_automute(struct hda_codec *codec,
1023 struct cs_spec *spec = codec->spec;
1032 spdif_present = snd_hda_jack_detect(codec, spdif_pin);
1038 snd_hda_set_pin_ctl(codec, spdif_pin, spdif_present ? PIN_OUT : 0);
1040 cs_automute(codec);
1043 static void parse_cs421x_digital(struct hda_codec *codec)
1045 struct cs_spec *spec = codec->spec;
1051 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1053 snd_hda_jack_detect_enable_callback(codec, nid,
1059 static int cs421x_init(struct hda_codec *codec)
1061 struct cs_spec *spec = codec->spec;
1064 snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
1065 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
1066 cs4210_pinmux_init(codec);
1069 snd_hda_gen_init(codec);
1072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
1074 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
1076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
1080 init_input_coef(codec);
1082 cs4210_spdif_automute(codec, NULL);
1087 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
1092 caps = query_amp_caps(codec, dac, HDA_OUTPUT);
1096 snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps);
1099 static int cs421x_parse_auto_config(struct hda_codec *codec)
1101 struct cs_spec *spec = codec->spec;
1105 fix_volume_caps(codec, dac);
1107 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
1111 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
1115 parse_cs421x_digital(codec);
1132 static int cs421x_suspend(struct hda_codec *codec)
1134 struct cs_spec *spec = codec->spec;
1137 snd_hda_shutup_pins(codec);
1139 snd_hda_codec_write(codec, CS4210_DAC_NID, 0,
1141 snd_hda_codec_write(codec, CS4210_ADC_NID, 0,
1145 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
1147 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);
1238 MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");