Lines Matching refs: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++) {
169 /* free jack instances manually when clearing/reconfiguring */
170 if (!codec->bus->shutdown && jack->jack)
171 snd_device_free(codec->card, jack->jack);
173 for (cb = jack->callback; cb; cb = next) {
185 struct hda_jack_tbl *jack)
187 if (!jack->jack_dirty)
190 if (jack->phantom_jack)
191 jack->pin_sense = AC_PINSENSE_PRESENCE;
193 jack->pin_sense = read_pin_sense(codec, jack->nid,
194 jack->dev_id);
196 /* A gating jack indicates the jack is invalid if gating is unplugged */
197 if (jack->gating_jack &&
198 !snd_hda_jack_detect_mst(codec, jack->gating_jack, jack->dev_id))
199 jack->pin_sense &= ~AC_PINSENSE_PRESENCE;
201 jack->jack_dirty = 0;
203 /* If a jack is gated by this one update it. */
204 if (jack->gated_jack) {
206 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
207 jack->dev_id);
219 * This function sets the dirty flag to all entries of jack table.
224 struct hda_jack_tbl *jack = codec->jacktbl.list;
227 for (i = 0; i < codec->jacktbl.used; i++, jack++)
228 if (jack->nid)
229 jack->jack_dirty = 1;
244 struct hda_jack_tbl *jack =
246 if (jack) {
247 jack_detect_update(codec, jack);
248 return jack->pin_sense;
266 struct hda_jack_tbl *jack =
268 if (jack && jack->phantom_jack)
279 find_callback_from_list(struct hda_jack_tbl *jack,
287 for (cb = jack->callback; cb; cb = cb->next) {
296 * snd_hda_jack_detect_enable_mst - enable the jack-detection
310 struct hda_jack_tbl *jack;
314 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
315 if (!jack)
318 callback = find_callback_from_list(jack, func);
325 callback->nid = jack->nid;
326 callback->dev_id = jack->dev_id;
327 callback->next = jack->callback;
328 jack->callback = callback;
331 if (jack->jack_detect)
333 jack->jack_detect = 1;
338 AC_USRSP_EN | jack->tag);
346 * snd_hda_jack_detect_enable - Enable the jack detection on the given pin
348 * @nid: pin NID to enable jack detection
351 * Enable the jack detection with the default callback. Returns zero if
365 * snd_hda_jack_set_gating_jack - Set gating jack.
370 * Indicates the gated jack is only valid when the gating jack is plugged.
397 struct hda_jack_tbl *jack;
401 jack = codec->jacktbl.list;
402 for (i = 0; i < codec->jacktbl.used; i++, jack++)
403 if (jack->nid)
404 jack_detect_update(codec, jack);
409 jack = codec->jacktbl.list;
410 for (i = 0; i < codec->jacktbl.used; i++, jack++)
411 if (jack->nid) {
412 if (!jack->jack || jack->block_report)
414 state = jack->button_state;
415 if (get_jack_plug_state(jack->pin_sense))
416 state |= jack->type;
417 snd_jack_report(jack->jack, state);
418 if (jack->button_state) {
419 snd_jack_report(jack->jack,
420 state & ~jack->button_state);
421 jack->button_state = 0; /* button released */
427 /* guess the jack type from the pin-config */
447 static void hda_free_jack_priv(struct snd_jack *jack)
449 struct hda_jack_tbl *jacks = jack->private_data;
451 jacks->jack = NULL;
459 * @name: string name for the jack
460 * @phantom_jack: flag to deal as a phantom jack
461 * @type: jack type bits to be reported, 0 for guessing from pincfg
462 * @keymap: optional jack / key mapping
464 * This assigns a jack-detection kctl to the given pin. The kcontrol
471 struct hda_jack_tbl *jack;
475 jack = snd_hda_jack_tbl_new(codec, nid, dev_id);
476 if (!jack)
478 if (jack->jack)
491 &jack->jack, true, phantom_jack);
495 jack->phantom_jack = !!phantom_jack;
496 jack->type = type;
497 jack->button_state = 0;
498 jack->jack->private_data = jack;
499 jack->jack->private_free = hda_free_jack_priv;
502 snd_jack_set_key(jack->jack, map->type, map->key);
506 snd_jack_report(jack->jack, state ? jack->type : 0);
611 struct hda_jack_tbl *jack)
615 for (cb = jack->callback; cb; cb = cb->next) {
616 cb->jack = jack;
620 if (jack->gated_jack) {
622 snd_hda_jack_tbl_get_mst(codec, jack->gated_jack,
623 jack->dev_id);
626 cb->jack = gated;
670 struct hda_jack_tbl *jack = codec->jacktbl.list;
673 for (i = 0; i < codec->jacktbl.used; i++, jack++) {
675 if (!jack->nid || !jack->jack_dirty || jack->phantom_jack)
677 old_sense = get_jack_plug_state(jack->pin_sense);
678 jack_detect_update(codec, jack);
679 if (old_sense == get_jack_plug_state(jack->pin_sense))
682 call_jack_callback(codec, 0, jack);