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