sound/core/seq/oss/seq_oss.c

Source file repositories/reference/linux-study-clean/sound/core/seq/oss/seq_oss.c

File Facts

System
Linux kernel
Corpus path
sound/core/seq/oss/seq_oss.c
Extension
.c
Size
6635 bytes
Lines
302
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 seq_oss_f_ops =
{
	.owner =	THIS_MODULE,
	.read =		odev_read,
	.write =	odev_write,
	.open =		odev_open,
	.release =	odev_release,
	.poll =		odev_poll,
	.unlocked_ioctl =	odev_ioctl,
	.compat_ioctl =	odev_ioctl_compat,
	.llseek =	noop_llseek,
};

static int __init
register_device(void)
{
	int rc;

	guard(mutex)(&register_mutex);
	rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
				     NULL, 0,
				     &seq_oss_f_ops, NULL);
	if (rc < 0) {
		pr_err("ALSA: seq_oss: can't register device seq\n");
		return rc;
	}
	rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
				     NULL, 0,
				     &seq_oss_f_ops, NULL);
	if (rc < 0) {
		pr_err("ALSA: seq_oss: can't register device music\n");
		snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
		return rc;
	}
	return 0;
}

static void
unregister_device(void)
{
	guard(mutex)(&register_mutex);
	if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0)		
		pr_err("ALSA: seq_oss: error unregister device music\n");
	if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0)
		pr_err("ALSA: seq_oss: error unregister device seq\n");
}

/*
 * /proc interface
 */

#ifdef CONFIG_SND_PROC_FS

static struct snd_info_entry *info_entry;

static void
info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf)
{
	guard(mutex)(&register_mutex);
	snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR);
	snd_seq_oss_system_info_read(buf);
	snd_seq_oss_synth_info_read(buf);
	snd_seq_oss_midi_info_read(buf);
}


static int __init
register_proc(void)
{
	struct snd_info_entry *entry;

	entry = snd_info_create_module_entry(THIS_MODULE, SNDRV_SEQ_OSS_PROCNAME, snd_seq_root);
	if (entry == NULL)
		return -ENOMEM;

	entry->content = SNDRV_INFO_CONTENT_TEXT;
	entry->private_data = NULL;
	entry->c.text.read = info_read;
	if (snd_info_register(entry) < 0) {
		snd_info_free_entry(entry);
		return -ENOMEM;
	}
	info_entry = entry;
	return 0;
}

static void
unregister_proc(void)
{
	snd_info_free_entry(info_entry);

Annotation

Implementation Notes