Lines Matching full:jack
3 * Jack-detection handling for HD-audio
13 #include <sound/jack.h>
20 * is_jack_detectable - Check whether the given pin is jack-detectable
24 * Check whether the given pin is capable to report the jack detection.
25 * The jack detection might not work by various reasons, e.g. the jack
65 * snd_hda_jack_tbl_get_mst - query the jack-table entry for the given NID
73 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_get_mst() local
76 if (!nid || !jack) in snd_hda_jack_tbl_get_mst()
78 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_tbl_get_mst()
79 if (jack->nid == nid && jack->dev_id == dev_id) in snd_hda_jack_tbl_get_mst()
80 return jack; in snd_hda_jack_tbl_get_mst()
86 * snd_hda_jack_tbl_get_from_tag - query the jack-table entry for the given tag
95 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_get_from_tag() local
98 if (!tag || !jack) 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()
101 if (jack->tag == tag && jack->dev_id == dev_id) in snd_hda_jack_tbl_get_from_tag()
102 return jack; in snd_hda_jack_tbl_get_from_tag()
110 struct hda_jack_tbl *jack = codec->jacktbl.list; in any_jack_tbl_get_from_nid() local
113 if (!nid || !jack) in any_jack_tbl_get_from_nid()
115 for (i = 0; i < codec->jacktbl.used; i++, jack++) in any_jack_tbl_get_from_nid()
116 if (jack->nid == nid) in any_jack_tbl_get_from_nid()
117 return jack; in any_jack_tbl_get_from_nid()
122 * snd_hda_jack_tbl_new - create a jack-table entry for the given NID
130 struct hda_jack_tbl *jack = in snd_hda_jack_tbl_new() local
137 if (jack) in snd_hda_jack_tbl_new()
138 return jack; in snd_hda_jack_tbl_new()
139 jack = snd_array_new(&codec->jacktbl); in snd_hda_jack_tbl_new()
140 if (!jack) in snd_hda_jack_tbl_new()
142 jack->nid = nid; in snd_hda_jack_tbl_new()
143 jack->dev_id = dev_id; in snd_hda_jack_tbl_new()
144 jack->jack_dirty = 1; in snd_hda_jack_tbl_new()
146 jack->tag = existing_nid_jack->tag; in snd_hda_jack_tbl_new()
153 jack->jack_detect = existing_nid_jack->jack_detect; in snd_hda_jack_tbl_new()
155 jack->tag = codec->jacktbl.used; in snd_hda_jack_tbl_new()
158 return jack; in snd_hda_jack_tbl_new()
163 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_disconnect() local
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()
174 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_tbl_clear() local
177 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_tbl_clear()
180 /* free jack instances manually when clearing/reconfiguring */ 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()
184 for (cb = jack->callback; cb; cb = next) { in snd_hda_jack_tbl_clear()
196 struct hda_jack_tbl *jack) in jack_detect_update() argument
198 if (!jack->jack_dirty) in jack_detect_update()
201 if (jack->phantom_jack) in jack_detect_update()
202 jack->pin_sense = AC_PINSENSE_PRESENCE; in jack_detect_update()
204 jack->pin_sense = read_pin_sense(codec, jack->nid, in jack_detect_update()
205 jack->dev_id); in jack_detect_update()
207 /* A gating jack indicates the jack is invalid if gating is unplugged */ in jack_detect_update()
208 if (jack->gating_jack && in jack_detect_update()
209 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id)) in jack_detect_update()
210 jack->pin_sense &= ~AC_PINSENSE_PRESENCE; in jack_detect_update()
212 jack->jack_dirty = 0; in jack_detect_update()
214 /* If a jack is gated by this one update it. */ in jack_detect_update()
215 if (jack->gated_jack) { in jack_detect_update()
217 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in jack_detect_update()
218 jack->dev_id); in jack_detect_update()
230 * This function sets the dirty flag to all entries of jack table.
235 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_set_dirty_all() local
238 for (i = 0; i < codec->jacktbl.used; i++, jack++) in snd_hda_jack_set_dirty_all()
239 if (jack->nid) in snd_hda_jack_set_dirty_all()
240 jack->jack_dirty = 1; in snd_hda_jack_set_dirty_all()
255 struct hda_jack_tbl *jack = in snd_hda_jack_pin_sense() local
257 if (jack) { in snd_hda_jack_pin_sense()
258 jack_detect_update(codec, jack); in snd_hda_jack_pin_sense()
259 return jack->pin_sense; in snd_hda_jack_pin_sense()
277 struct hda_jack_tbl *jack = in snd_hda_jack_detect_state_mst() local
279 if (jack && jack->phantom_jack) in snd_hda_jack_detect_state_mst()
290 find_callback_from_list(struct hda_jack_tbl *jack, in find_callback_from_list() argument
298 for (cb = jack->callback; cb; cb = cb->next) { in find_callback_from_list()
307 * snd_hda_jack_detect_enable_callback_mst - enable the jack-detection
321 struct hda_jack_tbl *jack; in snd_hda_jack_detect_enable_callback_mst() local
325 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_detect_enable_callback_mst()
326 if (!jack) in snd_hda_jack_detect_enable_callback_mst()
329 callback = find_callback_from_list(jack, func); in snd_hda_jack_detect_enable_callback_mst()
336 callback->nid = jack->nid; in snd_hda_jack_detect_enable_callback_mst()
337 callback->dev_id = jack->dev_id; in snd_hda_jack_detect_enable_callback_mst()
338 callback->next = jack->callback; in snd_hda_jack_detect_enable_callback_mst()
339 jack->callback = callback; in snd_hda_jack_detect_enable_callback_mst()
342 if (jack->jack_detect) in snd_hda_jack_detect_enable_callback_mst()
344 jack->jack_detect = 1; in snd_hda_jack_detect_enable_callback_mst()
349 AC_USRSP_EN | jack->tag); in snd_hda_jack_detect_enable_callback_mst()
357 * snd_hda_jack_detect_enable - Enable the jack detection on the given pin
359 * @nid: pin NID to enable jack detection
362 * Enable the jack detection with the default callback. Returns zero if
376 * snd_hda_jack_set_gating_jack - Set gating jack.
381 * Indicates the gated jack is only valid when the gating jack is plugged.
403 * snd_hda_jack_bind_keymap - bind keys generated from one NID to another jack.
407 * @jack_nid: key reports to the jack of this pin NID
410 * reported to the jack of another NID.
422 if (!key_gen || !report_to || !report_to->jack) in snd_hda_jack_bind_keymap()
429 snd_jack_set_key(report_to->jack, map->type, map->key); in snd_hda_jack_bind_keymap()
446 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid); in snd_hda_jack_set_button_state() local
448 if (!jack) in snd_hda_jack_set_button_state()
451 if (jack->key_report_jack) { 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()
461 jack->button_state = button_state; in snd_hda_jack_set_button_state()
471 struct hda_jack_tbl *jack; in snd_hda_jack_report_sync() local
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()
477 if (jack->nid) 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()
485 if (jack->nid) { in snd_hda_jack_report_sync()
486 if (!jack->jack || jack->block_report) in snd_hda_jack_report_sync()
488 state = jack->button_state; in snd_hda_jack_report_sync()
489 if (get_jack_plug_state(jack->pin_sense)) in snd_hda_jack_report_sync()
490 state |= jack->type; in snd_hda_jack_report_sync()
491 snd_jack_report(jack->jack, state); in snd_hda_jack_report_sync()
492 if (jack->button_state) { in snd_hda_jack_report_sync()
493 snd_jack_report(jack->jack, in snd_hda_jack_report_sync()
494 state & ~jack->button_state); in snd_hda_jack_report_sync()
495 jack->button_state = 0; /* button released */ in snd_hda_jack_report_sync()
501 /* guess the jack type from the pin-config */
521 static void hda_free_jack_priv(struct snd_jack *jack) in hda_free_jack_priv() argument
523 struct hda_jack_tbl *jacks = jack->private_data; in hda_free_jack_priv()
525 jacks->jack = NULL; in hda_free_jack_priv()
533 * @name: string name for the jack
534 * @phantom_jack: flag to deal as a phantom jack
535 * @type: jack type bits to be reported, 0 for guessing from pincfg
536 * @keymap: optional jack / key mapping
538 * This assigns a jack-detection kctl to the given pin. The kcontrol
545 struct hda_jack_tbl *jack; in snd_hda_jack_add_kctl_mst() local
549 jack = snd_hda_jack_tbl_new(codec, nid, dev_id); in snd_hda_jack_add_kctl_mst()
550 if (!jack) in snd_hda_jack_add_kctl_mst()
552 if (jack->jack) in snd_hda_jack_add_kctl_mst()
565 &jack->jack, true, phantom_jack); in snd_hda_jack_add_kctl_mst()
569 jack->phantom_jack = !!phantom_jack; in snd_hda_jack_add_kctl_mst()
570 jack->type = type; in snd_hda_jack_add_kctl_mst()
571 jack->button_state = 0; in snd_hda_jack_add_kctl_mst()
572 jack->jack->private_data = jack; in snd_hda_jack_add_kctl_mst()
573 jack->jack->private_free = hda_free_jack_priv; in snd_hda_jack_add_kctl_mst()
576 snd_jack_set_key(jack->jack, map->type, map->key); in snd_hda_jack_add_kctl_mst()
580 snd_jack_report(jack->jack, state ? jack->type : 0); in snd_hda_jack_add_kctl_mst()
611 /* Example final name: "Internal Mic Phantom Jack" */ in add_jack_kctl()
685 struct hda_jack_tbl *jack) in call_jack_callback() argument
689 for (cb = jack->callback; cb; cb = cb->next) { in call_jack_callback()
690 cb->jack = jack; in call_jack_callback()
694 if (jack->gated_jack) { in call_jack_callback()
696 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack, in call_jack_callback()
697 jack->dev_id); in call_jack_callback()
700 cb->jack = gated; in call_jack_callback()
752 struct hda_jack_tbl *jack = codec->jacktbl.list; in snd_hda_jack_poll_all() local
755 for (i = 0; i < codec->jacktbl.used; i++, jack++) { in snd_hda_jack_poll_all()
757 if (!jack->nid || !jack->jack_dirty || jack->phantom_jack) in snd_hda_jack_poll_all()
759 old_sense = get_jack_plug_state(jack->pin_sense); in snd_hda_jack_poll_all()
760 jack_detect_update(codec, jack); in snd_hda_jack_poll_all()
761 if (old_sense == get_jack_plug_state(jack->pin_sense)) in snd_hda_jack_poll_all()
764 call_jack_callback(codec, 0, jack); in snd_hda_jack_poll_all()