sound/hda/common/jack.c
Source file repositories/reference/linux-study-clean/sound/hda/common/jack.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/common/jack.c- Extension
.c- Size
- 20812 bytes
- Lines
- 777
- Domain
- Driver Families
- Bucket
- sound/hda
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/slab.hlinux/export.hsound/core.hsound/control.hsound/jack.hsound/hda_codec.hhda_local.hhda_auto_parser.hhda_jack.h
Detected Declarations
function Copyrightfunction read_pin_sensefunction snd_hda_jack_tbl_get_mstfunction snd_hda_jack_tbl_get_from_tagfunction any_jack_tbl_get_from_nidfunction snd_hda_jack_tbl_newfunction snd_hda_jack_tbl_disconnectfunction snd_hda_jack_tbl_clearfunction jack_detect_updatefunction snd_hda_jack_set_dirty_allfunction snd_hda_jack_pin_sensefunction snd_hda_jack_detect_state_mstfunction find_callback_from_listfunction snd_hda_jack_detect_enable_callback_mstfunction snd_hda_jack_detect_enablefunction snd_hda_jack_set_gating_jackfunction snd_hda_jack_bind_keymapfunction snd_hda_jack_set_button_statefunction snd_hda_jack_report_syncfunction get_input_jack_typefunction hda_free_jack_privfunction snd_hda_jack_add_kctl_mstfunction add_jack_kctlfunction snd_hda_jack_add_kctlsfunction call_jack_callbackfunction snd_hda_jack_unsol_eventfunction snd_hda_jack_report_syncexport is_jack_detectableexport snd_hda_jack_tbl_get_mstexport snd_hda_jack_tbl_get_from_tagexport snd_hda_jack_set_dirty_allexport snd_hda_jack_pin_senseexport snd_hda_jack_detect_state_mstexport snd_hda_jack_detect_enable_callback_mstexport snd_hda_jack_detect_enableexport snd_hda_jack_set_gating_jackexport snd_hda_jack_bind_keymapexport snd_hda_jack_set_button_stateexport snd_hda_jack_report_syncexport snd_hda_jack_add_kctl_mstexport snd_hda_jack_add_kctlsexport snd_hda_jack_unsol_eventexport snd_hda_jack_poll_all
Annotated Snippet
if (gated) {
gated->jack_dirty = 1;
jack_detect_update(codec, gated);
}
}
}
/**
* snd_hda_jack_set_dirty_all - Mark all the cached as dirty
* @codec: the HDA codec
*
* This function sets the dirty flag to all entries of jack table.
* It's called from the resume path in hda_codec.c.
*/
void snd_hda_jack_set_dirty_all(struct hda_codec *codec)
{
struct hda_jack_tbl *jack = codec->jacktbl.list;
int i;
for (i = 0; i < codec->jacktbl.used; i++, jack++)
if (jack->nid)
jack->jack_dirty = 1;
}
EXPORT_SYMBOL_GPL(snd_hda_jack_set_dirty_all);
/**
* snd_hda_jack_pin_sense - execute pin sense measurement
* @codec: the CODEC to sense
* @nid: the pin NID to sense
* @dev_id: pin device entry id
*
* Execute necessary pin sense measurement and return its Presence Detect,
* Impedance, ELD Valid etc. status bits.
*/
u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id)
{
struct hda_jack_tbl *jack =
snd_hda_jack_tbl_get_mst(codec, nid, dev_id);
if (jack) {
jack_detect_update(codec, jack);
return jack->pin_sense;
}
return read_pin_sense(codec, nid, dev_id);
}
EXPORT_SYMBOL_GPL(snd_hda_jack_pin_sense);
/**
* snd_hda_jack_detect_state_mst - query pin Presence Detect status
* @codec: the CODEC to sense
* @nid: the pin NID to sense
* @dev_id: pin device entry id
*
* Query and return the pin's Presence Detect status, as either
* HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT or HDA_JACK_PHANTOM.
*/
int snd_hda_jack_detect_state_mst(struct hda_codec *codec,
hda_nid_t nid, int dev_id)
{
struct hda_jack_tbl *jack =
snd_hda_jack_tbl_get_mst(codec, nid, dev_id);
if (jack && jack->phantom_jack)
return HDA_JACK_PHANTOM;
else if (snd_hda_jack_pin_sense(codec, nid, dev_id) &
AC_PINSENSE_PRESENCE)
return HDA_JACK_PRESENT;
else
return HDA_JACK_NOT_PRESENT;
}
EXPORT_SYMBOL_GPL(snd_hda_jack_detect_state_mst);
static struct hda_jack_callback *
find_callback_from_list(struct hda_jack_tbl *jack,
hda_jack_callback_fn func)
{
struct hda_jack_callback *cb;
if (!func)
return NULL;
for (cb = jack->callback; cb; cb = cb->next) {
if (cb->func == func)
return cb;
}
return NULL;
}
/**
* snd_hda_jack_detect_enable_callback_mst - enable the jack-detection
* @codec: the HDA codec
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/export.h`, `sound/core.h`, `sound/control.h`, `sound/jack.h`, `sound/hda_codec.h`, `hda_local.h`.
- Detected declarations: `function Copyright`, `function read_pin_sense`, `function snd_hda_jack_tbl_get_mst`, `function snd_hda_jack_tbl_get_from_tag`, `function any_jack_tbl_get_from_nid`, `function snd_hda_jack_tbl_new`, `function snd_hda_jack_tbl_disconnect`, `function snd_hda_jack_tbl_clear`, `function jack_detect_update`, `function snd_hda_jack_set_dirty_all`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.