Lines Matching refs:codec

142 static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)  in cs_vendor_coef_get()  argument
144 struct cs_spec *spec = codec->spec; in cs_vendor_coef_get()
145 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
147 return snd_hda_codec_read(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
151 static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, in cs_vendor_coef_set() argument
154 struct cs_spec *spec = codec->spec; in cs_vendor_coef_set()
155 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
157 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
167 static void cs_automute(struct hda_codec *codec) in cs_automute() argument
169 struct cs_spec *spec = codec->spec; in cs_automute()
174 snd_hda_gen_update_outputs(codec); in cs_automute()
183 snd_hda_codec_write(codec, 0x01, 0, in cs_automute()
188 static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid) in is_active_pin() argument
191 val = snd_hda_codec_get_pincfg(codec, nid); in is_active_pin()
195 static void init_input_coef(struct hda_codec *codec) in init_input_coef() argument
197 struct cs_spec *spec = codec->spec; in init_input_coef()
202 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG); in init_input_coef()
203 if (is_active_pin(codec, CS_DMIC2_PIN_NID)) in init_input_coef()
205 if (is_active_pin(codec, CS_DMIC1_PIN_NID)) in init_input_coef()
211 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef); in init_input_coef()
294 static void init_digital_coef(struct hda_codec *codec) in init_digital_coef() argument
300 if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) in init_digital_coef()
305 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); in init_digital_coef()
308 static int cs_init(struct hda_codec *codec) in cs_init() argument
310 struct cs_spec *spec = codec->spec; in cs_init()
314 snd_hda_sequence_write(codec, cs_errata_init_verbs); in cs_init()
315 snd_hda_sequence_write(codec, cs_coef_init_verbs); in cs_init()
317 snd_hda_sequence_write(codec, cs4208_coef_init_verbs); in cs_init()
320 snd_hda_gen_init(codec); in cs_init()
323 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, in cs_init()
325 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, in cs_init()
327 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in cs_init()
332 init_input_coef(codec); in cs_init()
333 init_digital_coef(codec); in cs_init()
339 static int cs_build_controls(struct hda_codec *codec) in cs_build_controls() argument
343 err = snd_hda_gen_build_controls(codec); in cs_build_controls()
346 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in cs_build_controls()
360 static int cs_parse_auto_config(struct hda_codec *codec) in cs_parse_auto_config() argument
362 struct cs_spec *spec = codec->spec; in cs_parse_auto_config()
366 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs_parse_auto_config()
370 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs_parse_auto_config()
381 snd_hda_gen_fix_pin_power(codec, in cs_parse_auto_config()
506 static void cs420x_fixup_gpio_13(struct hda_codec *codec, in cs420x_fixup_gpio_13() argument
510 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_13()
518 static void cs420x_fixup_gpio_23(struct hda_codec *codec, in cs420x_fixup_gpio_23() argument
522 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_23()
582 static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid) in cs_alloc_spec() argument
589 codec->spec = spec; in cs_alloc_spec()
591 codec->power_save_node = 1; in cs_alloc_spec()
597 static int patch_cs420x(struct hda_codec *codec) in patch_cs420x() argument
602 spec = cs_alloc_spec(codec, CS420X_VENDOR_NID); in patch_cs420x()
606 codec->patch_ops = cs_patch_ops; in patch_cs420x()
608 codec->single_adc_amp = 1; in patch_cs420x()
610 snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl, in patch_cs420x()
612 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs420x()
614 err = cs_parse_auto_config(codec); in patch_cs420x()
618 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs420x()
623 cs_free(codec); in patch_cs420x()
662 static void cs4208_fixup_gpio0(struct hda_codec *codec, in cs4208_fixup_gpio0() argument
666 struct cs_spec *spec = codec->spec; in cs4208_fixup_gpio0()
677 static void cs4208_fixup_mac(struct hda_codec *codec, in cs4208_fixup_mac() argument
683 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in cs4208_fixup_mac()
684 snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups); in cs4208_fixup_mac()
685 if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET) in cs4208_fixup_mac()
686 codec->fixup_id = CS4208_GPIO0; /* default fixup */ in cs4208_fixup_mac()
687 snd_hda_apply_fixup(codec, action); in cs4208_fixup_mac()
691 static void cs4208_fixup_macmini(struct hda_codec *codec, in cs4208_fixup_macmini() argument
702 codec->inv_jack_detect = 1; in cs4208_fixup_macmini()
704 snd_hda_apply_pincfgs(codec, pincfgs); in cs4208_fixup_macmini()
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs4208_spdif_sw_put() local
712 struct cs_spec *spec = codec->spec; in cs4208_spdif_sw_put()
716 snd_hda_set_pin_ctl_cache(codec, pin, pinctl); in cs4208_spdif_sw_put()
721 static void cs4208_fixup_spdif_switch(struct hda_codec *codec, in cs4208_fixup_spdif_switch() argument
725 struct cs_spec *spec = codec->spec; in cs4208_fixup_spdif_switch()
730 kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch"); in cs4208_fixup_spdif_switch()
768 static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc) in cs4208_fix_amp_caps() argument
772 caps = query_amp_caps(codec, adc, HDA_INPUT); in cs4208_fix_amp_caps()
775 snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps); in cs4208_fix_amp_caps()
778 static int patch_cs4208(struct hda_codec *codec) in patch_cs4208() argument
783 spec = cs_alloc_spec(codec, CS4208_VENDOR_NID); in patch_cs4208()
787 codec->patch_ops = cs_patch_ops; in patch_cs4208()
792 snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl, in patch_cs4208()
794 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs4208()
796 snd_hda_override_wcaps(codec, 0x18, in patch_cs4208()
797 get_wcaps(codec, 0x18) | AC_WCAP_STEREO); in patch_cs4208()
798 cs4208_fix_amp_caps(codec, 0x18); in patch_cs4208()
799 cs4208_fix_amp_caps(codec, 0x1b); in patch_cs4208()
800 cs4208_fix_amp_caps(codec, 0x1c); in patch_cs4208()
802 err = cs_parse_auto_config(codec); in patch_cs4208()
806 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs4208()
811 cs_free(codec); in patch_cs4208()
860 static void cs421x_fixup_sense_b(struct hda_codec *codec, in cs421x_fixup_sense_b() argument
863 struct cs_spec *spec = codec->spec; in cs421x_fixup_sense_b()
959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs421x_boost_vol_get() local
962 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003; in cs421x_boost_vol_get()
969 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs421x_boost_vol_put() local
973 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL); in cs421x_boost_vol_put()
981 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef); in cs421x_boost_vol_put()
998 static void cs4210_pinmux_init(struct hda_codec *codec) in cs4210_pinmux_init() argument
1000 struct cs_spec *spec = codec->spec; in cs4210_pinmux_init()
1004 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs4210_pinmux_init()
1016 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs4210_pinmux_init()
1019 is_active_pin(codec, CS421X_DMIC_PIN_NID)) { in cs4210_pinmux_init()
1024 def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID); in cs4210_pinmux_init()
1027 snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf); in cs4210_pinmux_init()
1031 static void cs4210_spdif_automute(struct hda_codec *codec, in cs4210_spdif_automute() argument
1034 struct cs_spec *spec = codec->spec; in cs4210_spdif_automute()
1043 spdif_present = snd_hda_jack_detect(codec, spdif_pin); in cs4210_spdif_automute()
1049 snd_hda_set_pin_ctl(codec, spdif_pin, spdif_present ? PIN_OUT : 0); in cs4210_spdif_automute()
1051 cs_automute(codec); in cs4210_spdif_automute()
1054 static void parse_cs421x_digital(struct hda_codec *codec) in parse_cs421x_digital() argument
1056 struct cs_spec *spec = codec->spec; in parse_cs421x_digital()
1062 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { in parse_cs421x_digital()
1064 snd_hda_jack_detect_enable_callback(codec, nid, in parse_cs421x_digital()
1070 static int cs421x_init(struct hda_codec *codec) in cs421x_init() argument
1072 struct cs_spec *spec = codec->spec; in cs421x_init()
1075 snd_hda_sequence_write(codec, cs421x_coef_init_verbs); in cs421x_init()
1076 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes); in cs421x_init()
1077 cs4210_pinmux_init(codec); in cs421x_init()
1080 snd_hda_gen_init(codec); in cs421x_init()
1083 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, in cs421x_init()
1085 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, in cs421x_init()
1087 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in cs421x_init()
1091 init_input_coef(codec); in cs421x_init()
1093 cs4210_spdif_automute(codec, NULL); in cs421x_init()
1098 static int cs421x_build_controls(struct hda_codec *codec) in cs421x_build_controls() argument
1100 struct cs_spec *spec = codec->spec; in cs421x_build_controls()
1103 err = snd_hda_gen_build_controls(codec); in cs421x_build_controls()
1109 err = snd_hda_ctl_add(codec, 0, in cs421x_build_controls()
1110 snd_ctl_new1(&cs421x_speaker_boost_ctl, codec)); in cs421x_build_controls()
1117 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) in fix_volume_caps() argument
1122 caps = query_amp_caps(codec, dac, HDA_OUTPUT); in fix_volume_caps()
1126 snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); in fix_volume_caps()
1129 static int cs421x_parse_auto_config(struct hda_codec *codec) in cs421x_parse_auto_config() argument
1131 struct cs_spec *spec = codec->spec; in cs421x_parse_auto_config()
1135 fix_volume_caps(codec, dac); in cs421x_parse_auto_config()
1137 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs421x_parse_auto_config()
1141 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs421x_parse_auto_config()
1145 parse_cs421x_digital(codec); in cs421x_parse_auto_config()
1154 static int cs421x_suspend(struct hda_codec *codec) in cs421x_suspend() argument
1156 struct cs_spec *spec = codec->spec; in cs421x_suspend()
1159 snd_hda_shutup_pins(codec); in cs421x_suspend()
1161 snd_hda_codec_write(codec, CS4210_DAC_NID, 0, in cs421x_suspend()
1163 snd_hda_codec_write(codec, CS4210_ADC_NID, 0, in cs421x_suspend()
1167 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs421x_suspend()
1169 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs421x_suspend()
1187 static int patch_cs4210(struct hda_codec *codec) in patch_cs4210() argument
1192 spec = cs_alloc_spec(codec, CS4210_VENDOR_NID); in patch_cs4210()
1196 codec->patch_ops = cs421x_patch_ops; in patch_cs4210()
1199 snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl, in patch_cs4210()
1201 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs4210()
1208 cs4210_pinmux_init(codec); in patch_cs4210()
1210 err = cs421x_parse_auto_config(codec); in patch_cs4210()
1214 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs4210()
1219 cs_free(codec); in patch_cs4210()
1223 static int patch_cs4213(struct hda_codec *codec) in patch_cs4213() argument
1228 spec = cs_alloc_spec(codec, CS4213_VENDOR_NID); in patch_cs4213()
1232 codec->patch_ops = cs421x_patch_ops; in patch_cs4213()
1234 err = cs421x_parse_auto_config(codec); in patch_cs4213()
1241 cs_free(codec); in patch_cs4213()