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_clear(struct hda_codec *codec) in snd_hda_jack_tbl_clear() argument
163 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_clear()
166 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_tbl_clear()
170 if (!codec->bus->shutdown && jack->jack) in snd_hda_jack_tbl_clear()
171 snd_device_free(codec->card, jack->jack); in snd_hda_jack_tbl_clear()
178 snd_array_free(&codec->jacktbl); in snd_hda_jack_tbl_clear()
184 static void jack_detect_update(struct hda_codec *codec, in jack_detect_update() argument
193 jack->pin_sense = read_pin_sense(codec, jack->nid, in jack_detect_update()
198 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id)) in jack_detect_update()
206 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in jack_detect_update()
210 jack_detect_update(codec, gated); in jack_detect_update()
217 * @codec: the HDA codec
222 void snd_hda_jack_set_dirty_all(struct hda_codec *codec) in snd_hda_jack_set_dirty_all() argument
224 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_set_dirty_all()
227 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_set_dirty_all()
235 * @codec: the CODEC to sense
242 u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id) in snd_hda_jack_pin_sense() argument
245 snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in snd_hda_jack_pin_sense()
247 jack_detect_update(codec, jack); in snd_hda_jack_pin_sense()
250 return read_pin_sense(codec, nid, dev_id); in snd_hda_jack_pin_sense()
256 * @codec: the CODEC to sense
263 int snd_hda_jack_detect_state_mst(struct hda_codec *codec, in snd_hda_jack_detect_state_mst() argument
267 snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in snd_hda_jack_detect_state_mst()
270 else if (snd_hda_jack_pin_sense(codec, nid, dev_id) & in snd_hda_jack_detect_state_mst()
297 * @codec: the HDA codec
307 snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_detect_enable_callback_mst() argument
314 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_detect_enable_callback_mst()
334 if (codec->jackpoll_interval > 0) in snd_hda_jack_detect_enable_callback_mst()
336 err = snd_hda_codec_write_cache(codec, nid, 0, in snd_hda_jack_detect_enable_callback_mst()
347 * @codec: the HDA codec
354 int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_detect_enable() argument
357 return PTR_ERR_OR_ZERO(snd_hda_jack_detect_enable_callback_mst(codec, in snd_hda_jack_detect_enable()
366 * @codec: the HDA codec
372 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, in snd_hda_jack_set_gating_jack() argument
375 struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid, 0); in snd_hda_jack_set_gating_jack()
377 snd_hda_jack_tbl_new(codec, gating_nid, 0); in snd_hda_jack_set_gating_jack()
379 WARN_ON(codec->dp_mst); in snd_hda_jack_set_gating_jack()
393 * @codec: the HDA codec
395 void snd_hda_jack_report_sync(struct hda_codec *codec) in snd_hda_jack_report_sync() argument
401 jack = codec->jacktbl.list; in snd_hda_jack_report_sync()
402 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_report_sync()
404 jack_detect_update(codec, jack); in snd_hda_jack_report_sync()
409 jack = codec->jacktbl.list; in snd_hda_jack_report_sync()
410 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_report_sync()
428 static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid) in get_input_jack_type() argument
430 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); in get_input_jack_type()
456 * @codec: the HDA codec
467 int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid, in snd_hda_jack_add_kctl_mst() argument
475 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_add_kctl_mst()
482 type = get_input_jack_type(codec, nid); in snd_hda_jack_add_kctl_mst()
490 err = snd_jack_new(codec->card, name, type | buttons, in snd_hda_jack_add_kctl_mst()
505 state = snd_hda_jack_detect_mst(codec, nid, dev_id); in snd_hda_jack_add_kctl_mst()
512 static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, in add_jack_kctl() argument
521 WARN_ON(codec->dp_mst); in add_jack_kctl()
525 def_conf = snd_hda_codec_get_pincfg(codec, nid); in add_jack_kctl()
530 !is_jack_detectable(codec, nid); in add_jack_kctl()
535 snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL); in add_jack_kctl()
539 err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, 0, NULL); in add_jack_kctl()
544 return snd_hda_jack_detect_enable(codec, nid, 0); in add_jack_kctl()
550 * @codec: the HDA codec
553 int snd_hda_jack_add_kctls(struct hda_codec *codec, in snd_hda_jack_add_kctls() argument
564 err = add_jack_kctl(codec, auto_cfg_hp_pins(cfg)[0], in snd_hda_jack_add_kctls()
567 err = add_jack_kctl(codec, cfg->inputs[i].pin, in snd_hda_jack_add_kctls()
570 err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg, in snd_hda_jack_add_kctls()
577 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
584 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
591 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
596 err = add_jack_kctl(codec, *p, cfg, NULL); in snd_hda_jack_add_kctls()
600 err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, NULL); in snd_hda_jack_add_kctls()
603 err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, NULL); in snd_hda_jack_add_kctls()
610 static void call_jack_callback(struct hda_codec *codec, unsigned int res, in call_jack_callback() argument
618 cb->func(codec, cb); in call_jack_callback()
622 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in call_jack_callback()
628 cb->func(codec, cb); in call_jack_callback()
636 * @codec: the HDA codec
639 void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res) in snd_hda_jack_unsol_event() argument
644 if (codec->dp_mst) { in snd_hda_jack_unsol_event()
648 event = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in snd_hda_jack_unsol_event()
650 event = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in snd_hda_jack_unsol_event()
656 call_jack_callback(codec, res, event); in snd_hda_jack_unsol_event()
657 snd_hda_jack_report_sync(codec); in snd_hda_jack_unsol_event()
663 * @codec: the HDA codec
668 void snd_hda_jack_poll_all(struct hda_codec *codec) in snd_hda_jack_poll_all() argument
670 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_poll_all()
673 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_poll_all()
678 jack_detect_update(codec, jack); in snd_hda_jack_poll_all()
682 call_jack_callback(codec, 0, jack); in snd_hda_jack_poll_all()
685 snd_hda_jack_report_sync(codec); in snd_hda_jack_poll_all()