Lines Matching defs:jack

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;
76 if (!nid || !jack)
78 for (i = 0; i < codec->jacktbl.used; i++, jack++)
79 if (jack->nid == nid && jack->dev_id == dev_id)
80 return jack;
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;
98 if (!tag || !jack)
100 for (i = 0; i < codec->jacktbl.used; i++, jack++)
101 if (jack->tag == tag && jack->dev_id == dev_id)
102 return jack;
110 struct hda_jack_tbl *jack = codec->jacktbl.list;
113 if (!nid || !jack)
115 for (i = 0; i < codec->jacktbl.used; i++, jack++)
116 if (jack->nid == nid)
117 return jack;
122 * snd_hda_jack_tbl_new - create a jack-table entry for the given NID
130 struct hda_jack_tbl *jack =
137 if (jack)
138 return jack;
139 jack = snd_array_new(&codec->jacktbl);
140 if (!jack)
142 jack->nid = nid;
143 jack->dev_id = dev_id;
144 jack->jack_dirty = 1;
146 jack->tag = existing_nid_jack->tag;
153 jack->jack_detect = existing_nid_jack->jack_detect;
155 jack->tag = codec->jacktbl.used;
158 return jack;
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);
174 struct hda_jack_tbl *jack = codec->jacktbl.list;
177 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
180 /* free jack instances manually when clearing/reconfiguring */
181 if (!codec->bus->shutdown && jack->jack)
182 snd_device_free(codec->card, jack->jack);
184 for (cb = jack->callback; cb; cb = next) {
196 struct hda_jack_tbl *jack)
198 if (!jack->jack_dirty)
201 if (jack->phantom_jack)
202 jack->pin_sense = AC_PINSENSE_PRESENCE;
204 jack->pin_sense = read_pin_sense(codec, jack->nid,
205 jack->dev_id);
207 /* A gating jack indicates the jack is invalid if gating is unplugged */
208 if (jack->gating_jack &&
209 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id))
210 jack->pin_sense &= ~AC_PINSENSE_PRESENCE;
212 jack->jack_dirty = 0;
214 /* If a jack is gated by this one update it. */
215 if (jack->gated_jack) {
217 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
218 jack->dev_id);
230 * This function sets the dirty flag to all entries of jack table.
235 struct hda_jack_tbl *jack = codec->jacktbl.list;
238 for (i = 0; i < codec->jacktbl.used; i++, jack++)
239 if (jack->nid)
240 jack->jack_dirty = 1;
255 struct hda_jack_tbl *jack =
257 if (jack) {
258 jack_detect_update(codec, jack);
259 return jack->pin_sense;
277 struct hda_jack_tbl *jack =
279 if (jack && jack->phantom_jack)
290 find_callback_from_list(struct hda_jack_tbl *jack,
298 for (cb = jack->callback; cb; cb = cb->next) {
307 * snd_hda_jack_detect_enable_callback_mst - enable the jack-detection
321 struct hda_jack_tbl *jack;
325 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
326 if (!jack)
329 callback = find_callback_from_list(jack, func);
336 callback->nid = jack->nid;
337 callback->dev_id = jack->dev_id;
338 callback->next = jack->callback;
339 jack->callback = callback;
342 if (jack->jack_detect)
344 jack->jack_detect = 1;
349 AC_USRSP_EN | jack->tag);
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)
429 snd_jack_set_key(report_to->jack, map->type, map->key);
446 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid);
448 if (!jack)
451 if (jack->key_report_jack) {
453 snd_hda_jack_tbl_get(codec, jack->key_report_jack);
461 jack->button_state = button_state;
471 struct hda_jack_tbl *jack;
475 jack = codec->jacktbl.list;
476 for (i = 0; i < codec->jacktbl.used; i++, jack++)
477 if (jack->nid)
478 jack_detect_update(codec, jack);
483 jack = codec->jacktbl.list;
484 for (i = 0; i < codec->jacktbl.used; i++, jack++)
485 if (jack->nid) {
486 if (!jack->jack || jack->block_report)
488 state = jack->button_state;
489 if (get_jack_plug_state(jack->pin_sense))
490 state |= jack->type;
491 snd_jack_report(jack->jack, state);
492 if (jack->button_state) {
493 snd_jack_report(jack->jack,
494 state & ~jack->button_state);
495 jack->button_state = 0; /* button released */
501 /* guess the jack type from the pin-config */
521 static void hda_free_jack_priv(struct snd_jack *jack)
523 struct hda_jack_tbl *jacks = jack->private_data;
525 jacks->jack = NULL;
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;
549 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
550 if (!jack)
552 if (jack->jack)
565 &jack->jack, true, phantom_jack);
569 jack->phantom_jack = !!phantom_jack;
570 jack->type = type;
571 jack->button_state = 0;
572 jack->jack->private_data = jack;
573 jack->jack->private_free = hda_free_jack_priv;
576 snd_jack_set_key(jack->jack, map->type, map->key);
580 snd_jack_report(jack->jack, state ? jack->type : 0);
685 struct hda_jack_tbl *jack)
689 for (cb = jack->callback; cb; cb = cb->next) {
690 cb->jack = jack;
694 if (jack->gated_jack) {
696 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
697 jack->dev_id);
700 cb->jack = gated;
752 struct hda_jack_tbl *jack = codec->jacktbl.list;
755 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
757 if (!jack->nid || !jack->jack_dirty || jack->phantom_jack)
759 old_sense = get_jack_plug_state(jack->pin_sense);
760 jack_detect_update(codec, jack);
761 if (old_sense == get_jack_plug_state(jack->pin_sense))
764 call_jack_callback(codec, 0, jack);