sound/core/seq/oss/seq_oss_init.c
Source file repositories/reference/linux-study-clean/sound/core/seq/oss/seq_oss_init.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/seq/oss/seq_oss_init.c- Extension
.c- Size
- 10741 bytes
- Lines
- 495
- 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_device.hseq_oss_synth.hseq_oss_midi.hseq_oss_writeq.hseq_oss_readq.hseq_oss_timer.hseq_oss_event.hlinux/init.hlinux/export.hlinux/moduleparam.hlinux/slab.hlinux/workqueue.h
Detected Declarations
function async_call_lookup_portsfunction snd_seq_oss_create_clientfunction receive_announcefunction snd_seq_oss_delete_clientfunction snd_seq_oss_openfunction translate_modefunction create_portfunction delete_portfunction alloc_seq_queuefunction delete_seq_queuefunction free_devinfofunction snd_seq_oss_releasefunction snd_seq_oss_resetfunction filemode_strfunction snd_seq_oss_system_info_read
Annotated Snippet
if (!dp->readq) {
rc = -ENOMEM;
goto _error;
}
}
/* initialize write queue */
if (is_write_mode(dp->file_mode)) {
dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen);
if (!dp->writeq) {
rc = -ENOMEM;
goto _error;
}
}
/* initialize timer */
dp->timer = snd_seq_oss_timer_new(dp);
if (!dp->timer) {
pr_err("ALSA: seq_oss: can't alloc timer\n");
rc = -ENOMEM;
goto _error;
}
/* set private data pointer */
file->private_data = dp;
/* set up for mode2 */
if (level == SNDRV_SEQ_OSS_MODE_MUSIC)
snd_seq_oss_synth_setup_midi(dp);
else if (is_read_mode(dp->file_mode))
snd_seq_oss_midi_open_all(dp, SNDRV_SEQ_OSS_FILE_READ);
client_table[dp->index] = dp;
num_clients++;
return 0;
_error:
snd_seq_oss_synth_cleanup(dp);
snd_seq_oss_midi_cleanup(dp);
delete_seq_queue(dp->queue);
delete_port(dp);
return rc;
}
/*
* translate file flags to private mode
*/
static int
translate_mode(struct file *file)
{
int file_mode = 0;
if ((file->f_flags & O_ACCMODE) != O_RDONLY)
file_mode |= SNDRV_SEQ_OSS_FILE_WRITE;
if ((file->f_flags & O_ACCMODE) != O_WRONLY)
file_mode |= SNDRV_SEQ_OSS_FILE_READ;
if (file->f_flags & O_NONBLOCK)
file_mode |= SNDRV_SEQ_OSS_FILE_NONBLOCK;
return file_mode;
}
/*
* create sequencer port
*/
static int
create_port(struct seq_oss_devinfo *dp)
{
int rc;
struct snd_seq_port_info port;
struct snd_seq_port_callback callback;
memset(&port, 0, sizeof(port));
port.addr.client = dp->cseq;
sprintf(port.name, "Sequencer-%d", dp->index);
port.capability = SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_WRITE; /* no subscription */
port.type = SNDRV_SEQ_PORT_TYPE_SPECIFIC;
port.midi_channels = 128;
port.synth_voices = 128;
memset(&callback, 0, sizeof(callback));
callback.owner = THIS_MODULE;
callback.private_data = dp;
callback.event_input = snd_seq_oss_event_input;
callback.private_free = free_devinfo;
port.kernel = &callback;
rc = call_ctl(SNDRV_SEQ_IOCTL_CREATE_PORT, &port);
if (rc < 0)
Annotation
- Immediate include surface: `seq_oss_device.h`, `seq_oss_synth.h`, `seq_oss_midi.h`, `seq_oss_writeq.h`, `seq_oss_readq.h`, `seq_oss_timer.h`, `seq_oss_event.h`, `linux/init.h`.
- Detected declarations: `function async_call_lookup_ports`, `function snd_seq_oss_create_client`, `function receive_announce`, `function snd_seq_oss_delete_client`, `function snd_seq_oss_open`, `function translate_mode`, `function create_port`, `function delete_port`, `function alloc_seq_queue`, `function delete_seq_queue`.
- 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.