sound/drivers/opl4/opl4_seq.c
Source file repositories/reference/linux-study-clean/sound/drivers/opl4/opl4_seq.c
File Facts
- System
- Linux kernel
- Corpus path
sound/drivers/opl4/opl4_seq.c- Extension
.c- Size
- 5693 bytes
- Lines
- 202
- Domain
- Driver Families
- Bucket
- sound/drivers
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
opl4_local.hlinux/init.hlinux/moduleparam.hlinux/module.hsound/initval.h
Detected Declarations
function snd_opl4_seq_use_incfunction snd_opl4_seq_use_decfunction snd_opl4_seq_usefunction scoped_guardfunction snd_opl4_seq_unusefunction scoped_guardfunction snd_opl4_seq_event_inputfunction snd_opl4_seq_free_portfunction snd_opl4_seq_probefunction snd_opl4_seq_remove
Annotated Snippet
if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) {
err = snd_opl4_seq_use_inc(opl4);
if (err < 0)
return err;
}
}
snd_opl4_synth_reset(opl4);
return 0;
}
static int snd_opl4_seq_unuse(void *private_data, struct snd_seq_port_subscribe *info)
{
struct snd_opl4 *opl4 = private_data;
snd_opl4_synth_shutdown(opl4);
scoped_guard(mutex, &opl4->access_mutex) {
opl4->used--;
}
if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM)
snd_opl4_seq_use_dec(opl4);
return 0;
}
static const struct snd_midi_op opl4_ops = {
.note_on = snd_opl4_note_on,
.note_off = snd_opl4_note_off,
.note_terminate = snd_opl4_terminate_note,
.control = snd_opl4_control,
.sysex = snd_opl4_sysex,
};
static int snd_opl4_seq_event_input(struct snd_seq_event *ev, int direct,
void *private_data, int atomic, int hop)
{
struct snd_opl4 *opl4 = private_data;
snd_midi_process_event(&opl4_ops, ev, opl4->chset);
return 0;
}
static void snd_opl4_seq_free_port(void *private_data)
{
struct snd_opl4 *opl4 = private_data;
snd_midi_channel_free_set(opl4->chset);
}
static int snd_opl4_seq_probe(struct snd_seq_device *dev)
{
struct snd_opl4 *opl4;
int client;
struct snd_seq_port_callback pcallbacks;
opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(dev);
if (!opl4)
return -EINVAL;
if (snd_yrw801_detect(opl4) < 0)
return -ENODEV;
opl4->chset = snd_midi_channel_alloc_set(16);
if (!opl4->chset)
return -ENOMEM;
opl4->chset->private_data = opl4;
/* allocate new client */
client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num,
"OPL4 Wavetable");
if (client < 0) {
snd_midi_channel_free_set(opl4->chset);
return client;
}
opl4->seq_client = client;
opl4->chset->client = client;
/* create new port */
memset(&pcallbacks, 0, sizeof(pcallbacks));
pcallbacks.owner = THIS_MODULE;
pcallbacks.use = snd_opl4_seq_use;
pcallbacks.unuse = snd_opl4_seq_unuse;
pcallbacks.event_input = snd_opl4_seq_event_input;
pcallbacks.private_free = snd_opl4_seq_free_port;
pcallbacks.private_data = opl4;
opl4->chset->port = snd_seq_event_port_attach(client, &pcallbacks,
SNDRV_SEQ_PORT_CAP_WRITE |
SNDRV_SEQ_PORT_CAP_SUBS_WRITE,
Annotation
- Immediate include surface: `opl4_local.h`, `linux/init.h`, `linux/moduleparam.h`, `linux/module.h`, `sound/initval.h`.
- Detected declarations: `function snd_opl4_seq_use_inc`, `function snd_opl4_seq_use_dec`, `function snd_opl4_seq_use`, `function scoped_guard`, `function snd_opl4_seq_unuse`, `function scoped_guard`, `function snd_opl4_seq_event_input`, `function snd_opl4_seq_free_port`, `function snd_opl4_seq_probe`, `function snd_opl4_seq_remove`.
- Atlas domain: Driver Families / sound/drivers.
- 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.