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.

Dependency Surface

Detected Declarations

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

Implementation Notes