sound/core/seq/oss/seq_oss_synth.c
Source file repositories/reference/linux-study-clean/sound/core/seq/oss/seq_oss_synth.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/seq/oss/seq_oss_synth.c- Extension
.c- Size
- 12970 bytes
- Lines
- 594
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
seq_oss_synth.hseq_oss_midi.h../seq_lock.hlinux/init.hlinux/module.hlinux/slab.hlinux/nospec.h
Detected Declarations
struct seq_oss_synthfunction snd_seq_oss_synth_initfunction snd_seq_oss_synth_probefunction snd_seq_oss_synth_removefunction scoped_guardfunction get_sdevfunction snd_seq_oss_synth_setupfunction snd_seq_oss_synth_setup_midifunction snd_seq_oss_synth_cleanupfunction get_synthinfo_nospecfunction get_synthdevfunction reset_channelsfunction snd_seq_oss_synth_resetfunction snd_seq_oss_synth_load_patchfunction snd_seq_oss_synth_infofunction snd_seq_oss_synth_sysexfunction snd_seq_oss_synth_addrfunction snd_seq_oss_synth_ioctlfunction snd_seq_oss_synth_raw_eventfunction snd_seq_oss_synth_make_infofunction snd_seq_oss_synth_info_read
Annotated Snippet
struct seq_oss_synth {
int seq_device;
/* for synth_info */
int synth_type;
int synth_subtype;
int nr_voices;
char name[SNDRV_SEQ_OSS_MAX_SYNTH_NAME];
struct snd_seq_oss_callback oper;
int opened;
void *private_data;
snd_use_lock_t use_lock;
};
DEFINE_FREE(seq_oss_synth, struct seq_oss_synth *, if (!IS_ERR_OR_NULL(_T)) snd_use_lock_free(&(_T)->use_lock))
/*
* device table
*/
static int max_synth_devs;
static struct seq_oss_synth *synth_devs[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
static struct seq_oss_synth midi_synth_dev = {
.seq_device = -1,
.synth_type = SYNTH_TYPE_MIDI,
.synth_subtype = 0,
.nr_voices = 16,
.name = "MIDI",
};
static DEFINE_SPINLOCK(register_lock);
/*
* prototypes
*/
static struct seq_oss_synth *get_synthdev(struct seq_oss_devinfo *dp, int dev);
static void reset_channels(struct seq_oss_synthinfo *info);
/*
* global initialization
*/
void __init
snd_seq_oss_synth_init(void)
{
snd_use_lock_init(&midi_synth_dev.use_lock);
}
/*
* registration of the synth device
*/
int
snd_seq_oss_synth_probe(struct snd_seq_device *dev)
{
int i;
struct seq_oss_synth *rec;
struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
rec = kzalloc(sizeof(*rec), GFP_KERNEL);
if (!rec)
return -ENOMEM;
rec->seq_device = -1;
rec->synth_type = reg->type;
rec->synth_subtype = reg->subtype;
rec->nr_voices = reg->nvoices;
rec->oper = reg->oper;
rec->private_data = reg->private_data;
rec->opened = 0;
snd_use_lock_init(&rec->use_lock);
/* copy and truncate the name of synth device */
strscpy(rec->name, dev->name, sizeof(rec->name));
/* registration */
scoped_guard(spinlock_irqsave, ®ister_lock) {
for (i = 0; i < max_synth_devs; i++) {
if (synth_devs[i] == NULL)
break;
}
if (i >= max_synth_devs) {
if (max_synth_devs >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS) {
pr_err("ALSA: seq_oss: no more synth slot\n");
kfree(rec);
return -ENOMEM;
}
max_synth_devs++;
}
rec->seq_device = i;
synth_devs[i] = rec;
Annotation
- Immediate include surface: `seq_oss_synth.h`, `seq_oss_midi.h`, `../seq_lock.h`, `linux/init.h`, `linux/module.h`, `linux/slab.h`, `linux/nospec.h`.
- Detected declarations: `struct seq_oss_synth`, `function snd_seq_oss_synth_init`, `function snd_seq_oss_synth_probe`, `function snd_seq_oss_synth_remove`, `function scoped_guard`, `function get_sdev`, `function snd_seq_oss_synth_setup`, `function snd_seq_oss_synth_setup_midi`, `function snd_seq_oss_synth_cleanup`, `function get_synthinfo_nospec`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: source 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.