sound/core/jack.c
Source file repositories/reference/linux-study-clean/sound/core/jack.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/jack.c- Extension
.c- Size
- 17346 bytes
- Lines
- 674
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/input.hlinux/slab.hlinux/module.hlinux/ctype.hlinux/mm.hlinux/debugfs.hsound/jack.hsound/core.hsound/control.h
Detected Declarations
struct snd_jack_kctlfunction snd_jack_dev_disconnectfunction snd_jack_dev_freefunction list_for_each_entry_safefunction snd_jack_dev_registerfunction snd_jack_inject_reportfunction sw_inject_enable_readfunction sw_inject_enable_writefunction jackin_inject_writefunction jack_kctl_id_readfunction parse_mask_bitsfunction jack_kctl_mask_bits_readfunction jack_kctl_status_readfunction jack_type_readfunction snd_jack_debugfs_add_inject_nodefunction snd_jack_remove_debugfsfunction list_for_each_entryfunction snd_jack_debugfs_add_inject_nodefunction snd_jack_remove_debugfsfunction snd_jack_kctl_addfunction snd_jack_kctl_newfunction snd_jack_add_new_kctlfunction snd_jack_newfunction snd_jack_set_keyfunction sleepexport snd_jack_add_new_kctlexport snd_jack_newexport snd_jack_set_keyexport snd_jack_report
Annotated Snippet
static const struct file_operations jack_type_fops = {
.open = simple_open,
.read = jack_type_read,
.llseek = default_llseek,
};
#endif
static const struct file_operations sw_inject_enable_fops = {
.open = simple_open,
.read = sw_inject_enable_read,
.write = sw_inject_enable_write,
.llseek = default_llseek,
};
static const struct file_operations jackin_inject_fops = {
.open = simple_open,
.write = jackin_inject_write,
.llseek = default_llseek,
};
static const struct file_operations jack_kctl_id_fops = {
.open = simple_open,
.read = jack_kctl_id_read,
.llseek = default_llseek,
};
static const struct file_operations jack_kctl_mask_bits_fops = {
.open = simple_open,
.read = jack_kctl_mask_bits_read,
.llseek = default_llseek,
};
static const struct file_operations jack_kctl_status_fops = {
.open = simple_open,
.read = jack_kctl_status_read,
.llseek = default_llseek,
};
static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
struct snd_jack_kctl *jack_kctl)
{
char *tname;
int i;
/* Don't create injection interface for Phantom jacks */
if (strstr(jack_kctl->kctl->id.name, "Phantom"))
return 0;
tname = kstrdup(jack_kctl->kctl->id.name, GFP_KERNEL);
if (!tname)
return -ENOMEM;
/* replace the chars which are not suitable for folder's name with _ */
for (i = 0; tname[i]; i++)
if (!isalnum(tname[i]))
tname[i] = '_';
jack_kctl->jack_debugfs_root = debugfs_create_dir(tname, jack->card->debugfs_root);
kfree(tname);
debugfs_create_file("sw_inject_enable", 0644, jack_kctl->jack_debugfs_root, jack_kctl,
&sw_inject_enable_fops);
debugfs_create_file("jackin_inject", 0200, jack_kctl->jack_debugfs_root, jack_kctl,
&jackin_inject_fops);
debugfs_create_file("kctl_id", 0444, jack_kctl->jack_debugfs_root, jack_kctl,
&jack_kctl_id_fops);
debugfs_create_file("mask_bits", 0444, jack_kctl->jack_debugfs_root, jack_kctl,
&jack_kctl_mask_bits_fops);
debugfs_create_file("status", 0444, jack_kctl->jack_debugfs_root, jack_kctl,
&jack_kctl_status_fops);
#ifdef CONFIG_SND_JACK_INPUT_DEV
debugfs_create_file("type", 0444, jack_kctl->jack_debugfs_root, jack_kctl,
&jack_type_fops);
#endif
return 0;
}
static void snd_jack_remove_debugfs(struct snd_jack *jack)
{
struct snd_jack_kctl *jack_kctl;
list_for_each_entry(jack_kctl, &jack->kctl_list, list) {
debugfs_remove(jack_kctl->jack_debugfs_root);
jack_kctl->jack_debugfs_root = NULL;
}
Annotation
- Immediate include surface: `linux/input.h`, `linux/slab.h`, `linux/module.h`, `linux/ctype.h`, `linux/mm.h`, `linux/debugfs.h`, `sound/jack.h`, `sound/core.h`.
- Detected declarations: `struct snd_jack_kctl`, `function snd_jack_dev_disconnect`, `function snd_jack_dev_free`, `function list_for_each_entry_safe`, `function snd_jack_dev_register`, `function snd_jack_inject_report`, `function sw_inject_enable_read`, `function sw_inject_enable_write`, `function jackin_inject_write`, `function jack_kctl_id_read`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: pattern 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.