Lines Matching full:codec
21 * @codec: the HDA codec
26 * detection is prohibited in the codec level, the pin config has
29 bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) in is_jack_detectable() argument
31 if (codec->no_jack_detect) in is_jack_detectable()
33 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT)) in is_jack_detectable()
35 if (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) & in is_jack_detectable()
38 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) && in is_jack_detectable()
39 !codec->jackpoll_interval) in is_jack_detectable()
46 static u32 read_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id) in read_pin_sense() argument
51 if (!codec->no_trigger_sense) { in read_pin_sense()
52 pincap = snd_hda_query_pin_caps(codec, nid); in read_pin_sense()
54 snd_hda_codec_read(codec, nid, 0, in read_pin_sense()
57 val = snd_hda_codec_read(codec, nid, 0, in read_pin_sense()
59 if (codec->inv_jack_detect) in read_pin_sense()
66 * @codec: the HDA codec
71 snd_hda_jack_tbl_get_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id) in snd_hda_jack_tbl_get_mst() argument
73 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_get_mst()
78 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_tbl_get_mst()
87 * @codec: the HDA codec
92 snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, in snd_hda_jack_tbl_get_from_tag() argument
95 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_get_from_tag()
100 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_tbl_get_from_tag()
108 any_jack_tbl_get_from_nid(struct hda_codec *codec, hda_nid_t nid) in any_jack_tbl_get_from_nid() argument
110 struct hda_jack_tbl *jack = codec->jacktbl.list; in any_jack_tbl_get_from_nid()
115 for (i = 0; i < codec->jacktbl.used; i++, jack++) in any_jack_tbl_get_from_nid()
123 * @codec: the HDA codec
128 snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id) in snd_hda_jack_tbl_new() argument
131 snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in snd_hda_jack_tbl_new()
133 any_jack_tbl_get_from_nid(codec, nid); in snd_hda_jack_tbl_new()
135 WARN_ON(dev_id != 0 && !codec->dp_mst); in snd_hda_jack_tbl_new()
139 jack = snd_array_new(&codec->jacktbl); in snd_hda_jack_tbl_new()
155 jack->tag = codec->jacktbl.used; in snd_hda_jack_tbl_new()
161 void snd_hda_jack_tbl_disconnect(struct hda_codec *codec) in snd_hda_jack_tbl_disconnect() argument
163 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_disconnect()
166 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_tbl_disconnect()
167 if (!codec->bus->shutdown && jack->jack) in snd_hda_jack_tbl_disconnect()
168 snd_device_disconnect(codec->card, jack->jack); in snd_hda_jack_tbl_disconnect()
172 void snd_hda_jack_tbl_clear(struct hda_codec *codec) in snd_hda_jack_tbl_clear() argument
174 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_clear()
177 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_tbl_clear()
181 if (!codec->bus->shutdown && jack->jack) in snd_hda_jack_tbl_clear()
182 snd_device_free(codec->card, jack->jack); in snd_hda_jack_tbl_clear()
189 snd_array_free(&codec->jacktbl); in snd_hda_jack_tbl_clear()
195 static void jack_detect_update(struct hda_codec *codec, in jack_detect_update() argument
204 jack->pin_sense = read_pin_sense(codec, jack->nid, in jack_detect_update()
209 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id)) in jack_detect_update()
217 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in jack_detect_update()
221 jack_detect_update(codec, gated); in jack_detect_update()
228 * @codec: the HDA codec
233 void snd_hda_jack_set_dirty_all(struct hda_codec *codec) in snd_hda_jack_set_dirty_all() argument
235 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_set_dirty_all()
238 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_set_dirty_all()
246 * @codec: the CODEC to sense
253 u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id) in snd_hda_jack_pin_sense() argument
256 snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in snd_hda_jack_pin_sense()
258 jack_detect_update(codec, jack); in snd_hda_jack_pin_sense()
261 return read_pin_sense(codec, nid, dev_id); in snd_hda_jack_pin_sense()
267 * @codec: the CODEC to sense
274 int snd_hda_jack_detect_state_mst(struct hda_codec *codec, in snd_hda_jack_detect_state_mst() argument
278 snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in snd_hda_jack_detect_state_mst()
281 else if (snd_hda_jack_pin_sense(codec, nid, dev_id) & in snd_hda_jack_detect_state_mst()
308 * @codec: the HDA codec
318 snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_detect_enable_callback_mst() argument
325 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_detect_enable_callback_mst()
345 if (codec->jackpoll_interval > 0) in snd_hda_jack_detect_enable_callback_mst()
347 err = snd_hda_codec_write_cache(codec, nid, 0, in snd_hda_jack_detect_enable_callback_mst()
358 * @codec: the HDA codec
365 int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_detect_enable() argument
368 return PTR_ERR_OR_ZERO(snd_hda_jack_detect_enable_callback_mst(codec, in snd_hda_jack_detect_enable()
377 * @codec: the HDA codec
383 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, in snd_hda_jack_set_gating_jack() argument
386 struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid, 0); in snd_hda_jack_set_gating_jack()
388 snd_hda_jack_tbl_new(codec, gating_nid, 0); in snd_hda_jack_set_gating_jack()
390 WARN_ON(codec->dp_mst); in snd_hda_jack_set_gating_jack()
404 * @codec: the HDA codec
412 int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid, in snd_hda_jack_bind_keymap() argument
417 struct hda_jack_tbl *key_gen = snd_hda_jack_tbl_get(codec, key_nid); in snd_hda_jack_bind_keymap()
418 struct hda_jack_tbl *report_to = snd_hda_jack_tbl_get(codec, jack_nid); in snd_hda_jack_bind_keymap()
420 WARN_ON(codec->dp_mst); in snd_hda_jack_bind_keymap()
437 * @codec: the HDA codec
439 * @button_state: the button event captured by codec
441 * Codec driver calls this function to report the button event.
443 void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid, in snd_hda_jack_set_button_state() argument
446 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid); in snd_hda_jack_set_button_state()
453 snd_hda_jack_tbl_get(codec, jack->key_report_jack); in snd_hda_jack_set_button_state()
467 * @codec: the HDA codec
469 void snd_hda_jack_report_sync(struct hda_codec *codec) in snd_hda_jack_report_sync() argument
475 jack = codec->jacktbl.list; in snd_hda_jack_report_sync()
476 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_report_sync()
478 jack_detect_update(codec, jack); in snd_hda_jack_report_sync()
483 jack = codec->jacktbl.list; in snd_hda_jack_report_sync()
484 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_report_sync()
502 static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid) in get_input_jack_type() argument
504 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); in get_input_jack_type()
530 * @codec: the HDA codec
541 int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_add_kctl_mst() argument
549 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_add_kctl_mst()
556 type = get_input_jack_type(codec, nid); in snd_hda_jack_add_kctl_mst()
564 err = snd_jack_new(codec->card, name, type | buttons, in snd_hda_jack_add_kctl_mst()
579 state = snd_hda_jack_detect_mst(codec, nid, dev_id); in snd_hda_jack_add_kctl_mst()
586 static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, in add_jack_kctl() argument
595 WARN_ON(codec->dp_mst); in add_jack_kctl()
599 def_conf = snd_hda_codec_get_pincfg(codec, nid); in add_jack_kctl()
604 !is_jack_detectable(codec, nid); in add_jack_kctl()
609 snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL); in add_jack_kctl()
613 err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, 0, NULL); in add_jack_kctl()
618 return snd_hda_jack_detect_enable(codec, nid, 0); in add_jack_kctl()
624 * @codec: the HDA codec
627 int snd_hda_jack_add_kctls(struct hda_codec *codec, in snd_hda_jack_add_kctls() argument
638 err = add_jack_kctl(codec, auto_cfg_hp_pins(cfg)[0], in snd_hda_jack_add_kctls()
641 err = add_jack_kctl(codec, cfg->inputs[i].pin, in snd_hda_jack_add_kctls()
644 err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg, in snd_hda_jack_add_kctls()
651 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
658 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
665 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
670 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
674 err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, NULL); in snd_hda_jack_add_kctls()
677 err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, NULL); in snd_hda_jack_add_kctls()
684 static void call_jack_callback(struct hda_codec *codec, unsigned int res, in call_jack_callback() argument
692 cb->func(codec, cb); in call_jack_callback()
696 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in call_jack_callback()
702 cb->func(codec, cb); in call_jack_callback()
710 * @codec: the HDA codec
713 void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res) in snd_hda_jack_unsol_event() argument
718 if (codec->dp_mst) { in snd_hda_jack_unsol_event()
722 event = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in snd_hda_jack_unsol_event()
724 event = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in snd_hda_jack_unsol_event()
731 snd_hda_jack_tbl_get_mst(codec, event->key_report_jack, in snd_hda_jack_unsol_event()
738 call_jack_callback(codec, res, event); in snd_hda_jack_unsol_event()
739 snd_hda_jack_report_sync(codec); in snd_hda_jack_unsol_event()
745 * @codec: the HDA codec
750 void snd_hda_jack_poll_all(struct hda_codec *codec) in snd_hda_jack_poll_all() argument
752 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_poll_all()
755 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_poll_all()
760 jack_detect_update(codec, jack); in snd_hda_jack_poll_all()
764 call_jack_callback(codec, 0, jack); in snd_hda_jack_poll_all()
767 snd_hda_jack_report_sync(codec); in snd_hda_jack_poll_all()