Lines Matching refs: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_disconnect(struct hda_codec *codec)
163 struct hda_jack_tbl *jack = codec->jacktbl.list;
166 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
167 if (!codec->bus->shutdown && jack->jack)
168 snd_device_disconnect(codec->card, jack->jack);
172 void snd_hda_jack_tbl_clear(struct hda_codec *codec)
174 struct hda_jack_tbl *jack = codec->jacktbl.list;
177 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
181 if (!codec->bus->shutdown && jack->jack)
182 snd_device_free(codec->card, jack->jack);
189 snd_array_free(&codec->jacktbl);
195 static void jack_detect_update(struct hda_codec *codec,
204 jack->pin_sense = read_pin_sense(codec, jack->nid,
209 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id))
217 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
221 jack_detect_update(codec, gated);
228 * @codec: the HDA codec
233 void snd_hda_jack_set_dirty_all(struct hda_codec *codec)
235 struct hda_jack_tbl *jack = codec->jacktbl.list;
238 for (i = 0; i < codec->jacktbl.used; i++, jack++)
246 * @codec: the CODEC to sense
253 u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id)
256 snd_hda_jack_tbl_get_mst(codec, nid, dev_id);
258 jack_detect_update(codec, jack);
261 return read_pin_sense(codec, nid, dev_id);
267 * @codec: the CODEC to sense
274 int snd_hda_jack_detect_state_mst(struct hda_codec *codec,
278 snd_hda_jack_tbl_get_mst(codec, nid, dev_id);
281 else if (snd_hda_jack_pin_sense(codec, nid, dev_id) &
308 * @codec: the HDA codec
318 snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid,
325 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
345 if (codec->jackpoll_interval > 0)
347 err = snd_hda_codec_write_cache(codec, nid, 0,
358 * @codec: the HDA codec
365 int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
368 return PTR_ERR_OR_ZERO(snd_hda_jack_detect_enable_callback_mst(codec,
377 * @codec: the HDA codec
383 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
386 struct hda_jack_tbl *gated = snd_hda_jack_tbl_new(codec, gated_nid, 0);
388 snd_hda_jack_tbl_new(codec, gating_nid, 0);
390 WARN_ON(codec->dp_mst);
404 * @codec: the HDA codec
412 int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid,
417 struct hda_jack_tbl *key_gen = snd_hda_jack_tbl_get(codec, key_nid);
418 struct hda_jack_tbl *report_to = snd_hda_jack_tbl_get(codec, jack_nid);
420 WARN_ON(codec->dp_mst);
437 * @codec: the HDA codec
439 * @button_state: the button event captured by codec
443 void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid,
446 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid);
453 snd_hda_jack_tbl_get(codec, jack->key_report_jack);
467 * @codec: the HDA codec
469 void snd_hda_jack_report_sync(struct hda_codec *codec)
475 jack = codec->jacktbl.list;
476 for (i = 0; i < codec->jacktbl.used; i++, jack++)
478 jack_detect_update(codec, jack);
483 jack = codec->jacktbl.list;
484 for (i = 0; i < codec->jacktbl.used; i++, jack++)
502 static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid)
504 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
530 * @codec: the HDA codec
541 int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid,
549 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
556 type = get_input_jack_type(codec, nid);
564 err = snd_jack_new(codec->card, name, type | buttons,
579 state = snd_hda_jack_detect_mst(codec, nid, dev_id);
586 static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
595 WARN_ON(codec->dp_mst);
599 def_conf = snd_hda_codec_get_pincfg(codec, nid);
604 !is_jack_detectable(codec, nid);
609 snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL);
613 err = snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, 0, NULL);
618 return snd_hda_jack_detect_enable(codec, nid, 0);
624 * @codec: the HDA codec
627 int snd_hda_jack_add_kctls(struct hda_codec *codec,
638 err = add_jack_kctl(codec, auto_cfg_hp_pins(cfg)[0],
641 err = add_jack_kctl(codec, cfg->inputs[i].pin,
644 err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg,
651 err = add_jack_kctl(codec, *p, cfg, NULL);
658 err = add_jack_kctl(codec, *p, cfg, NULL);
665 err = add_jack_kctl(codec, *p, cfg, NULL);
670 err = add_jack_kctl(codec, *p, cfg, NULL);
674 err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, NULL);
677 err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, NULL);
684 static void call_jack_callback(struct hda_codec *codec, unsigned int res,
692 cb->func(codec, cb);
696 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
702 cb->func(codec, cb);
710 * @codec: the HDA codec
713 void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res)
718 if (codec->dp_mst) {
722 event = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry);
724 event = snd_hda_jack_tbl_get_from_tag(codec, tag, 0);
731 snd_hda_jack_tbl_get_mst(codec, event->key_report_jack,
738 call_jack_callback(codec, res, event);
739 snd_hda_jack_report_sync(codec);
745 * @codec: the HDA codec
750 void snd_hda_jack_poll_all(struct hda_codec *codec)
752 struct hda_jack_tbl *jack = codec->jacktbl.list;
755 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
760 jack_detect_update(codec, jack);
764 call_jack_callback(codec, 0, jack);
767 snd_hda_jack_report_sync(codec);