Lines Matching refs:codec

115 static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)  in cs_vendor_coef_get()  argument
117 snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, in cs_vendor_coef_get()
119 return snd_hda_codec_read(codec, CS420X_VENDOR_NID, 0, in cs_vendor_coef_get()
123 static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, in cs_vendor_coef_set() argument
126 snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, in cs_vendor_coef_set()
128 snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, in cs_vendor_coef_set()
140 struct hda_codec *codec, in cs_playback_pcm_open() argument
143 struct cs_spec *spec = codec->spec; in cs_playback_pcm_open()
144 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, in cs_playback_pcm_open()
149 struct hda_codec *codec, in cs_playback_pcm_prepare() argument
154 struct cs_spec *spec = codec->spec; in cs_playback_pcm_prepare()
155 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, in cs_playback_pcm_prepare()
160 struct hda_codec *codec, in cs_playback_pcm_cleanup() argument
163 struct cs_spec *spec = codec->spec; in cs_playback_pcm_cleanup()
164 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); in cs_playback_pcm_cleanup()
171 struct hda_codec *codec, in cs_dig_playback_pcm_open() argument
174 struct cs_spec *spec = codec->spec; in cs_dig_playback_pcm_open()
175 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in cs_dig_playback_pcm_open()
179 struct hda_codec *codec, in cs_dig_playback_pcm_close() argument
182 struct cs_spec *spec = codec->spec; in cs_dig_playback_pcm_close()
183 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in cs_dig_playback_pcm_close()
187 struct hda_codec *codec, in cs_dig_playback_pcm_prepare() argument
192 struct cs_spec *spec = codec->spec; in cs_dig_playback_pcm_prepare()
193 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, in cs_dig_playback_pcm_prepare()
198 struct hda_codec *codec, in cs_dig_playback_pcm_cleanup() argument
201 struct cs_spec *spec = codec->spec; in cs_dig_playback_pcm_cleanup()
202 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in cs_dig_playback_pcm_cleanup()
209 struct hda_codec *codec, in cs_capture_pcm_prepare() argument
214 struct cs_spec *spec = codec->spec; in cs_capture_pcm_prepare()
218 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); in cs_capture_pcm_prepare()
223 struct hda_codec *codec, in cs_capture_pcm_cleanup() argument
226 struct cs_spec *spec = codec->spec; in cs_capture_pcm_cleanup()
227 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); in cs_capture_pcm_cleanup()
273 static int cs_build_pcms(struct hda_codec *codec) in cs_build_pcms() argument
275 struct cs_spec *spec = codec->spec; in cs_build_pcms()
278 codec->pcm_info = info; in cs_build_pcms()
279 codec->num_pcms = 0; in cs_build_pcms()
289 codec->num_pcms++; in cs_build_pcms()
310 codec->num_pcms++; in cs_build_pcms()
319 static hda_nid_t get_dac(struct hda_codec *codec, hda_nid_t pin) in get_dac() argument
324 if (snd_hda_get_connections(codec, pin, &dac, 1) != 1) in get_dac()
329 static int is_ext_mic(struct hda_codec *codec, unsigned int idx) in is_ext_mic() argument
331 struct cs_spec *spec = codec->spec; in is_ext_mic()
334 unsigned int val = snd_hda_query_pin_caps(codec, pin); in is_ext_mic()
337 val = snd_hda_codec_get_pincfg(codec, pin); in is_ext_mic()
341 static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, in get_adc() argument
347 nid = codec->start_nid; in get_adc()
348 for (i = 0; i < codec->num_nodes; i++, nid++) { in get_adc()
352 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) in get_adc()
356 nums = snd_hda_get_connections(codec, nid, pins, in get_adc()
370 static int is_active_pin(struct hda_codec *codec, hda_nid_t nid) in is_active_pin() argument
373 val = snd_hda_codec_get_pincfg(codec, nid); in is_active_pin()
377 static int parse_output(struct hda_codec *codec) in parse_output() argument
379 struct cs_spec *spec = codec->spec; in parse_output()
385 dac = get_dac(codec, cfg->line_out_pins[i]); in parse_output()
397 dac = get_dac(codec, cfg->hp_pins[i]); in parse_output()
406 dac = get_dac(codec, cfg->speaker_pins[i]); in parse_output()
422 static int parse_input(struct hda_codec *codec) in parse_input() argument
424 struct cs_spec *spec = codec->spec; in parse_input()
433 spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]); in parse_input()
442 if (is_ext_mic(codec, cfg->inputs[0].pin)) { in parse_input()
443 if (!is_ext_mic(codec, cfg->inputs[1].pin)) { in parse_input()
448 if (is_ext_mic(codec, cfg->inputs[1].pin)) { in parse_input()
458 static int parse_digital_output(struct hda_codec *codec) in parse_digital_output() argument
460 struct cs_spec *spec = codec->spec; in parse_digital_output()
466 if (snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) < 1) in parse_digital_output()
471 snd_hda_get_connections(codec, cfg->dig_out_pins[1], &nid, 1) > 0) { in parse_digital_output()
473 codec->slave_dig_outs = spec->slave_dig_outs; in parse_digital_output()
478 static int parse_digital_input(struct hda_codec *codec) in parse_digital_input() argument
480 struct cs_spec *spec = codec->spec; in parse_digital_input()
485 spec->dig_in = get_adc(codec, cfg->dig_in_pin, &idx); in parse_digital_input()
495 static int add_mute(struct hda_codec *codec, const char *name, int index, in add_mute() argument
503 *kctlp = snd_ctl_new1(&knew, codec); in add_mute()
505 return snd_hda_ctl_add(codec, 0, *kctlp); in add_mute()
508 static int add_volume(struct hda_codec *codec, const char *name, in add_volume() argument
517 *kctlp = snd_ctl_new1(&knew, codec); in add_volume()
519 return snd_hda_ctl_add(codec, 0, *kctlp); in add_volume()
522 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) in fix_volume_caps() argument
527 caps = query_amp_caps(codec, dac, HDA_OUTPUT); in fix_volume_caps()
531 snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); in fix_volume_caps()
534 static int add_vmaster(struct hda_codec *codec, hda_nid_t dac) in add_vmaster() argument
536 struct cs_spec *spec = codec->spec; in add_vmaster()
542 err = snd_hda_ctl_add(codec, dac, spec->vmaster_sw); in add_vmaster()
546 snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); in add_vmaster()
549 err = snd_hda_ctl_add(codec, dac, spec->vmaster_vol); in add_vmaster()
555 static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx, in add_output() argument
558 struct cs_spec *spec = codec->spec; in add_output()
569 fix_volume_caps(codec, dac); in add_output()
571 err = add_vmaster(codec, dac); in add_output()
596 err = add_mute(codec, name, index, in add_output()
604 err = add_volume(codec, name, index, in add_output()
615 static int build_output(struct hda_codec *codec) in build_output() argument
617 struct cs_spec *spec = codec->spec; in build_output()
622 err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]), in build_output()
628 err = add_output(codec, get_dac(codec, cfg->hp_pins[i]), in build_output()
634 err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]), in build_output()
650 static int change_cur_input(struct hda_codec *codec, unsigned int idx, in change_cur_input() argument
653 struct cs_spec *spec = codec->spec; in change_cur_input()
659 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); in change_cur_input()
661 snd_hda_codec_setup_stream(codec, spec->cur_adc, in change_cur_input()
665 snd_hda_codec_write(codec, spec->cur_adc, 0, in change_cur_input()
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs_capture_source_info() local
676 struct cs_spec *spec = codec->spec; in cs_capture_source_info()
687 hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); in cs_capture_source_info()
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs_capture_source_get() local
695 struct cs_spec *spec = codec->spec; in cs_capture_source_get()
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs_capture_source_put() local
704 struct cs_spec *spec = codec->spec; in cs_capture_source_put()
710 return change_cur_input(codec, idx, 0); in cs_capture_source_put()
722 static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, in make_bind_capture() argument
725 struct cs_spec *spec = codec->spec; in make_bind_capture()
746 static int add_input_volume_control(struct hda_codec *codec, in add_input_volume_control() argument
755 if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) in add_input_volume_control()
757 caps = query_amp_caps(codec, pin, HDA_INPUT); in add_input_volume_control()
761 label = hda_get_autocfg_input_label(codec, cfg, item); in add_input_volume_control()
762 return add_volume(codec, label, 0, in add_input_volume_control()
766 static int build_input(struct hda_codec *codec) in build_input() argument
768 struct cs_spec *spec = codec->spec; in build_input()
775 spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw); in build_input()
776 spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); in build_input()
782 kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); in build_input()
786 err = snd_hda_ctl_add(codec, 0, kctl); in build_input()
792 err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[n]); in build_input()
799 err = snd_hda_ctl_add(codec, 0, in build_input()
800 snd_ctl_new1(&cs_capture_source, codec)); in build_input()
806 err = add_input_volume_control(codec, &spec->autocfg, i); in build_input()
817 static int build_digital_output(struct hda_codec *codec) in build_digital_output() argument
819 struct cs_spec *spec = codec->spec; in build_digital_output()
825 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); in build_digital_output()
828 err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); in build_digital_output()
834 static int build_digital_input(struct hda_codec *codec) in build_digital_input() argument
836 struct cs_spec *spec = codec->spec; in build_digital_input()
838 return snd_hda_create_spdif_in_ctls(codec, spec->dig_in); in build_digital_input()
846 static void cs_automute(struct hda_codec *codec) in cs_automute() argument
848 struct cs_spec *spec = codec->spec; in cs_automute()
857 caps = snd_hda_query_pin_caps(codec, nid); in cs_automute()
860 hp_present = snd_hda_jack_detect(codec, nid); in cs_automute()
866 snd_hda_codec_write(codec, nid, 0, in cs_automute()
874 snd_hda_codec_write(codec, 0x01, 0, in cs_automute()
879 static void cs_automic(struct hda_codec *codec) in cs_automic() argument
881 struct cs_spec *spec = codec->spec; in cs_automic()
887 present = snd_hda_jack_detect(codec, nid); in cs_automic()
889 change_cur_input(codec, spec->automic_idx, 0); in cs_automic()
891 change_cur_input(codec, !spec->automic_idx, 0); in cs_automic()
897 static void init_output(struct hda_codec *codec) in init_output() argument
899 struct cs_spec *spec = codec->spec; in init_output()
905 snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, in init_output()
908 snd_hda_codec_write(codec, spec->multiout.hp_nid, 0, in init_output()
913 snd_hda_codec_write(codec, spec->multiout.extra_out_nid[i], 0, in init_output()
919 snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, in init_output()
923 snd_hda_codec_write(codec, nid, 0, in init_output()
927 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { in init_output()
928 snd_hda_codec_write(codec, nid, 0, in init_output()
935 snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, in init_output()
938 cs_automute(codec); in init_output()
941 static void init_input(struct hda_codec *codec) in init_input() argument
943 struct cs_spec *spec = codec->spec; in init_input()
956 unsigned int caps = snd_hda_query_pin_caps(codec, pin); in init_input()
961 snd_hda_codec_write(codec, pin, 0, in init_input()
963 snd_hda_codec_write(codec, spec->adc_nid[i], 0, in init_input()
967 snd_hda_codec_write(codec, pin, 0, in init_input()
971 change_cur_input(codec, spec->cur_input, 1); in init_input()
973 cs_automic(codec); in init_input()
976 if (is_active_pin(codec, CS_DMIC2_PIN_NID)) in init_input()
978 if (is_active_pin(codec, CS_DMIC1_PIN_NID)) in init_input()
983 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); in init_input()
1052 static void init_digital(struct hda_codec *codec) in init_digital() argument
1058 if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) in init_digital()
1063 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); in init_digital()
1066 static int cs_init(struct hda_codec *codec) in cs_init() argument
1068 struct cs_spec *spec = codec->spec; in cs_init()
1071 snd_hda_sequence_write(codec, cs_errata_init_verbs); in cs_init()
1073 snd_hda_sequence_write(codec, cs_coef_init_verbs); in cs_init()
1076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, in cs_init()
1078 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, in cs_init()
1080 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in cs_init()
1084 init_output(codec); in cs_init()
1085 init_input(codec); in cs_init()
1086 init_digital(codec); in cs_init()
1090 static int cs_build_controls(struct hda_codec *codec) in cs_build_controls() argument
1094 err = build_output(codec); in cs_build_controls()
1097 err = build_input(codec); in cs_build_controls()
1100 err = build_digital_output(codec); in cs_build_controls()
1103 err = build_digital_input(codec); in cs_build_controls()
1106 return cs_init(codec); in cs_build_controls()
1109 static void cs_free(struct hda_codec *codec) in cs_free() argument
1111 struct cs_spec *spec = codec->spec; in cs_free()
1114 kfree(codec->spec); in cs_free()
1117 static void cs_unsol_event(struct hda_codec *codec, unsigned int res) in cs_unsol_event() argument
1121 cs_automute(codec); in cs_unsol_event()
1124 cs_automic(codec); in cs_unsol_event()
1137 static int cs_parse_auto_config(struct hda_codec *codec) in cs_parse_auto_config() argument
1139 struct cs_spec *spec = codec->spec; in cs_parse_auto_config()
1142 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); in cs_parse_auto_config()
1146 err = parse_output(codec); in cs_parse_auto_config()
1149 err = parse_input(codec); in cs_parse_auto_config()
1152 err = parse_digital_output(codec); in cs_parse_auto_config()
1155 err = parse_digital_input(codec); in cs_parse_auto_config()
1231 static void fix_pincfg(struct hda_codec *codec, int model) in fix_pincfg() argument
1237 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); in fix_pincfg()
1241 static int patch_cs420x(struct hda_codec *codec) in patch_cs420x() argument
1249 codec->spec = spec; in patch_cs420x()
1252 snd_hda_check_board_config(codec, CS420X_MODELS, in patch_cs420x()
1255 fix_pincfg(codec, spec->board_config); in patch_cs420x()
1268 err = cs_parse_auto_config(codec); in patch_cs420x()
1272 codec->patch_ops = cs_patch_ops; in patch_cs420x()
1277 kfree(codec->spec); in patch_cs420x()
1278 codec->spec = NULL; in patch_cs420x()